-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPong.js
More file actions
33 lines (26 loc) · 803 Bytes
/
Pong.js
File metadata and controls
33 lines (26 loc) · 803 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Pong.js
* Created on Tuesday 22 November 2016 by Josie Musto, Opus Laboris Recruitment
*/
var PongController =
{
// This method is called when the form is loaded
Load: function()
{
// Your code here
debugger;
const canvas = document.querySelector('#pong');
const pong = new Pong(canvas);
canvas.addEventListener('click', () => pong.play());
canvas.addEventListener('mousemove', event => {
const scale = event.offsetY / event.target.getBoundingClientRect().height;
pong.players[0].pos.y = canvas.height * scale;
});
pong.start();
}
};
// This event fires after the associated Pong.html file is loaded into the DOM
$(document).ready(function ()
{
PongController.Load();
});