coverted database interactions and menu to classes
This commit is contained in:
26
web/game.js
26
web/game.js
@@ -1,7 +1,11 @@
|
||||
function preload() {
|
||||
controlsImage = loadImage('./contols.png');
|
||||
}
|
||||
|
||||
// the function setup() is called once when the page is loaded
|
||||
function setup() {
|
||||
// create a canvas element and append it to the body
|
||||
getData()
|
||||
DB.getData()
|
||||
createCanvas(width, height);
|
||||
frameRate(framerate);
|
||||
angleMode(DEGREES);
|
||||
@@ -25,13 +29,16 @@ function reset() {
|
||||
isDead = false;
|
||||
entered = false;
|
||||
buttonSelect = 0;
|
||||
|
||||
nameHS = '';
|
||||
submitted = false;
|
||||
escaped = false;
|
||||
bossPosX = width / 2;
|
||||
bossPosY = height / 6;
|
||||
bossVelX = 5;
|
||||
bossVelY = 5;
|
||||
dataIsCalled = false;
|
||||
DB.getData();
|
||||
|
||||
}
|
||||
|
||||
function movementCheck() {
|
||||
@@ -79,7 +86,7 @@ async function keyPressed() {
|
||||
homescreenOn = true;
|
||||
reset();
|
||||
keyReleasedFlag = false;
|
||||
getData()
|
||||
DB.getData()
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -169,10 +176,11 @@ async function keyPressed() {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
function submit() {
|
||||
if (entered == true) {
|
||||
sendData(nameHS, int(time));
|
||||
DB.sendData(nameHS, int(time));
|
||||
console.log(nameHS + ": " + int(time));
|
||||
nameHS = '';
|
||||
submitted = true;
|
||||
@@ -255,7 +263,7 @@ function nameDraw(positiony) {
|
||||
// the function draw() is called every frame
|
||||
function draw() {
|
||||
keyPressed();
|
||||
gameOver();
|
||||
Menus.gameOver();
|
||||
// draw background
|
||||
background(0, 0, 0, 100);
|
||||
ffps = frameRate();
|
||||
@@ -263,7 +271,7 @@ function draw() {
|
||||
playerSpeed = 300 / ffps;
|
||||
|
||||
if (homescreenOn) {
|
||||
homescreen();
|
||||
Menus.homescreen();
|
||||
buttonSelect = constrain(buttonSelect, 0, 1);
|
||||
if (buttonSelect == 0) {
|
||||
push()
|
||||
@@ -286,7 +294,7 @@ function draw() {
|
||||
game();
|
||||
}
|
||||
if (scorescreenOn) {
|
||||
scoremenu();
|
||||
Menus.scoreMenu();
|
||||
buttonSelect = constrain(buttonSelect, 0, 1);
|
||||
if (buttonSelect == 1 && entered) {
|
||||
push()
|
||||
@@ -298,7 +306,7 @@ function draw() {
|
||||
}
|
||||
}
|
||||
if (pausescreenOn) {
|
||||
pauseMenu();
|
||||
Menus.pauseMenu();
|
||||
buttonSelect = constrain(buttonSelect, 0, 1);
|
||||
if (buttonSelect == 0) {
|
||||
push()
|
||||
@@ -353,7 +361,7 @@ function draw() {
|
||||
}
|
||||
|
||||
if (!hasMoved && !isDead && !homescreenOn && !pausescreenOn && !scorescreenOn) {
|
||||
dodgeBanner();
|
||||
Menus.dodgeBanner();
|
||||
}
|
||||
}
|
||||
async function randPatern() {
|
||||
|
Reference in New Issue
Block a user