1. Introduction to the game
The ball can only move within the specified area. and hit the upper, left and right three sides rebounded. And hit the lower side is to lose. You can use the bezel to bounce the ball.
2. Game parameter Setting
(1), the ball as the object, there are four kinds of behavior.
1, basic Movement (x+y)
ball.speedx = 1;
Ball.speedy = 1;
2, the wall turned
Ball.speedx =-ball.speedx (the condition is ball.style.left<=0 | | ball.style.left>=370)
ball.speedy =- Ball.speedy (occurrence condition is ball.style.top<=0)
3, touch baffle turn
ball.speedy =-ball.speedy;
(Conditions are ball.style.left+15 >= board.style.left && ball.style.left+15 <=board.style.left+60 && Ball.style.top+30 >=board.style.top)
4, when the next wall is judged to be lost
alert (' You lost ... Click OK to come again ... ');
(Occurrence condition is ball.style.top>=370)
(2), with the baffle as the object, there are 1 kinds of behavior
1. Move with
the mouse (the condition is
board.style.left=e.offsetx-30 + ' px ');
board.style.top=e.offsety-20 + ' px ';
3, all the code.
<! DOCTYPE html>