Adventure game written for ECE2035 at the Georgia Institute of Technology
Dependencies: mbed wave_player 4DGL-uLCD-SE MMA8452
Diff: main.cpp
- Revision:
- 3:289762133fd6
- Parent:
- 2:0876296d9473
- Child:
- 4:cdc54191ff07
--- a/main.cpp Tue Apr 17 17:17:20 2018 +0000 +++ b/main.cpp Wed Apr 18 20:18:51 2018 +0000 @@ -10,7 +10,8 @@ int get_action (GameInputs inputs); int update_game (int action); void draw_game (int init); -void init_main_map (); +void init_main_map(); +void init_house_map(); int main (); /** @@ -24,6 +25,7 @@ int quest_complete; } Player; +int house_enabled = false; int door_open = false; int game_over = false; int health = 0; @@ -164,7 +166,9 @@ return NO_RESULT; } - } + } else if(object -> type == DOOR){ + init_house_map(); //add a bit of a wait here to simulate going into the house + } if (object -> walkable == false){ return NO_RESULT; } @@ -243,6 +247,9 @@ } else // There used to be something, but now there isn't { + if (house_enabled){ + draw = draw_house_floor; + } draw = draw_nothing; } } @@ -279,7 +286,8 @@ void init_main_map() { // "Random" plants - Map* map = set_active_map(0); + + maps_init(50, 50, 5); for(int i = map_width() + 3; i < map_area(); i += 39) { add_plant(i % map_width(), i / map_width()); @@ -310,6 +318,21 @@ print_map(); } +void init_house_map() +{ + + Map* map = set_active_map(1); //one is a house map + maps_init(20, 20, 5); + Player.x = Player.y = 5; + + add_wall(0, 0, HORIZONTAL, map_width()); + add_wall(0, map_height()-1, HORIZONTAL, map_width()); + add_wall(0, 0, VERTICAL, map_height()); + add_wall(map_width()-1, 0, VERTICAL, map_height()); + + add_npc(5, 15); //place NPC in the house +} + /** * Program entry point! This is where it all begins. * This function orchestrates all the parts of the game. Most of your @@ -318,16 +341,18 @@ */ int main() { + Map* map = set_active_map(0); int start = menu(); // First things first: initialize hardware ASSERT_P(hardware_init() == ERROR_NONE, "Hardware init failed!"); // Initialize the maps - maps_init(); + init_main_map(); + // Initialize game state - set_active_map(0); + //set_active_map(0); //this doesn't need to be here twice Player.x = Player.y = 5; Player.quest_complete = false; @@ -350,10 +375,13 @@ // 3b. Check for game over if (game_over == true){ draw_game_over(); - }else{ + }//else if(house_enabled == true){ + + //Player.x = Player.y = 5; //idk if this should be here... + //} // 4. Draw frame (draw_game) draw_game(u); - } + // 5. Frame delay t.stop();