JS Pinball Game

Source: Internet
Author: User
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> 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.