Yes, correct. Here is my code for when the A key is hit:
1 2 3 4 5 6 7 8 9 10
|
if (player_coord - 1 < 0 || player_coord == HORIZONTAL*1){
input = true;
cout << "\rCharacter cannot complete move. Try again.";
break; }
else {
player_coord -= 1;
input = false;
break; }
|
I have two constant variables for the Horizontal and Vertical size of the map. I can change these variables to alter the size of the map which prints out to be a box using " " as a filler. The player can move up, down, left and right using WASD.
So if I change the Horizontal and Vertical integers the playable area will change, allowing me to create different levels and whatnot.
I'm just having trouble blocking off the left and right sides of the screen so the player doesn't loop around to the end of the previous "line" on the map, or the beginning of the next "line" on the map respectively.
So in the code I provided, since each "new line" is the Horizontal value multiplied by the vertical line value at that spot, I know how to block that movement - I just don't know how to do it consistently enough so that the code doesn't repeat itself.
1 2
|
case 'a':
if (player_coord - 1 < 0 || player_coord == HORIZONTAL || player_coord == HORIZONTAL*2 || player_coord == HORIZONTAL*3 || player_coord == HORIZONTAL*4)
|
That iteration works - what it's doing is taking the Horizontal value, say for example, 10, and multiplying it each time there is a new line and blocking the movement there. So you can't go left while you're on the 20th Horizontal space, or the 30th, etc. Is there a way to condense it so that the movement is blocked regardless of how many vertical lines there are?
Sorry if I rambled or repeated myself, I'm wracking my brain here.