It will actually stop at the value of y were it started. The game physics knows to make the acceleration invert so the ball will slow down as it moves upward. If they have, their velocity is set to negative to make them go back up. Creating the bounceĪ game update interval (the onUpdateInterval function) checks to see if any balls have reached the bottom of the screen. The red and orange balls go faster at 20 and 30 pixels per second. Green balls go slow, 10 pixels per second. The ball is also sent moving left to right at a constant velocity based on the color of the ball. This makes the ball sprite speed up as it drops, simulating the effect of gravity. The value of acceleration chosen for the game is 100 pixels per second, per second. To make the sprite behave like a real ball dropping from above, it begins at the top of the screen with velocity of 0 and is given a value of acceleration in the down direction. Along with a position, we can assign velocity and acceleration to a sprite representing a ball. Using the motion properties of sprites we can simulate the action of a ball or balls bouncing. Balls move at different speeds so catching a faster ball scores a higher point value. The player scores points for each ball caught. The purpose of the game is to catch the balls in a bucket before they bounce away and leave the screen. This game drops balls onto the screen and makes them bounce while moving left to right.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |