-
Notifications
You must be signed in to change notification settings - Fork 0
/
sketch.js
54 lines (44 loc) · 1.17 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
const Engine = Matter.Engine;
const World = Matter.World;
const Bodies = Matter.Bodies;
const Constraint = Matter.Constraint;
var engine, world;
var box1, box2, box3,box4;
var hero,monster,rope,ground;
function preload() {
bg = loadImage("gamingbackground2.png");
}
function setup() {
createCanvas(3000, 700);
engine = Engine.create();
world = engine.world;
ground = new Ground(600, 600, 1200, 20);
hero = new Hero(400,800,250);
rope = new Rope(hero.body, { x: 500, y: 50 });
monster = new Monster(1100,550,300);
box1 = new Box(600, 100, 70, 70);
box2 = new Box(900, 100, 70, 70);
box3 = new Box(800, 100, 70, 70);
box4 = new Box(1000, 100, 70, 70);
box5 = new Box(1200, 100, 70, 70);
box6 = new Box(1300, 100, 70, 70);
box7 = new Box(400, 100, 70, 70);
box8 = new Box(600, 150, 70, 70);
box9 = new Box(1300, 120, 70, 70);
box10 = new Box(890, 110, 70, 70);
}
function draw() {
background(bg);
Engine.update(engine);
ground.display();
box1.display();
box2.display();
box3.display();
box4.display()
hero.display();
rope.display();
monster.display();
}
function mouseDragged(){
Matter.Body.setPosition(hero.body,{x:mouseX,y:mouseY});
}