Hello all! (my first post)
Im trying to achieve tile based movement with along with diagonal moves. I have 16x16 entity, hotspot is 0,0,16,16.
Problem is that on diagonal movement entity moves towards obstruction one pixel.
void MapInit()
{
player = 0;
npc_int = 1;
active = 0;
player = EntitySpawn(5, 5, "chars\player.chr"); // player to the field
entity.obstruct[player] = 1; // not sure if needed
entity.obstructable[player] = 1; // not sure if needed
//movement calls
HookKey(SCAN_PGUP,"playerMoveUR");
HookKey(SCAN_HOME,"playerMoveUL");
HookKey(SCAN_PGDN,"playerMoveDR");
HookKey(SCAN_END,"playerMoveDL");
HookKey(SCAN_UP,"playerMoveU");
HookKey(SCAN_DOWN,"playerMoveD");
HookKey(SCAN_LEFT,"playerMoveL");
HookKey(SCAN_RIGHT,"playerMoveR");
//PlayerStep = 16; // tile based movement. looses obstruction detection
HookKey(SCAN_A, "spawn_npc");
HookKey(SCAN_B, "changeActive");
}
/*
Just to remind me
|02:57| <@kdfgeas> if you put something like hookKey(SCAN_PGUP,playerMoveUR);
|02:57| <@kdfgeas> and then
|02:58| <@kdfgeas> void playerMoveUR() { PlayerMove("UR1"); }
*/
In system.vc
void playerMoveUR()
{
EntityMove(active,"UR1");
Unpress(SCAN_PGUP);
}
void playerMoveUL()
{
EntityMove(active,"UL1");
Unpress(SCAN_HOME);
}
void playerMoveDR()
{
EntityMove(active,"DR1");
Unpress(SCAN_PGDN);
}
void playerMoveDL()
{
EntityMove(active,"DL1");
Unpress(SCAN_END);
}
void playerMoveU()
{
EntityMove(active,"U1");
Unpress(SCAN_UP);
}
void playerMoveD()
{
EntityMove(active,"D1");
Unpress(SCAN_DOWN);
}
void playerMoveL()
{
EntityMove(active,"L1");
Unpress(SCAN_LEFT);
}
void playerMoveR()
{
EntityMove(active,"R1");
Unpress(SCAN_RIGHT);
}