📢 More maps are coming out in May! (Sorry, this is fake news.)
Li Han (3035845954) @Kelios1556
Ye Yaowen (3035845344) @HelloElwin
"Unnamed Game is a fun game without a name (yet)! And you, the bravest explorer in HKU, are given the job to find the name for this game! The name is hidden in a secrete room in a world of ice and flame, and your journey starts from a certain point in this world. At the end point lies the entrance of the secrete room and your ultimate goal: name for the Unnamed Game!"
This is a keyboard-based adventure game for one player controlled by wasd. The player is suggested to kick in a way to travel to the destination.
A list of features including portals, gravity switches, world converters etc., are designed to assist the travel. Two properties, ice and flame, are attached to the player, elfins and grounds. Under opposite properties, elfins and grounds may be dangerous to the player.
[Video Demonstration in Google Drive] [Video Demonstration in this repo]
Start the game with these commands!
Move the character with wasd
and select with g
. [Sample I/O]
make clean
make main
./main
The game is tested in HKU CS academy11
server. However, we strongly recommend you to run the game locally since the network latency may affect your gaming experience.
The player will fall/float according the direction of gravity.
It can move in horizontal directions with a property of ice or flame. An elfin will move towards the player when the player arrives at the same level. If the player holds the same property as the elfin, the elfin is harmless. It will chase after you, or bounce around you, or fly towards you. Otherwise, if the player holds the opposite property as the elfin's, direct contacting means Game Fails.
When the player reaches a Gravity Switch, the direction of gravity will be changed.
When the player enters a World Converter from the external world, the player will arrive in the inner world, and vice versa. The properties of some features (e.g., player, elfins, property grounds) may convert upon player's arrival.
Portals, appearing in pairs, are distinguished by colors. When the player enters a portal from one side, the player will be sent to the same side of another portal with the same color.
They differd from normal grounds as their specified properties. They may be attached with ice or flame as their own property, which might convert to the opposite properties in the inner world. If the player is with the same property as the ground, it can be treated as the normal ground. Otherwise, walking on the ground with the opposite property will result in Game Fails.
World converters usually have similar shapes with portals except that they do not appear in pairs. It means that if there's no other portal that is with the same color as this "portal", then it is a world converter. When it is a necessity to pass a block of property ground with the opposite property, or when facing the coming attack from a elfin with the opposite property, the player can enter the external/inner world through these world converters.
-
Generation of random game sets or events
- We use random seeds to decide the color of Portals and World-Converters. [link]
-
Data structures for storing game status
-
Dynamic memory management
- We use a vector to store all the elfins in a specific map. When initializing a map, we push the elfin to the vector one by one. At the end of the game, we release all the stored elfins from the vector. [link]
-
File input/output
- Before the game, the player needs to choose a map available. The program will read the choice, and the corresponding map file will be loaded from
/lib/maps
. [link] - When the program initializes a map, the corresponding templates of different blocks (E.G., portals, gates, grounds) and the elfin are loaded to fill the content of the map. [link]
- After the player wins a game, the success record will be saved to
pass.txt
. [link]
- Before the game, the player needs to choose a map available. The program will read the choice, and the corresponding map file will be loaded from
-
Program codes in multiple files
. ├── main ├── Makefile ├── README.md ├── src │ ├── *.cpp │ ├── *.h ├── bin │ ├── *.o ├── lib │ ├── blocks │ │ ├── *.txt (block models) │ └── maps │ ├── *.txt (maps) │ ├── conio.h │ ├── description.txt │ ├── format.txt │ ├── pass.txt ├── test │ ├── *.py/cpp (test programs) ├── pics
-
Implemented functions for game features
Map initialization
void Map::init(int map_num);
Map print
void Map::print(void);
Map update
void Map::update(Player u);
Map content fill
void fill(int overall, int *cont, int state);
Gravity inversion & portal and world-converter delivery
void Map::check(Player &u);
World Conversion
void Map::converter(Player &u);
Player initialization
void Player::init(int x0, int y0, int h0, int w0, int s0, int cont[][2], int proty);
Game status check
bool Player::alive(Map& map); bool Player::success(Map& map);
Player move
void Player::move(char direction, Map& map, bool& moving);
Elfin initialization
void Elfin::init(int x0; int y0, int h, int w, int cont[][6], int proty, int lel);
Elfin move
void elfin_move(Map& map, Player& player, bool& touch, bool& moving);
Window size reminder
void sizecheck(void);
-
termios.h
is used to monitor keyboard input#include <termios.h> struct termios; int txgetattr(int, struct termios *); int tcsetattr(int, int, struct termios *);
-
sys/ioctl.h
is used to get the row and column of the window#include <sys/ioctl.h> struct winsize; ioctl(int, usigned long, struct winsize *);
-
conio.h
is used to determine whether a key has been pressed or not#include <conio.h> int kbhit(void);