Observed: No Game instance and no Play Scene.
Expected: A Game instance and a Play Scene.
Related to #9
Initialize the game and create a barebones Play scene.
src/main.ts
to import PlayScene
and create a new Phaser.Game
instance with a configuration object.PlayScene
to the Phaser.Game
instance.src/scenes/PlayScene.ts
to define the PlayScene
class, extending Phaser.Scene
.constructor
, preload
, create
, and update
methods in PlayScene
.PlayScene
as the default export.For more details, open the Copilot Workspace session.
Observed: No method to generate textures
Expected: A utility class to generate a solid color texture with the specified dimensions and name. The method will be used to generate textures for use in Sprites and TilemapImages.
Related to #11
Add a utility class to generate solid color textures.
src/utils/TextureGenerator.ts
with TextureGenerator
class.
generateTexture
method to create a solid color texture with specified dimensions and name.Phaser.GameObjects.Graphics
to draw the texture and add it to the game's texture manager.src/scenes/PlayScene.ts
to use TextureGenerator
.
TextureGenerator
in PlayScene
.create
method to call TextureGenerator.generateTexture
and use the generated texture.For more details, open the Copilot Workspace session.
Observed: No tilemap
Expected: A class that encapsulates a configurable tilemap. The class uses the generateTexture utility method to generate two different color textures for use as tilesetImages in the tilemap layer. One of the tilesetImages represents empty space and the other tilesetImage represents filled space. The filled spaces will be used for collision detection.
Related to #13
Add a TilemapManager
class to manage the tilemap and update PlayScene
to use it.
TilemapManager Class
src/utils/TilemapManager.ts
.TilemapManager
class to encapsulate a configurable tilemap.TextureGenerator.generateTexture
to create textures for empty and filled spaces.TilemapManager
class.setTile
to set tiles in the tilemap.PlayScene Update
TilemapManager
class in src/scenes/PlayScene.ts
.TilemapManager
in the create
method.setTile
method in the create
method.For more details, open the Copilot Workspace session.
Observation: The private properties of TilemapManager are not definitively assigned in the constructor and this leads to a typescript warning.
Expected: Encapsulate the private properties of TilemapManager into an object that is a property on TilemapManager.
Related to #15
Refactor the TilemapManager to encapsulate private properties into an object.
tilemapData
to encapsulate scene
, tilemap
, emptyTileset
, filledTileset
, and layer
.tilemapData
with the scene
and call createTilemap
.createTilemap
to accept scene
as a parameter and return a new tilemapData
object.tilemapData
for null after they are created and throw an error if any found.setupCollision
to use tilemapData
for accessing layer
and filledTileset
.setTile
to use tilemapData
for accessing tilemap
, filledTileset
, emptyTileset
, and layer
.For more details, open the Copilot Workspace session.
Observed: There is no map generator
Expected: A procedural map generator that returns an array of booleans representing filled and unfilled spaces. The output of the generator is used to populate the MapManager tilemap.
Related to #17
Implement a procedural map generator using a cellular automata algorithm and integrate it with the existing tilemap management system.
Map Generator: Add MapGenerator
class in src/utils/MapGenerator.ts
with a static method generateMap
that generates a 2D array of booleans using a cellular automata algorithm.
Tilemap Manager: Update TilemapManager
class in src/utils/TilemapManager.ts
to use the MapGenerator
for populating the tilemap.
MapGenerator
class.populateTilemap
that takes a 2D array of booleans and sets the tiles accordingly.MapGenerator
to generate the map and call populateTilemap
in the constructor.Play Scene: Update PlayScene
class in src/scenes/PlayScene.ts
to use the MapGenerator
and TilemapManager
.
MapGenerator
class.MapGenerator
and pass it to TilemapManager
.populateTilemap
method of TilemapManager
with the generated map in the create
method.For more details, open the Copilot Workspace session.
Observed: TilemapManager does not have a TilemapData type
Expected: Define a TilemapData type to match the tilemapData parameter.
Related to #21
Refactor TilemapManager to be stateless and accept a TilemapData object as a parameter.
For more details, open the Copilot Workspace session.
Observed: No method to find a non-filled tile
Expected: A method on the TileManager class to find a random non-filled tile
Related to #23
Add a method to find a random non-filled tile in the TilemapManager class.
findRandomNonFilledTile
method to TilemapManager
class in src/utils/TilemapManager.ts
.x
and y
properties.For more details, open the Copilot Workspace session.
Observed: No physics enabled
Expected: The Phaser Game should have Arcade Physics enabled.
Implement a class that reads keyboard state on a per-frame basis and updates in inputs object. The inputs object has booleans to indicate up, down, left, right, down. The inputs are updated according to key states.
Related to #36
Implement an InputManager
class to handle keyboard input and update the game state accordingly.
InputManager Class:
src/utils/InputManager.ts
file.InputManager
class to read keyboard state using Phaser.inputs
object with booleans for up, down, left, right.inputs
object based on key states.PlayScene Modifications:
InputManager
class in src/scenes/PlayScene.ts
.InputManager
in the create
method.inputs
object in the update
method based on keyboard state.For more details, open the Copilot Workspace session.
The game needs a player. The player navigates the map using the cursor keys. The player is unable to pass through filled tiles. The player falls if not standing on a tile. The player's image is generated by generateTexture. The player's implementation should use a state machine. The following states are allowed: IDLE, RUNNING, JUMPING, FALLING, GLIDING.
Related to #38
Add Player class and implement state machine for player movement and state transitions.
Player
class in src/objects/Player.ts
to handle player movement, state transitions, and image generation using generateTexture
. Implement a state machine with states IDLE, RUNNING, JUMPING, FALLING, and GLIDING. Define empty onEnter
, onExit
, and onExecute
methods for each state. Use currentState
and nextState
properties to manage state transitions. Add width/height parameters to the Player constructor.src/scenes/PlayScene.ts
to import the Player
class, create an instance of the Player
class in the create
method, add the player to the physics world, and update the player in the update
method based on inputs.src/utils/InputManager.ts
to include a method for checking if the player is jumping.For more details, open the Copilot Workspace session.
Observed: The player hangs in mid air.
Expected: The player should be pulled down by gravity.
Related to #42
Add gravity to the player in the game.
Phaser.Game
configuration under the physics
property.For more details, open the Copilot Workspace session.
Related to #47
Add optional border parameter to generateTexture method in TextureGenerator.ts
border
interface with color
and thickness
properties.generateTexture
method to accept an optional border
parameter.border
parameter is provided.Update calls to generateTexture method to include optional border parameter
Player.ts
to include a red border with thickness 2.TilemapManager.ts
to include a black border with thickness 1.For more details, open the Copilot Workspace session.
Related to #49
Add collision handling for the player with filled tiles.
Player Class (src/objects/Player.ts
):
handleCollision
method to manage collision events.PlayScene Class (src/scenes/PlayScene.ts
):
create
method.update
method.For more details, open the Copilot Workspace session.
Related to #54
Add a text object to display the player's current state above the player sprite.
Phaser.GameObjects.Text
object to Player
class to display the player's current state.updateState
method.getStateText
method to return the current state's text representation.For more details, open the Copilot Workspace session.
Related to #59
Define a new type Inputs
for the inputs
object in src/utils/InputManager.ts
.
InputManager.ts
Inputs
with properties up
, down
, left
, and right
, all of which are boolean.inputs
object to be of type Inputs
.getInputs
method to Inputs
.Player.ts
Inputs
type from src/utils/InputManager.ts
.updateState
method to accept an inputs
object of type Inputs
.For more details, open the Copilot Workspace session.
Related to #61
Type the stateMachine
in the Player
class.
State
interface to type the stateMachine
object.stateMachine
object to use the State
interface.stateMachine
object uses the PlayerState
enum to define its keys.For more details, open the Copilot Workspace session.
Related to #63
Pass the Inputs
object as a parameter to the state machine's onEnter
, onExecute
, and onExit
methods in the Player
class.
State
interface to include inputs: Inputs
as a parameter in the onEnter
, onExecute
, and onExit
methods.stateMachine
object to include inputs: Inputs
as a parameter in the onEnter
, onExecute
, and onExit
methods for each state (IDLE
, RUNNING
, JUMPING
, FALLING
, GLIDING
).updateState
method to pass the inputs
object to the onEnter
, onExecute
, and onExit
methods.For more details, open the Copilot Workspace session.
The following conditions are necessary for the state transitions to occur:
Related to #65
Implement logic for transitioning from player state IDLE to JUMPING.
isBlockedFromBelow
method to check if the player is blocked from below using body.blocked.down
.onEnter
method for the PlayerState.JUMPING
state to add a vertical impulse to the player.onExecute
method for the PlayerState.IDLE
state to check for the up input and the collision condition to transition to the JUMPING state.For more details, open the Copilot Workspace session.
When the player jumps the initial state is JUMPING and the player is moving upwards. When the player start's moving downward, the state should transition to FALLING.
Related to #67
Update the onExecute
method for the JUMPING
state to transition to FALLING
when the player starts moving downward.
onExecute
method for the JUMPING
state.FALLING
if the player's vertical velocity is greater than zero.For more details, open the Copilot Workspace session.
If the player is FALLING and blocked from below, transition to IDLE. In the IDLE state the player has no vertical velocity.
Related to #69
Add logic for transitioning from FALLING to IDLE when blocked from below.
PlayerState.IDLE
state's onEnter
method to set the player's vertical velocity to zero.PlayerState.FALLING
state's onExecute
method to transition to IDLE
if the player is blocked from below.For more details, open the Copilot Workspace session.
If the player is in IDLE state and the inputs for left or right are true, then transition to the RUNNING state. In the RUNNING state the player's horizontal velocity is set according to the left or right input. If left, move left. If right, move right. If both left and right, do not move. If neither left or right is down, transition to IDLE.
Related to #71
Add logic for state transition from IDLE to RUNNING state in Player.ts
.
onExecute
method in PlayerState.IDLE
to check for left or right inputs and transition to PlayerState.RUNNING
.onEnter
method in PlayerState.RUNNING
to set initial horizontal velocity based on left or right inputs.onExecute
method in PlayerState.RUNNING
to set horizontal velocity based on left or right inputs.onExecute
method in PlayerState.RUNNING
to transition to PlayerState.IDLE
if neither left nor right inputs are true.For more details, open the Copilot Workspace session.
If the player is IDLE and not blocked from below, transition to state FALLING
If the player is FALLING and the left or right inputs are true, transition to GLIDING. In the GLIDING state, if the left or right inputs are true then add a left or right impulse. If neither left or right input is true then transition to FALLING. If the player is FALLING and blocked from below then transition to IDLE.
Related to #75
Add logic for transition from FALLING to GLIDING state.
onExecute
method in FALLING
state to check for left or right inputs and transition to GLIDING
state.onExecute
method in GLIDING
state to handle left and right inputs to add a left or right impulse.onExecute
method in GLIDING
state to transition to FALLING
state if neither left nor right input is true.onExecute
method in GLIDING
state to transition to FALLING
state if both left and right inputs are true.For more details, open the Copilot Workspace session.
If the player is in the GLIDING state and blocked from below, transition to the RUNNING state.
Related to #78
Add logic for transition from GLIDING to RUNNING state when blocked from below.
onExecute
method for the GLIDING state in src/objects/Player.ts
to check if the player is blocked from below.For more details, open the Copilot Workspace session.
If the player is RUNNING and the player is not blocked from below, transition the player to GLIDING.
Related to #77
NetworkError when attempting to fetch resource.
For more details, open the Copilot Workspace session.
If both left and right inputs are true, do not add horizontal impulse.
Related to #81
Add horizontal impulse to the player in JUMPING state based on left or right inputs.
onEnter
method for the JUMPING
state to set horizontal velocity based on left or right inputs.onExecute
method for the JUMPING
state to adjust horizontal velocity based on left or right inputs.For more details, open the Copilot Workspace session.
If the player is JUMPING and the left or right input is true, add a left or right impulse. If both left and right are true, remove the horizontal impulse. If neither input is true, remove the horizontal impulse.
Related to #83
Update the onEnter
method for the JUMPING state to add horizontal impulse based on left and right inputs.
onEnter
method to adjust the horizontal velocity by adding or subtracting 10 based on left and right inputs.For more details, open the Copilot Workspace session.
If the player is RUNNING and the up input is true, transition to the JUMPING state.
Related to #85
Add logic for player transition from RUNNING to JUMPING
onExecute
method for the RUNNING state to check for the up input.For more details, open the Copilot Workspace session.
Currently velocity is set using a literal value, for example: setVelocity(150)
. Use a constant in a central location instead, for example: setVelocity(-RUNNING_VELOCITY)
. Do this for gliding, running, and gliding velocities.
Related to #87
Define velocity constants as static properties within the Player
class and replace literal values with these constants.
RUNNING_VELOCITY
, GLIDING_VELOCITY
, and JUMPING_VELOCITY
to the Player
class.Player
class.For more details, open the Copilot Workspace session.
Related to #97
Refactor to combine the properties of TilemapData
into TilemapManager
and eliminate the TilemapData
class.
TilemapData
type definition from src/utils/TilemapManager.ts
.scene
, tilemap
, emptyTileset
, filledTileset
, and layer
to TilemapManager
class.createTilemap
method to initialize class properties instead of returning TilemapData
.setTile
, populateTilemap
, and findRandomNonFilledTile
to use class properties directly.create
method in src/scenes/PlayScene.ts
to use TilemapManager
properties directly instead of TilemapData
.handlePlayerCollision
method in src/scenes/PlayScene.ts
to use TilemapManager
properties directly instead of TilemapData
.For more details, open the Copilot Workspace session.
Related to #89
Implement a GRAPPLING state for the player.
InputManager
class and update the Inputs
type to include the grappling input.findFirstFilledTileAbove
to the TilemapManager
class to return the first filled tile above a given position.PlayerState
enum and the stateMachine
object in the Player
class.Player
class for setting the currently active map.For more details, open the Copilot Workspace session.
Related to #89
Implement a GRAPPLING state for the player.
TilemapManager.ts
getFirstFilledTileAbove
to determine the first filled tile above a given (x,y) coordinate, taking a TilemapData
parameter.Player.ts
setCurrentMap
to set the current map the player is in.computeGrapplingHookAnchor
to compute the grappling hook anchor tile.InputManager.ts
Inputs
object.update
method to handle the grappling input.PlayScene.ts
setCurrentMap
method.update
method.For more details, open the Copilot Workspace session.
Related to #89
Implement a GRAPPLING state for the player.
findFirstFilledTileAbove
to TilemapManager
to determine the first filled tile above a given (x,y) coordinate.GRAPPLING
state to the PlayerState
enum and the state machine in Player.ts
.
Player.ts
to set the current map and compute the grappling hook anchor tile.Inputs
type and the InputManager
class (left shift key).For more details, open the Copilot Workspace session.
Related to #89
Implement a GRAPPLING state for the player.
getFirstFilledTileAbove
in TilemapManager
to determine the first filled tile above a given (x, y) coordinate.Inputs
type and InputManager
class to handle grappling input (left shift key).Player
class.PlayerState
enum and state machine in the Player
class.
Player
class.PlayScene
.For more details, open the Copilot Workspace session.
Related to #102
Add a method to the MapGenerator that adds a border of filled tiles around the generated map.
addBorder
method to MapGenerator
class in src/utils/MapGenerator.ts
to add a border of filled tiles around the provided mapData
.create
method in PlayScene
class in src/scenes/PlayScene.ts
to use the updated MapGenerator
to generate maps with a border of filled tiles.For more details, open the Copilot Workspace session.
* Remove the grapplingLine * Add tint to anchored tile * Use getTileWorldXY instead of manual computation
PlayCurrently the player gets stuck in the JUMPING state if blocked from below while in JUMPING state. If the player becomes blocked from below while JUMPING, transition to IDLE.
Related to #111
Update the JUMPING
state to transition to IDLE
if blocked from below.
onExecute
method for the JUMPING
state to see if the player is blocked from below.IDLE
state if the player is blocked from below while in the JUMPING
state.For more details, open the Copilot Workspace session.
If the player enters the GRAPPLING state, add a vertical line to the scene that connects the player's center to the bottom edge of the anchored tile. The line should shorten or lengthen as the player moves up or down. Remove the line when the GRAPPLING state exits.
Related to #113
Add a grappling line while in the GRAPPLING state.
grapplingLine
property to the Player
class to store the line object.onEnter
method of the GRAPPLING
state.onExecute
method of the GRAPPLING
state.onExit
method of the GRAPPLING
state.For more details, open the Copilot Workspace session.
When the grappling hook is deployed, a quick tween should scale the line from 0.5% to 100%, and the reverse when retracted.
Related to #115
Add tweening to the deployment and retraction of the grappling hook line.
Phaser.Tweens
in src/objects/Player.ts
.onEnter
method of the GRAPPLING
state, add a tween to scale the grappling line from 0.5% to 100%.onExit
method of the GRAPPLING
state, add a tween to scale the grappling line from 100% to 0.5% before destroying it.For more details, open the Copilot Workspace session.
Textures should be generated only once, then referred to by classes that use them. Because currently textures would be generated twice if two instances of MapManager were created. Ideally all the textures should be created in a single method, and each referenced by with a name assigned to a const and referenced that way.
Related to #117
Move texture generation out of the MapManager and Player classes into a separate module.
src/utils/TextureManager.ts
to handle texture generation and storage.src/objects/Player.ts
to use TextureManager
for player texture instead of generating it.src/utils/TilemapManager.ts
to use TextureManager
for empty and filled tile textures instead of generating them.TextureGenerator.generateTexture
in Player
and TilemapManager
classes.TextureManager
to be referenced by other classes.For more details, open the Copilot Workspace session.
Related to #122
Merge the TextureGenerator and TextureManager into a unified class.
TextureGenerator
from src/utils/TextureManager.ts
.generateTexture
method from TextureGenerator
to TextureManager
.generateTexture
call within TextureManager
to use the new method.src/utils/TextureGenerator.ts
file.For more details, open the Copilot Workspace session.
Related to #128
Add texture parameters to the Textures structure and update texture generation methods accordingly.
name
, height
, width
, count
, color
, margin
, spacing
to Textures
structure in src/utils/TextureManager.ts
.generateTextureIfNotExists
method to take a parameter from the Textures
structure.generateTexture
method to render a row of 'count' rectangles of specified dimensions and color using specified spacing and margin.addTilesetImage
in src/utils/TilemapManager.ts
to use parameters from the Textures
structure.For more details, open the Copilot Workspace session.
count
greater than 1, draw the first rectangle with no variation and subsequent rectangles with a very slight color/texture variation.count
for filled tiles to be 10.Related to #130
Introduce color variations for generated textures and update tilemap logic.
generateTexture
method in src/utils/TextureManager.ts
to introduce slight color variations for subsequent rectangles when count
is greater than 1.count
to 10 for FILLED_TILE
in Textures
object.populateTilemap
method in src/utils/TilemapManager.ts
to randomly pick a filled tile from the available set when placing a filled tile.TextureManager.Textures
texture that have a count > 1.setupCollision
method to account for tilesets that have more than 1 tile.For more details, open the Copilot Workspace session.
Related to #130
Unexpected error. Please try again in some time
For more details, open the Copilot Workspace session.
Related to #130
Add texture variation and update tile count for filled tiles.
src/utils/TextureManager.ts
to apply slight color/texture variation for textures with count
greater than 1.FILLED_TILE
texture count
to 10 in src/utils/TextureManager.ts
.createTilemap
in src/utils/TilemapManager.ts
to set the starting GID to account for previously created tilesetImages and number of tiles contained. Add a running count of the starting GID to avoid computing each time.populateTilemap
in src/utils/TilemapManager.ts
to randomly pick a tile from the appropriate tileset image.setupCollision
in src/utils/TilemapManager.ts
to use the full range of GIDs for collisions and anchor tile computations, using the tileset images 'total' property.For more details, open the Copilot Workspace session.
Related to #134
Add optional noise to generated textures.
noise
field to the Textures
structure in src/utils/TextureManager.ts
.generateTexture
method to add value noise to the filled rectangles if the noise
field is set to true.applyValueNoise
method to generate and apply value noise to the filled rectangles.For more details, open the Copilot Workspace session.
Each map should contain 10 pieces of loot scattered throughout the maze. The piece of loot should be removed when the player overlaps it.
Related to #136
Add loot to the map and handle collision with the player.
Textures
entry for LOOT colored green without noise in src/utils/TextureManager.ts
.src/utils/TilemapManager.ts
.src/scenes/PlayScene.ts
.src/objects/Player.ts
.For more details, open the Copilot Workspace session.
Related to #136
Add loot to the map and handle player collision with loot.
src/utils/TextureManager.ts
.src/utils/TilemapManager.ts
.src/utils/TilemapManager.ts
.src/objects/Player.ts
.src/scenes/PlayScene.ts
.For more details, open the Copilot Workspace session.
Related to #136
Add loot to the map and handle player overlap with loot items.
Textures
entry for LOOT colored green without noise in src/utils/TextureManager.ts
.src/scenes/PlayScene.ts
.src/scenes/PlayScene.ts
.src/scenes/PlayScene.ts
.src/scenes/PlayScene.ts
.For more details, open the Copilot Workspace session.
If the player presses the 'r' key, regenerate the map. Regeneration means remove all filled tiles and repopulate with a new map.
Related to #141
Add functionality to regenerate the map when the 'r' key is pressed.
InputManager.ts
regenerate
to the Inputs
type.update
method to check the state of the 'r' key.PlayScene.ts
regenerateMap
to remove all filled tiles and repopulate with a new map.regenerateMap
.regenerateMap
when the 'r' key is pressed in the update
method.tilemapManager
to use this.tilemapManager
.For more details, open the Copilot Workspace session.