Hello, I'm trying to get started on a Maze game assignment and I want to make sure I'm setting up my classes correctly, before moving into functions and reading level files. The full assignment instructions are quite long so here is the class outline and an example level to read in.
Brief outline of goals and rules:
*Enable user to walk through maze
*Doors require keys
*Ghost wanders around
*User can pick up cherries to handle ghosts
*User must reach ladder to get to next maze
*Ladders go to next level (maze) until level with exit
Here is the class outline (given by instructor):
Game class - Array of floors, Array of characters, function to read in floors from files
Floor class - char[][] tiles, void print to screen, constructor
Character class: ABSTRACT - int x/y loc, char symbol, virtual move
Ghost class (inherits Character) - move (automated)
Player class (inherits Character) - move (prompt for WASD), keys(s), Invincibility counter, hold up to 3 keys
My header (so far):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
|
#ifndef HEADER_H
#define HEADER_H
class Game {
public:
int floor [3];
int characters [];
void readFloors();
}
class Floor {
char tiles;
void printToScreen;
Print();
~Print();
}
class Character {
int x;
int y;
char symbol;
}
class Ghost: public Character {
}
class Player: public Character {
void controls();
int lives;
int keys;
}
#endif // HEADER_H
|
What should I do for the ABSTRACT class?
Also, what's the best way to read in files that look like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
##############################
# K #
# ############## ### ### # #
# K # # #C# #K# # #
# ######### # A # # # # # # #
# K # # # #
# ############D#####D####### #
# #
# C G C #
# #
# ######D##############D#### #
# # C #K# # #
# #### ######## # # # #
# #K # # ### # # #### #
# # ## # #### # # # # # #
E # ## # # ### # # #### # #
# # # #K D # #
# #D#### ################### #
# K #
##############################
|
Map info:
# = Wall
D = Door
A = Ladder up and down, A and B
B = Ladder up and down, B and C
P = Player
G = Ghost
K = Key
C = Cherry
E = Entrance
X = Exit
Thanks for the help!