-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
39 lines (31 loc) · 831 Bytes
/
main.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
// Create Player
var player1 = new Player(x=10, y=10, width=10, height=10, color="blue")
var players = [player1]
var worldObjects = [
new Tree(x=50, y=50),
new Tree(x=200, y=50),
new Tree(x=350, y=50),
new Tree(x=500, y=50),
new Tree(x=50, y=200),
new Tree(x=200, y=200),
new Tree(x=350, y=200),
new Tree(x=500, y=200),
new Tree(x=50, y=350),
new Tree(x=200, y=350),
new Tree(x=350, y=350),
new Tree(x=500, y=350),
]
var renderList = [];
renderList = renderList.concat(worldObjects)
renderList = renderList.concat(players)
var render = function () {
clearCanvas(canvas);
setBackground(canvas);
renderList.forEach(function (item) {
addElementToCanvas(item, canvas)
})
}
var mainInterval = setInterval(function(){
render();
movePlayer();
}, 10)