-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsketch.js
60 lines (47 loc) · 1.04 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
50
51
52
53
54
55
56
57
58
59
60
var wall1;
var person;
var backgroundImg;
var backgroundS
function preload(){
backgroundImg = loadImage("background.jpg");
}
function setup(){
createCanvas(600,600);
backgroundS = createSprite(600,600);
backgroundS.addImage("backgroundG",backgroundImg);
// backgroundS.scale = 1.0;
backgroundS.velocityX = -3;
//fill("red");
wall1 = createSprite(200,200,10,400);
wall1.shapeColor = "red";
wall1.velocityY = -5;
// fill("blue");
person = createSprite(500,200,10,10);
person.shapeColor = "blue"
}
function draw(){
background("blue");
drawSprites();
if(keyDown(UP_ARROW))
{
person.y -= 5;
}
if (keyDown(DOWN_ARROW)){
person.y += 5;
}
if (keyDown(RIGHT_ARROW)){
person.x += 5;
}
if(keyDown(LEFT_ARROW)){
person.x -= 5;
}
if (backgroundS.x < 0){
background.x = width/2;
}
console.log(backgroundS.x);
person.bounceOff(wall1);
edges = createEdgeSprites();
wall1.bounceOff(edges);
}
function spawnwall(){
}