-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
43 lines (30 loc) · 1004 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
var sea,ship;
var seaImg,shipImg;
function preload(){
seaImg = loadImage("sea.png");
shipImg1=loadAnimation("sea.png")
//Choose the correct option by uncommenting the right line to load the animation for ship.
shipImg1 = loadAnimation("ship-1.png","ship-1.png","ship-2.png","ship-1.png");
//shipImg1 = loadAnimation("ship-1","ship-1","ship-2","ship-1");
//shipImg1 = loadAnimation("1.png","2.png","3.png","4.png");
}
function setup(){
createCanvas(400,400);
background("blue");
// Moving background
sea=createSprite(400,200);
sea.addImage(seaImg);
sea.scale=0.3;
ship = createSprite(130,200,30,30);
ship.addAnimation("movingShip",shipImg1);
ship.scale =0.25;
}
function draw() {
background(0);
//Uncomment the correct line to make the background move to create a forward moving effect for the boat.
//sea.velocityY = -3;
//sea.x = -3;
sea.velocityX = -3;
//sea.velocityX = 3;
drawSprites();
}