* of course, timer state needs to be extended a bit to have the pop-out action
* right now all box calculations are done with the top left x,y, which makes player movement with the sprite quite funny if you traverse an intersection and are not completely in the adjunct box.
I need to think through how best to solve the latter problem, if anyone has any ideas, feel free to reply. In the mean time, I've attached a ROM to show behavior.
relevant code:
Code: Select all
/**
* move_players()
*/
void move_players(void)
{
for (i=0;i<2;++i)
{
// Get the player's box.
a=div24(stamps[STAMP_X(i)]-8);
b=div24(stamps[STAMP_Y(i)]-8);
c=(b*10)+a; // C is now the box #
d=dungeon[c];
if (stamps[STAMP_XTRA_A(i)]==TRUE)
{
// Player inside box.
if (sec==0) // One second has elapsed.
{
stamps[STAMP_XTRA_B(i)]--;
if (stamps[STAMP_XTRA_B(i)]==0x00)
{
stamps[STAMP_XTRA_A(i)]=FALSE;
}
}
else
{
// do nothing, for now.
}
}
else
{
// Player outside box.
if (stamps[STAMP_XTRA_B(i)]==0x00)
{
// Eject player
stamps[STAMP_Y(i)]=PIXEL_BOX_Y(5); // Place inside playfield.
stamps[STAMP_XTRA_B(i)]=0xff; // Indicate player has been ejected.
if (i==0)
{
yellow_door_state=CLOSED;
}
else
{
blue_door_state=CLOSED;
}
}
else
{
// Player is free to move, move about.
if ((stamps[STAMP_STATE(i)] == STATE_PLAYER_RIGHT_IDLE) ||
(stamps[STAMP_STATE(i)] == STATE_PLAYER_LEFT_IDLE) ||
(stamps[STAMP_STATE(i)] == STATE_PLAYER_UP_IDLE) ||
(stamps[STAMP_STATE(i)] == STATE_PLAYER_DOWN_IDLE))
{
// Player is idle, do nothing, else...
}
else
{
// Player wants to move.
if (stamps[STAMP_STATE(i)]==STATE_PLAYER_RIGHT)
{
if (d&1<<4)
{
// Right wall nearby.
if (stamps[STAMP_X(i)]==PIXEL_BOX_X(a))
{
// don't do a damned thing.
}
else
{
stamps[STAMP_X(i)]++;
}
}
else
{
stamps[STAMP_X(i)]++;
}
}
else if (stamps[STAMP_STATE(i)]==STATE_PLAYER_LEFT)
{
if (d&1<<6)
{
// Left wall nearby
if (stamps[STAMP_X(i)]==PIXEL_BOX_X(a))
{
// Don't do anything
}
else
{
stamps[STAMP_X(i)]--;
}
}
else
{
stamps[STAMP_X(i)]--;
}
}
else if (stamps[STAMP_STATE(i)]==STATE_PLAYER_UP)
{
if (d&1<<7)
{
// Up wall nearby
if (stamps[STAMP_Y(i)]==PIXEL_BOX_Y(b))
{
// Don't do anything
}
else
{
stamps[STAMP_Y(i)]--;
}
}
else
{
stamps[STAMP_Y(i)]--;
}
}
else if (stamps[STAMP_STATE(i)]==STATE_PLAYER_DOWN)
{
if (d&1<<5)
{
// Down wall nearby
if (stamps[STAMP_Y(i)]==PIXEL_BOX_Y(b))
{
// Don't do anything.
}
else
{
stamps[STAMP_Y(i)]++;
}
}
else
{
stamps[STAMP_Y(i)]++;
}
}
}
}
}
}
}