B
Blaize
Guest
I was wondering if it was possible to set a mask and store an object id in the same 2D array entry. I'm still relatively new to bitmasking in general, so any corrections are appreciated.
In a nutshell, I have a GameGrid[x,y] which starts empty. Then, I set specific tiles to hold certain features (heal, damage over time, etc). The goal is that an object that occupies a tile will react to that tile in a certain way.
Roughly (pseudo-codey), my project looks something like this:
And the player:
Without the masks (if I'm using them properly that is), everything works fine. When the player moves, it's original position in the array is cleared and the array stores the id in its new position. However, when combined with the tile masks, if the player moves over a masked tile, then moves off, it also removes the mask.
Should I be approaching this differently?
In a nutshell, I have a GameGrid[x,y] which starts empty. Then, I set specific tiles to hold certain features (heal, damage over time, etc). The goal is that an object that occupies a tile will react to that tile in a certain way.
Roughly (pseudo-codey), my project looks something like this:
Code:
for (i=room_height;i>-1;i--)
{
for(j=room_width;j>-1;j--)
{
GameGrid[j,i] = 0;
}
}
GameGrid[@0,0] = START; //These are macros I created as a bitmask
GameGrid[@2,3] = HEAL;
instance_create_depth(0,0,0,Player Object);
Code:
Map.GameGrid[@x,y] |= id;
CurrentX=x;
CurrentY=y;
TargetX=0;
TargetY=0;
Code:
LeftRight = keyboard(Right)-keyboard(Left);
if (LeftRight != 0)
{
TargetX = CurrentX + LeftRight;
if (Map.GameGrid[@TargetX,CurrentY]==noone)
{
Map.GameGrid[@CurrentX,CurrentY] &=~id;
x = TargetX;
Map.GameGrid[@TargetX,CurrentY] |= id;
}
}
Should I be approaching this differently?