Added the bricks (and improve the bouncing)
This commit is contained in:
23
index.js
23
index.js
@ -7,20 +7,29 @@ document.addEventListener('DOMContentLoaded', init);
|
||||
|
||||
function init() {
|
||||
let ctx, canvas = document.createElement("canvas");
|
||||
canvas.width = window.innerWidth
|
||||
canvas.height = window.innerHeight
|
||||
canvas.width = 360; // window.innerWidth
|
||||
canvas.height = 640; // window.innerHeight
|
||||
ctx = canvas.getContext('2d');
|
||||
document.body.insertBefore(canvas, document.body.childNodes[0]);
|
||||
let container = document.querySelector("body");
|
||||
let resize = (e) => {
|
||||
container.clientWidth / container.clientHeight > 1
|
||||
? (canvas.style.height = "100vh") && (canvas.style.width = "auto")
|
||||
: (canvas.style.height = "auto") && (canvas.style.width = "100vw");
|
||||
};
|
||||
resize();
|
||||
container.onresize = resize;
|
||||
|
||||
let key = new Key(), board;
|
||||
|
||||
let key = new Keyboard(), board;
|
||||
function runBoard(stage) {
|
||||
switch(stage) {
|
||||
case 1: board = new GamePlay(ctx, key); break;
|
||||
default: board = new GameIntro(ctx,key); break;
|
||||
switch (stage) {
|
||||
case 1: board = new GamePlay(ctx, key); break;
|
||||
default: board = new GameIntro(ctx, key); break;
|
||||
}
|
||||
board
|
||||
.run()
|
||||
.then( stage=>runBoard(stage), e=>{} );;
|
||||
.then(stage => runBoard(stage), e => { });;
|
||||
}
|
||||
runBoard(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user