From 2a0fe221c45e9bef9e6434a24ed053f7552a999a Mon Sep 17 00:00:00 2001 From: snonk <58750937+snonk@users.noreply.github.com> Date: Tue, 27 Feb 2024 20:22:30 -0500 Subject: [PATCH 1/3] added tilemap starter comments --- src/app.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app.js b/src/app.js index c2d5a1a..f000aec 100644 --- a/src/app.js +++ b/src/app.js @@ -10,6 +10,8 @@ class GameScene extends Phaser.Scene { frameHeight: 20, }); + // TODO 1: load the tileset and tilemap with keys of "tileset" and "map" respectively. + this.load.image("wallHorizontal", "assets/wallHorizontal.png"); this.load.image("wallVertical", "assets/wallVertical.png"); @@ -87,6 +89,7 @@ class GameScene extends Phaser.Scene { * Creates the walls of the game */ createWalls() { + // TODO 2.1: comment out manual wall creation this.walls = this.physics.add.staticGroup(); this.walls.create(10, 170, "wallVertical"); // Left @@ -101,6 +104,16 @@ class GameScene extends Phaser.Scene { this.walls.create(500, 170, "wallHorizontal"); // Middle right this.walls.create(250, 90, "wallHorizontal"); // Middle top this.walls.create(250, 250, "wallHorizontal"); // Middle bottom + + // TODO 2.2: create a tilemap called map with this.add.tilemap() + // the first parameter is the name of the tilemap in preload() + + // TODO 2.3: add the tileset to the tilemap with map.addTilesetImage(tilesetName, key) + // the first parameter is the name of the tileset in Tiled + // the second parameter is the name of the tileset in preload() + + // TODO 2.4: Enable collisions for the first tile (the blue walls) with the setCollision() method + } /** From ac85e860c298b6faaf29fab6680fe5a147399a0e Mon Sep 17 00:00:00 2001 From: Nathan Wang Date: Tue, 27 Feb 2024 20:56:51 -0500 Subject: [PATCH 2/3] Minor fixes --- src/app.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/app.js b/src/app.js index c2d5a1a..ccec802 100644 --- a/src/app.js +++ b/src/app.js @@ -53,7 +53,8 @@ class GameScene extends Phaser.Scene { // Make the player collide with walls this.physics.add.collider(this.player, this.walls); - this.coin = this.physics.add.sprite(60, 130, "coin"); + this.coin = this.physics.add.sprite(0, 0, "coin"); + this.moveCoin(); // Display the score this.scoreLabel = this.add.text(30, 25, "score: 0", { @@ -211,10 +212,10 @@ class GameScene extends Phaser.Scene { // bounce back in the opposite direction without losing speed enemy.body.bounce.x = 1; - // destroy the enemy after 10 seconds + // destroy the enemy after 15 seconds // this is roughly how long it takes to fall through the hole this.time.addEvent({ - delay: 10000, + delay: 15000, callback: () => enemy.destroy(), }); } From 0eb99cd1b92ffd5effd83bc5ae8bf8d9df332e08 Mon Sep 17 00:00:00 2001 From: snonk <58750937+snonk@users.noreply.github.com> Date: Sat, 2 Mar 2024 00:49:52 -0500 Subject: [PATCH 3/3] add comments --- src/app.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/app.js b/src/app.js index f000aec..cb40642 100644 --- a/src/app.js +++ b/src/app.js @@ -83,6 +83,8 @@ class GameScene extends Phaser.Scene { this.jumpSound = this.sound.add("jump"); this.coinSound = this.sound.add("coin"); this.deadSound = this.sound.add("dead"); + + // TODO 4.2: Add emitter for particle system. } /** @@ -92,6 +94,8 @@ class GameScene extends Phaser.Scene { // TODO 2.1: comment out manual wall creation this.walls = this.physics.add.staticGroup(); + // TODO 4.1: import pixel as "pixel" from "assets/pixel.png" + this.walls.create(10, 170, "wallVertical"); // Left this.walls.create(490, 170, "wallVertical"); // Right @@ -123,6 +127,9 @@ class GameScene extends Phaser.Scene { * check for win conditions, etc. */ update() { + + // TODO 5.1: + this.movePlayer(); this.checkCoinCollisions(); @@ -236,12 +243,17 @@ class GameScene extends Phaser.Scene { * Called when the player dies. Restart the game */ handlePlayerDeath() { + // TODO 5.1: EXPLODE!! this.scene.restart(); this.deadSound.play(); + + // TODO 5.2: Instead of immediately restarting the game, add a delay + // Hint: see addEnemy() + } } - +// TODO 3.1: Update the map config so that the width is 800 and the height is 560 const config = { type: Phaser.AUTO, width: 500,