How do you alter variables within arrays

I am coding a text RPG, and am trying to implement options to 'move north', 'move south', and so on. I have a 10x10 struct (I should add code to prevent the player from hitting the wall later) and it works by leaving one variable alone and modifying the other positively or negatively. I am unsure of how I should do this.

(I have all the integers within a struct. It's huge, so I left that out. I'm positive I'm calling it right. I also left out north and south to reduce the amount of code. They are identical except for the variable being modified and which operator is used.)

Coded on Ubuntu 11.04 in Code::Blocks.

1
2
3
4
5
6
7
8
9
10
11
int goeast()
{
    player.currentlocation[int a][int b] = player.currentlocation[int a][int b + 1];
    player.magicka = player.magicka + ((player.magicka / 20) + (player.constitution + player.intelligence));
}

int gowest()
{
    player.currentlocation[int a][int b] = player.currentlocation[int a][int b - 1];
    player.magicka = player.magicka + ((player.magicka / 20) + (player.constitution + player.intelligence));
}
Firstly, if you write int, it usually means you're declaring something (it could also be a cast or template argument, but that's for later..). Here you have nothing to declare.

The plan should be to have a player class that has members x and y. As you move add + or -1 to either. Also have a map array. When you want to know about the place the player is in, you can check map[player.x][player.y].hasMonster or etc.
I get it- of course, the array is for storing data in each combination of numbers, it doesn't hold two set values! My bad, it's been a while. Thanks!
Topic archived. No new replies allowed.