-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
51 lines (34 loc) · 956 Bytes
/
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
50
51
var barco, barco_running;
var sea, invisibleSea, seaImage;
function preload(){
seaImage = loadImage("sea.png");
barco_running = loadAnimation("ship-1.png","ship-2.png","ship-3.png","ship-4.png");
}
function setup(){
createCanvas(1400,755);
barco = createSprite(700,400,20,50);
barco.addAnimation("running", barco_running);
barco.scale = 0.5;
sea = createSprite(200,180,400,20);
sea.addImage("sea",seaImage);
sea.x = sea.width /2;
sea.velocityX = -4;
invisibleSea = createSprite(1400,750,1400,10);
invisibleSea.visible = false;
var rand = Math.round(random(1,100))
console.log(rand)
}
function draw() {
console.log (barco.y)
if(keyDown("space")&& barco.y >= 150) {
barco.velocityY = -10;
}
barco.velocityY = barco.velocityY + 0.8
if (sea.x < 0) {
sea.x = sea.width/2;
}
barco.collide(invisibleSea);
sea.depth = sea.depth;
barco.depth = barco.depth + 1;
drawSprites();
}