-
Notifications
You must be signed in to change notification settings - Fork 0
/
game.js
44 lines (42 loc) · 869 Bytes
/
game.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
let birdX = 50
let birdY = 300
let poletopX = []
let poletopY = 400
let polebotY = -600
let speed = 0
const grav = 0.3
for(let i = 0; i < 5; i++){
poletopX[i] = 900 + i*Math.random()*600
}
function update(){
speed += grav
if(birdY > 700){
alert("deiba")
}
for(let i = 0; i < 5; i++){
if(areColliding(birdX, birdY, 50, 50, poletopX[i], poletopY, 75, 500)){
alert("deiba")
}
if(areColliding(birdX, birdY, 50, 50, poletopX[i], polebotY, 75, 800)){
alert("deiba")
}
poletopX[i] -= 3
if(poletopX[i] < - 75){
poletopX[i] = 900 + i*Math.random()*600
}
}
birdY += speed
}
function draw(){
drawImage(bird, birdX, birdY, 50, 50)
for(let i = 0; i < 5; i++){
drawImage(barrelRed, poletopX[i], poletopY, 75, 500)
drawImage(barrelRed, poletopX[i], polebotY, 75, 800)
}
}
function keyup(key){
if(key == 32){
speed -= 6
birdY += speed
}
}