C代写:CIS2500 Rogue-like

Introduction

代写一个Rogue-like的游戏,Rogue-like属于RPG游戏中的一类,游戏最大的特点就是每次生成迷宫的都是随机的。
这只是Part 2的作业,后续还有更复杂的Part 3。

Problem

You will implement the basic features of a “Rogue-like” computer game. Your program will accept an input file describing the layout of a single level with 6 rooms in it, and your program should draw all six rooms in a single window. Your program will also have a hero that the user can control, and move around the level.

Description

When started, your program should accept one command line argument (using argc and argv). The command line argument is a path to the level file. This file is a description of the level to be drawn.
Your program should start by opening the file, parsing the room descriptions line by line, and storing the data in an appropriate struct. Once done, close the file.
The program should then initialize ncurses, draw the level to the screen, and enter a “game loop”. While in the game loop, your program should accept input from the user to manipulate the world and update the screen appropriately. If the user presses the quit key, your program should exit the game loop, clean up ncurses, print the player’s amount of gold and return.
While in the game loop, the user is able to move the hero around the level. If the hero steps on a door, they should be teleported. Stepping on a door in room 1, should teleport the hero to a door in room 2. Stepping on a door in room 2, should teleport the hero to a door in room 3. Room 4 doors teleport the hero to room 5 doors. Room 5 doors teleport the hero to room 6 doors. And room 6 doors teleport the hero to room 1 doors. See Figure 1 for room numbering.

Additional Notes

  1. The hero should be unable to step on walls, and should therefore be unable to walk outside of rooms.
  2. The hero should be unable to walk on weak monsters or strong monsters.
  3. If the hero steps on a small gold or big gold, the value of that gold piece should be added to the hero’s gold amount. The hero starts with 0 gold.
  4. If the hero steps on a collectable, it should be removed from the screen. The following elements are collectable: Small gold, Big gold, Common weapon, Rare weapon, Equipment, Potion.
  5. If the hero steps on stairs going up or down, the program should execute the normal quitting procedure.

Level File

  • The input file will contain 6 rooms. You are expected to draw the rooms 3 across and 2 down. No room will be larger than 18 rows X 23 columns.
  • Each line of the file will consist of a space-delimited line of text.
  • Each line of the file will be less than 150 characters.
  • No room will have more than 10 elements (excluding room dimensions, and doors).
  • Lines will always have a newline at the end.
  • The first element of the input string will ALWAYS be the room dimensions given as rowsXcolumns (i.e. 10X12). The dimensions given are the dimensions of the floor of the room. The walls must surround the floor.
  • Following the room dimensions are room elements. These elements can be in any order.
  • Door elements will begin with a lowercase d followed by a letter representing the wall that the door is in. For example, de3 is a door in the east wall in position three from the north edge (where the floor corner is position 0, and walls start at 1). There will never be more than one door per wall.
  • All other (not room dimension or door) elements will begin with a lowercase letter followed by coordinates. For example: w6,8 means there is a weapon at row 6 column 8 where the northwest floor corner of the room is 0,0.
  • For this assignment, you can assume the file inputted will follow this specification as closely as possible.

Summary

总体来说,Part 2部分的编程难度还好,不过需要设置游戏中的大量元素。