Assignment 1 A JavaScript Game solution

$24.99

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

The goal of this project is to learn JavaScript and DOM by implementing a simple computer game, reminiscent to the Pong arcade video game from the 70s.
This project must be done individually. No copying is permitted. Note: We will use a system for detecting software plagiarism, called Moss, which is an automatic system for determining the similarity of programs. That is, your program will be compared with the programs of the other students in class as well as with the programs submitted in previous years.

Platform
You will do this project on your own PC/laptop. You have to use the Mozilla Firefox web browser and you can use the firebug plugin for debugging your JavaScript code. To run JavaScript expressions, such as print the value of a variable, activate Firebug and on its Console menu select “Show Command Editor”, then type an expression such as 1+2 and hit Run.

Documentation
The following web pages contain various tutorials. Use them as a reference only. The class slides contain enough information on JavaScript and DOM.

JavaScript Tutorial
JavaScript
JavaScript DOM

Project Description
You need to write a JavaScript file pong.js, used in the file pong.html, that implements the following actions:

initialize: initialize the game
startGame: starts the game (when you click the mouse)
setSpeed: sets the speed to 0 (slow), 1 (medium), 2 (fast)
resetCounter: resets the score to zero
movePaddle: moves the paddle up and down, by folowing the mouse
Please watch the video pong.mp4 for a demo of how your game should look like.

Description: The pong court is 1100x600px, the pong ball is 50x50px, and the paddle is 102x14px. When you click left on the court, the ball will start from a random place at the left border of the court at a random angle between -π/4 and π/4. The paddle can move up and down on the right border by just moving the mouse (without clicking the mouse). The ball bounces at the left, top, and bottom borders of the court. If the ball crosses the right border, you loose a point and the game is suspended (you would need to click on the court again to resume). So the goal of this game is to move the paddle to protect the right border by hitting the ball.

Hints:

The position of any element is dictated by the three style properties: position, left, and top. If an element is nested inside another and its position is “absolute”, the top and left properties are relative to the enclosing element.