1. Homepage
  2. Programming
  3. COMP1000 Unix & C Programming Semester 2, 2022 - Assignment Two: Escape Game

COMP1000 Unix & C Programming Semester 2, 2022 - Assignment Two: Escape Game

Engage in a Conversation
AustraliaCurtinCurtin UniversityCOMP1000Unix & C ProgrammingEscape GameCUnix

Assignment Two
CourseNana.COM


CourseNana.COM

Your task for this assignment is to design, code (in C89 version of C) and test a program. In summary, your program will: CourseNana.COM

  • Retrieve map information from a text file provided in command line argument.
  • Adjusttheforegroundandbackgroundcolorofspecificcharacteronthegameinterface.
  • Utilize a generic linkedlist and struct to keep track of player movement and collapsed floor locations.

1 Code Design CourseNana.COM

You must comment your code sufficiently in a way that we understand the overall design of your program. Remember that you cannot use “//” to comment since it is C99-specific syntax. You can only use “/*.........*/” syntax. CourseNana.COM

Your code should be structured in a way that each file has a clear scope and goal. For example, “main.c” should only contain a main function, “game.c” should contain functions that handle and control the game features, and so on. Basically, functions should be located on reasonably appropriate files and you will link them when you write the makefile. DO NOT put everything together into one single source code file. Make sure you use the header files and header guard correctly. Never include .c files directly. CourseNana.COM

Make sure you free all the memories allocated by the malloc() function. Use valgrind to detect any memory leak and fix them. Memory leaks might not break your program, but penalty will still be applied if there is any. If you do not use malloc, you will lose marks. CourseNana.COM

Please be aware of our coding standard (can be found on Blackboard) Violation of the coding standard will result in penalty on the assignment. Keep in mind that it is possible to lose significant marks with a fully-working program that is written messily, has no clear structure, full of memory leaks, and violates many of the coding standards. The purpose of this unit is to teach you a good habit of programming. CourseNana.COM


CourseNana.COM

3 Task Details 3.1 Quick Preview CourseNana.COM

First of all, please watch the supplementary videos on the Assignment link on Blackboard. These videos demonstrates what we expect your program should do. You will expand the basic functionalities of the escape program you did for assignment 1 (The ”BORDERLESS” feature is NOT necessary to complete assignment 2. You can leave the feature as it is, or remove it if you prefer). Further details on the specification will be explained on the oncoming sections. CourseNana.COM

3.2 Command Line Arguments
Please ensure that the executable is called “escape”. Your executable should accept one command- CourseNana.COM

line parameters/arguments: CourseNana.COM

./escape <map_file_name> CourseNana.COM

<map_file_name> is the textfile name that contains the map size and location of all the neces- sary characters of the game. You have to use the proper File I/O functionalities to retrieve the information. For more detail, please refer to Section 3.3. CourseNana.COM

If the amount of the arguments are too many or too few, your program should print a message on the terminal and end the program accordingly (do NOT use exit() function). If the file does not exist, then you need to handle it with a proper error message. CourseNana.COM

Note: Remember, the name of the executable is stored in variable argv[0]. CourseNana.COM

3.3 File I/O CourseNana.COM

Please watch the supplementary video about the File I/O. The text file will look like this: CourseNana.COM

Figure 1: Example of a text file containing the map size and location information. CourseNana.COM

The two integers on the first line are the playable row and column map size respectively. After- wards, each line represents the location (starting from index zero) for the player, goal, and the collapsed floor grids. Each line will have the row position, column position, and the character. You can assume there is one and only one player and one goal in the text file. Collapsed floor grids locations are optional on the text file. Those characters can appear in any order. CourseNana.COM

Note: Keep in mind that we will use our own map text file when we mark your assign- ment. So, please make sure your file I/O implementation works with various files. CourseNana.COM


CourseNana.COM

Similar to assignment one, your program should clear the terminal screen and print the 2D map: CourseNana.COM

Then the user can enter the command via key ’w’, ’a’, ’s’, and ’d’ to control the player. Every time the user inputs the command, the program should update the map accordingly and refresh the screen (clear the screen and reprint the map). In addition, the player can enter the key ’u’ to undo the movement of the player. For more detail about UNDO feature, please refer to section 3.6. CourseNana.COM

3.5 Adding Colors CourseNana.COM

Please watch the supplementary video regarding the pre-written methods to add foreground color and background color on the game interface. You need to adopt those functions to your program to make: CourseNana.COM

• Player ’P’ has the blue font color.
• Goal ’G’ has the green font color.
• The most recent collapsed floor grid ’X’ will have the red background color.
CourseNana.COM

Note: Keep in mind that when you use the undo feature from section 3.6, your program should still be able to keep track the most recent collapsed floor grid and add the back- ground color accordingly. CourseNana.COM


CourseNana.COM

3.6 Struct and Generic Linked List to implement UNDO feature CourseNana.COM

In this section, you will need to write a generic linked list with appropriate struct to implement UNDO feature. This feature is triggered when the user enters the key ’u’. Everytime the key is pressed, the player will move back to the previous movement, and the most recent collapsed floor grid is restored. The player can use the undo feature at any point of the game as long as the game is not over. It should be possible to keep undo-ing until the initial state of the game when you just run the program. CourseNana.COM

Please refer to supplementary video for some advices regarding this implementation. The sum- mary is that you can use the linkedlist node to store the previous player ’P’ location, the current and previous collapsed floor grid ’X’ location (This is only one example, you can store more information if you need it). You will need to create a new linkedlist node every time the player moves and store it in the linkedlist. When the player presses ’u’, your program should be able to retrieve the most recent node and update the map to the previous state. If the linkedlist is empty, pressing ’u’ should not do anything. CourseNana.COM

Note: Please do not just copy the whole linkedlist code from someone else because it might lead to collusion academic misconduct. CourseNana.COM

3.7 Makefile CourseNana.COM

You should manually write the makefile according to the format explained in the lecture and practical. It should include the Make variables, appropriate flags, appropriate targets, correct prerequisites, conditional compilation, and clean rule. We will compile your program through the makefile. If the makefile is missing, we will assume the program cannot be compiled, and you will lose marks. DO NOT use the makefile that is generated by the VScode. Write it your- self. CourseNana.COM

3.8 Assumptions CourseNana.COM

For simplification purpose, these are assumptions you can use for this assignments: CourseNana.COM

  • The coordinates of all characters provided in the text file are all valid. (NOT out of bound)
  • There will be exactly one player and one goal in the text file. However, they can appear in any order in the text file.
  • Thesizeofthemapwillbereasonabletobedisplayedonterminal.Forexample,wewill not test the map with gigantic size such as 300 x 500. It is the the same for the opposite scenario, we will not test your program with the map size less than 5 x 5.
  • You only need to handle lowercase inputs (’w’, ’s’, ’a’, ’d’, ’u’).

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
Australia代写,Curtin代写,Curtin University代写,COMP1000代写,Unix & C Programming代写,Escape Game代写,C代写,Unix代写,Australia代编,Curtin代编,Curtin University代编,COMP1000代编,Unix & C Programming代编,Escape Game代编,C代编,Unix代编,Australia代考,Curtin代考,Curtin University代考,COMP1000代考,Unix & C Programming代考,Escape Game代考,C代考,Unix代考,Australiahelp,Curtinhelp,Curtin Universityhelp,COMP1000help,Unix & C Programminghelp,Escape Gamehelp,Chelp,Unixhelp,Australia作业代写,Curtin作业代写,Curtin University作业代写,COMP1000作业代写,Unix & C Programming作业代写,Escape Game作业代写,C作业代写,Unix作业代写,Australia编程代写,Curtin编程代写,Curtin University编程代写,COMP1000编程代写,Unix & C Programming编程代写,Escape Game编程代写,C编程代写,Unix编程代写,Australiaprogramming help,Curtinprogramming help,Curtin Universityprogramming help,COMP1000programming help,Unix & C Programmingprogramming help,Escape Gameprogramming help,Cprogramming help,Unixprogramming help,Australiaassignment help,Curtinassignment help,Curtin Universityassignment help,COMP1000assignment help,Unix & C Programmingassignment help,Escape Gameassignment help,Cassignment help,Unixassignment help,Australiasolution,Curtinsolution,Curtin Universitysolution,COMP1000solution,Unix & C Programmingsolution,Escape Gamesolution,Csolution,Unixsolution,