-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
72 lines (62 loc) · 1.78 KB
/
index.js
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
let resolution = {
width: window.innerWidth,
height: window.innerHeight - 5
};
let screen = document.querySelector('canvas');
screen.setAttribute('height', resolution.height);
screen.setAttribute('width', resolution.width);
let myEngine = new GameEngine(screen);
let myFloor = new Floor('floor', resolution);
let myBackground = new Background(myEngine, 'background', resolution);
let cannonGame = new Game(myEngine);
let controls = new TouchControls(myEngine, screen, resolution);
let myWall;
if (resolution.width >= resolution.height) {
myWall = new Wall('wall', {
x: (resolution.width / 2) - 25,
y: (resolution.height * 8 / 12)
}, resolution.width / 23, resolution.height * 3 / 4);
} else {
myWall = new Wall('wall', {
x: (resolution.width / 2) - 25,
y: (resolution.height * 10 / 12)
}, resolution.width / 23, resolution.height * 3 / 4);
}
// aqui tem um gato...
myEngine.addElement(new Ball(myEngine, 'ball', 0, 0, 0, 0, ''));
// gato termina aqui...
let myRooster = new Rooster(myEngine);
let myCannon1 = new Cannon(
myEngine,
'cannonLeft', {
x: 30,
y: resolution.height - 95
},
true,
resolution
);
let myCannon2 = new Cannon(
myEngine,
'cannonRight', {
x: resolution.width - 90,
y: resolution.height - 95
},
false,
resolution
);
let myAi = new Ai(myEngine, myCannon2);
myEngine.setAi(myAi)
myEngine.addColideElement(myCannon1);
myEngine.addColideElement(myCannon2);
myEngine.addColideElement(myFloor);
myEngine.addColideElement(myWall);
cannonGame.addElement(myBackground);
cannonGame.addElement(myFloor);
cannonGame.addElement(myCannon1);
cannonGame.addElement(myCannon2);
cannonGame.addElement(myRooster);
cannonGame.addElement(myWall);
cannonGame.addElement(myAi);
cannonGame.setControls(controls);
cannonGame.setAi(myAi);
cannonGame.start();