Skip to content

Commit 0871f93

Browse files
final bouncing box
1 parent 780d0e6 commit 0871f93

1 file changed

Lines changed: 25 additions & 14 deletions

File tree

fsd-projects/bouncing-box/index.html

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,15 @@
55
<title>Bouncing Box</title>
66
<script src="jquery.min.js"></script>
77
<style>
8+
body {
9+
background-image: url("https://cdnb.artstation.com/p/assets/images/images/043/396/311/large/eugene-ball-animation-background.jpg?1637151506");
10+
background-color: #555;
11+
}
812
.box {
9-
width: 70px;
10-
height: 70px;
11-
background-color: teal;
13+
width: 200px;
14+
height: 200px;
15+
background-image:url("https://pngimg.com/uploads/birds/birds_PNG115.png");
16+
background-color: #5B9C99;
1217
font-size: 300%;
1318
text-align: center;
1419
user-select: none;
@@ -69,9 +74,9 @@
6974
//////////////////////////////////////////////////////////////////
7075

7176
// TODO 2 - Variable declarations
72-
73-
74-
77+
var positionX = 0;
78+
var points = 0;
79+
var speed = 10;
7580

7681

7782
/**
@@ -80,9 +85,15 @@
8085
* If the box drifts off the screen, turn it around!
8186
*/
8287
function update() {
83-
84-
85-
88+
moveBoxTo(positionX); //Moves the box to x-position 200
89+
positionX = positionX += speed;
90+
if (positionX > boardWidth) {
91+
speed *= -1;
92+
}
93+
94+
else if (positionX < 0){
95+
speed*= -1;
96+
}
8697

8798
}
8899

@@ -93,11 +104,11 @@
93104
* - increase the speed
94105
* - move the box to the left side of the screen.
95106
*/
96-
function handleBoxClick() {
97-
98-
99-
100-
107+
function handleBoxClick() {
108+
positionX = 0;
109+
changeBoxText(points);
110+
points++;
111+
speed = 3 * points + 10;
101112
}
102113

103114

0 commit comments

Comments
 (0)