-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcreate1.js
105 lines (89 loc) · 3.14 KB
/
create1.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
var guards = []
function create1() {
guards = []
document.getElementById("nextLevel").addEventListener("click", (event) => {
switchLevel("3");
});
document.getElementById("respawn").addEventListener("click", (event) => {
gameOver = false;
this.scene.restart();
});
document.getElementById("nextLevel").disabled = true;
document.getElementById('level-select').value = '2';
// document.getElementById("nextLevel").addEventListener("click", (event) => {
// //something to load level 2
// this.scene.start("level2");
// });
arr1 = getLevel(1);
generateCheckerboard(this, 8); // Generate background
setup(this);
// GENERATE WALLS ---------------------------------------------------------------------
// Create the horizontal walls and the vertical walls
wall = this.physics.add.staticGroup();
guardIndex = 0;
for(i=0; i<arr1.length; i++){
for(j=0;j<arr1[i].length;j++){
if(arr1[i][j]==9){
wallkind = Math.floor(Math.random() * (10 - 1 + 1) + 1);
if (wallkind == 1 || wallkind == 4 || wallkind == 7){
wall.create(j*40+20, i*40+20, "wallS");
}
else if (wallkind == 2 || wallkind == 5 || wallkind == 8){
wall.create(j*40+20, i*40+20, "wallSR");
}
else if (wallkind == 3 || wallkind == 6 || wallkind == 9){
wall.create(j*40+20, i*40+20, "wallDS");
}
else if (wallkind == 10){
wallkind = Math.floor(Math.random() * (5 - 1 + 1) + 1);
if (wallkind == 1){
wall.create(j*40+20, i*40+20, "painting1");
}
else if (wallkind == 2){
wall.create(j*40+20, i*40+20, "painting2");
}
else if (wallkind == 3){
wall.create(j*40+20, i*40+20, "painting3");
}
else if (wallkind == 4){
wall.create(j*40+20, i*40+20, "painting4");
}
else if (wallkind == 5){
wall.create(j*40+20, i*40+20, "wall_light");
}
}
//wall.create(j*40+20,i*40+20, "wall");
}
else if (arr1[i][j] == 1){
wall.create(j*40+20, i*40+20, "void");
}
//adding gem to that position
else if(arr1[i][j]==4){
jewel = this.physics.add.sprite(j*40+20,i*40+20, "jewel").setScale(0.125);
}
}
}
for(i=0; i<arr1.length; i++){
for(j=0;j<arr1[i].length;j++){
//adding ROBBER to that position
if(arr1[i][j]==2){
player = this.physics.add.sprite(j*40+20,i*40+8, "dude").setScale(playerScale);
playerRow = i;
playerCol = j;
player_start_current_level = [j*40+20,i*40+8];
}
}
}
player.setDepth(2);
jewel.setDepth(1);
for (i = 0; i < guards.length; i++){
guards[i].setDepth(3);
}
const LEVEL_TWO_BOTTOM = 2 * CENTER_VERTICAL - 100;
// Input Events
cursors = this.input.keyboard.createCursorKeys();
// Checks to see if the player overlaps with any of the stars, if he does call the collectStar function
// this.physics.add.overlap(player, jewel, collectJewel, null, this);
//this.hitGuard = hitGuard.bind(this);
// Collision event
}