Basic-Reb0rn 2 (Getting Started)


Getting started with C++

Rooms and movement

First thing i did when trying to recreate this game in c++ was create the rooms and movement functionality. Initially I did this using a simple integer for the room number and have the arrow key inputs as the movement controls for the player.   Obviously this was only an initial test to get something moving around in a set number of rooms and will definitely need improvement. The players position also works with the room numbers. Basically "player_position" = "rooms". 

The movement controls has the player push an arrow key, the player is then asked to confirm the move by pressing enter after the prompt. However if they wish to choose a different direction they simply press one of the arrow keys again. All done using the "renderer", some bool variables for each direction, the "MovementManager" and directional functions that i created and some simple "If" statements in, all the main "MyGame" class. 

The rooms where changed into an array of room numbers and another array of constants for the names themselves. In "MyGame.cpp"(The main class) and in the Initialisation function, I use a "for" loop to go through each room number and then use the .setRoomName to set the corresponding number to room name.  Then in the "Rooms" class I made Set and Get functions for the directions the players can choose, because we don't want the player to be able to move through the walls essentially and we also want the player to know what directions they can go in. Then I made a 2D array of constants that have the room numbers and the four possible directions. This array when used with the set and get functions is what moves the player from room to room, by using the room index to decide weather that room is viable or not. Rooms that aren't viable were set to "-1" since that number does not exist in the array. 

Next up will be putting items in the rooms.