I know I'm asking loads of questions, but when I get frusterated I turn to you peeps
Anyways, I'm trying to make a tile based game, and now I have this struct
Code:
struct tileSlot{
object obj;
float x, y;
};
And an array
Code:
tileSlot slots[31][23];
And then I set a fixed position to all the 'slots', using this code
Code:
void tileSlotPos(){
float width = 0;
//width loop
for(int w = 0; w >= 31; ++w){
float height = 0;
//height loop
for(int h = 0; h >= 23; ++h){
slots[w][h].x = width;
slots[w][h].y = height;
height += 32;
}
width += 32;
}
}
and then I create the platforms using this code.
Code:
void createPlat(int slotW, int slotH){
platform plat;
slots[slotW][slotH].obj = plat;
plat.x = slots[slotW][slotH].x;
plat.y = slots[slotW][slotH].y;
plats.push_back(plat);
}
Then later when I call, for testing.
Code:
tileSlotPos();
createPlat(20, 20);
the platform ends up in the top left corner, meaning x= 0 and y = 0, or slot[0][0]
Do you peeps have any idea why it does this? And do you have any idea for a different approach to doing this?
Thanks in advance!