代写 game • 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.

• 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 room’s 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 the ANSI escape sequences 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 can’t 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/P to unpause the game
Ending the Game
The game is over when q/Q is 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. It’s represented by a ‘$’ on screen. Let’s 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 is STEP. 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 player’s score.
• Add a limit to the number of doors and floors.
Hints
• There are 5 states for each cell: PLAYER, LOOT, EMPTY, ENEMY, and UNCHANGED.
• UNCHANGED state 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 the CURRENT and NEW states.
• SUCCESS and FAIL enums are there for debugging.
• Each key on the keyboard is represented by an ASCII hex code. Find the codes for p and Pkeys and use the code in key.c file to handle the keypress event for those keys.
• Same for q and Q.
• Use manpages! Try calling man getch and man ncurses in the terminal.