-
Notifications
You must be signed in to change notification settings - Fork 0
/
gameUI.js
80 lines (69 loc) · 1.87 KB
/
gameUI.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
// const canvas = document.querySelector('canvas');
// const mapWidth = 300;
// const mapHeight = 500;
// let fps = 60;
//
// console.log("initializationData.canvas",canvas);
// this.game = new PinballGame({
// canvas: canvas,
// mapWidth: mapWidth,
// mapHeight: mapHeight,
// fps: fps
// });
//
//
// // module aliases
//
//
// let canvas = document.querySelector('canvas');
let wall = {
offset: -27,
gauge: 50,
};
let setupSettings = {
ballsize: 10,
ballAmount: 1,
ballVelocity: {
x: 0,
y: 6,
},
shipWidth: 140,
shipHeight: 20,
};
let sizeX = 10;
let sizeY = 6;
let exist = 0;
let brickPattern = new Array(sizeX).fill().map(() => new Array(sizeY).fill(0)); // empty map
console.log("brickPattern", brickPattern);
for (let j = 0; j < brickPattern[0].length; j++) {
// let randomColor = "#" + getRandomInt(31,90).toString() + getRandomInt(20,50).toString() + getRandomInt(70,70).toString();
let randomColor = "rgb("+getRandomInt((j+1)*100)+","+getRandomInt(40)+","+getRandomInt(10)+")";
for (let i = 0; i < brickPattern.length; i++) {
brickPattern[i][j] = {};
brickPattern[i][j].color = randomColor;
brickPattern[i][j].point = (brickPattern[0].length - j + 1) * 10;
brickPattern[i][j].health = j + 1;
if ((j + i) % 2 === 0 ) {
// console.log("igen");
console.log("brickPattern["+i+"["+j+"].health", brickPattern[i][j].health);
brickPattern[i][j].exist = 1;
} else {
// console.log("nem");
brickPattern[i][j].health = 1;
brickPattern[i][j].exist = 1;
}
}
}
console.log("brickPattern", brickPattern);
var game = new PinballGame( {
setupSettings: setupSettings,
mapHeight: 600,
mapWidth: 900,
brickPattern: brickPattern,
wall: wall,
} );
function getRandomInt (max) {
return Math.floor (Math.random() * Math.floor (max));
}
function getRandomColor (red, green, blue) {
}