-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
49 lines (39 loc) · 1.11 KB
/
sketch.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
function preload() {
let bgImage;
let baseImg;
let midflap
let upflap
let downflap
let dayTime = ['day','night']
let choice = floor(random(0,2))
bgImage = loadImage(`data/sprites/background-${dayTime[choice]}.png`);
baseImg = loadImage('data/sprites/base.png')
scene = new Scene(bgImage, baseImg)
// Load bird sprites
midflap = loadImage('data/sprites/yellowbird-midflap.png')
birdSprites.push(midflap)
upflap = loadImage('data/sprites/yellowbird-upflap.png')
birdSprites.push(upflap)
downflap = loadImage('data/sprites/yellowbird-downflap.png')
birdSprites.push(downflap)
// Pipes sprites
let pipeUp = loadImage('data/sprites/pipe-green-down.png')
pipeSprites.push(pipeUp)
let pipeDown = loadImage('data/sprites/pipe-red.png')
pipeSprites.push(pipeDown)
}
function setup() {
createCanvas(288, 512)
ground = height - 112;
bird = new Bird(birdSprites)
}
function draw() {
background(0)
scene.drawScene();
createPipes();
renderPipes();
bird.show();
bird.update();
checkHits()
scene.drawBase();
}