Skip to content
Snippets Groups Projects
Commit 8214d8dd authored by ah3472's avatar ah3472
Browse files

score code update

parent 377ae54e
Branches
No related tags found
No related merge requests found
......@@ -51,12 +51,7 @@ let bounds;
let playerCollided;
let score = 0;
let something = "Score:" + score;
let txt = new PIXI.Text(something,{fontFamily: "Arial",fontSize: 15, fill: "#FFFFFF"});
txt.x = app.view.width / 10;
txt.y = app.view.height / 4;
txt.anchor.set = 0.5;
app.stage.addChild(txt);
let scoreTxt;
let nextX;
let nextY;
......@@ -84,15 +79,27 @@ function startUpGame() {
g1 = new gun(p1.x - 40, p1.y - 5, p1.weapon, 10, 50, 10);
g1.create_gun(app, animatedObjects);
healthBar();
bounds = map.currentRoom.getColliders(app);
randomlySpawnMobs(map.currentRoom.numOfEnemies);
loadSprites();
healthBar();
createScoreBoard();
app.ticker.add(map_loop);
}
function createScoreBoard() {
let something = "Score: " + score;
scoreTxt = new PIXI.Text(something,{fontFamily: "Arial",fontSize: 25, fill: "#FFFFFF"});
scoreTxt.anchor.set(0.5);
scoreTxt.x = app.view.width / 2;
scoreTxt.y = 30; //app.view.height / 4;
scoreTxt.anchor.set = 0.5;
app.stage.addChild(scoreTxt);
}
function checkDoorCollision() {
if (nextX - 23 < roomDoors.minX) {
p1.x = app.view.width/2 + 64 * 9.5
......@@ -125,6 +132,7 @@ function ChangeRooms(nextRoom) {
app.ticker.stop()
map.currentRoom = nextRoom
map.currentRoom.drawRoom(app)
createScoreBoard()
bounds = map.currentRoom.getColliders(app)
if (map.currentRoom.firstTimeInRoom) {
randomlySpawnMobs(map.currentRoom.numOfEnemies)
......@@ -439,7 +447,7 @@ function bulletCollider(delta){
map.currentRoom.numOfEnemies--;
map.currentRoom.enemies.splice(j, 1);
score += 100;
txt.text ="Score:" + score;
scoreTxt.text ="Score: " + score;
}
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment