tile.c[h]:Defines the structure for a tile along with functions to create, destroy, and display tiles. There are also functions for moving the player and enemies.
This file includes eight functions and a struct for the tile.
room.c[h]:Includes function to initialize, draw, un-draw and change the dimensions of the rooms walls where the game will be played.
key.c[h]:Includes a function that will read key presses from the keyboard. This function deals with theANSI escapesequences generated by the keys.
game.c[h]:This file defines a function called game(). This function includes a state machine wrapped in an infinite loop. This state machine is the heart of the game. Game activities such as enemy movement, game termination, etc are launched from this state machine.
Moving the Player
The player cant move from the starting position, so you need to add player controls.
The player should be able to move up, down, left, and right.
The arrow-keys should be used for moving around the room.
The provided key.c file helps detect key presses.
Doors and stairs must function properly to receive full points for player movement.
Pausing/Resuming the game
Once you start playing the game you should be able to pause it. Also, you should be able to resume the game, starting from where it left off just before you paused it. The timer should not be updated, and nothing should be able to move in the paused state.
Once the game is paused, provide the user with 1 option:
p/Pto unpause the game
Ending the Game
The game is over whenq/Qis pressed, or an enemy touches the player. In this case, the game state should be set to EXIT. The EXIT state should clear the screen.
Scoring the Game
There is gold all over the floor in each room that the player can pick up. Its represented by a $ on screen. Lets turn the gold into a scoring system.
Keep track of how much gold the user collects.
Print out a running score total at the top of the screen.
Limiting Doors and Floors
Right now, the game allows an endless number of floor and too many doors. We need to add limits so the game has a definite end.
Limit the number of doors per wall to 1. Having no door on a wall is fine.
Limit The number of floors to 4 including the starting floor.
Milestone 1 Requirements
This milestone is about gaining basic familiarity with the code then adding player movement and a scoring system.
In the game() function, there is a switch statement that indicates the current state of the state machine. The state where you will be making your modifications isSTEP. The main function that it fulfills is updating the states for all the tiles and character movements.
You should implement the code necessary to implement the following functionality.
P:Press P/p to pause the game, must resume on another press.
Q:Press Q/q at any time to quit the game.
Move the player with the arrow keys.
Keep track of the players score.
Add a limit to the number of doors and floors.
Hints
There are 5 states for each cell:PLAYER,LOOT,EMPTY,ENEMY, andUNCHANGED.
UNCHANGEDstate is used to know which tiles to update.
There is a 3 element array called state in the tile struct. It keeps a sort-of history for that tile. For now focus on theCURRENTandNEWstates.
SUCCESSandFAILenums are there for debugging.
Each key on the keyboard is represented by an ASCII hex code. Find the codes forpandPkeys and use the code in key.c file to handle the keypress event for those keys.
Same forqandQ.
Use manpages!Try callingman getchandman ncursesin the terminal.
Reviews
There are no reviews yet.