diagonal tile based movement.
Displaying 1-6 of 6 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
HornyRabbit

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);
}

Posted on 2006-02-09 17:38:56

CrazyAznGamer

Oh, those Verge days without diagonal movement...
Oh.... how hard it was to make actually good real time AI... but that's another story.

Anyways. I don't quite understand what you're trying to do here. Looks here to me that you're just having players move by pressing one direction, and then, having pressed that one direction, make the player move one tile that direction. Wait, that's tile-based movement...

Aside from that, you must realize that EntityMove will move an entity like whatever no matter what the obstruct or obstructable is set to. As you can see, this will induce problems.
Players will consequently be able to move through walls and such blasphemous things. So really, you need to build some sort of collision detection into it.

Of course, I may be wrong on the obstruct thing (Verge is getting very frequent engine updates recently. So I have trouble keeping up sometimes).

Posted on 2006-02-09 22:10:01

Omni

I think this may actually be implemented in-engine in the latest builds. You'd have to either check the latest Changlogs, or read through the Development Forum to find out for sure, though.

Posted on 2006-02-09 23:42:23

Overkill

Quote:
Originally posted by CrazyAznGamer


Aside from that, you must realize that EntityMove will move an entity like whatever no matter what the obstruct or obstructable is set to. As you can see, this will induce problems.
Players will consequently be able to move through walls and such blasphemous things. So really, you need to build some sort of collision detection into it..



Incorrect. Only PlayerMove() ignores obstructions. EntityMove, on the other hand, takes these things into account but will continually try movement if in an obstructed place, hoping the wall or entity blocking will eventually disappear.

PlayerMove() on the other hand, walks through ANYTHING. And will actually only execute HookTimer, HookRetrace and HookEntityRender functions, Render() and ShowPage(), the whole time the player is moving.

Yeah, so he's doing things right, except for the lines that are:
Unpress(SCAN_PGUP);
Should be:
key[SCAN_PGUP] = 0;

That COULD be the reason why the diagonal movement is screwy, is because it'll repeatedly override the movescript as it moves, and will constantly reset the animation of the sprite.

OVERKILL MUHAHAH ADMIN EDIT:Just so you know, the EntityMove() and PlayerMove() obstruction stuff hasn't changed. It's been the same since Verge2, possibly Verge1, with the exception of PlayerMove() being called PartyMove() back then.

Posted on 2006-02-10 14:19:25

HornyRabbit

Many thanks to you guys on answering.

I'm just learning Verge and still want to learn thingsIi may want to do in future. Like now im doing graphics without move animation but want to learn how to make movement system that i like, ie. nethack.
I suck at names so i cant say who told me things(Overkill i remember for some reason :o), but I've been reading things at #vergehelp and even asked a few things and thats where i learned about diagonal move strings, but couldnt get them right.

I dont know what i sound like, got from work 2 hrs ago and managed to have a few beers at pub so i'll get on with coding tomorrow..
Over and out :)

Posted on 2006-02-10 15:38:24

CrazyAznGamer

:o...
...
:o

...
I'm shocked. Totally.
*Sigh*
*Comments out code*

Posted on 2006-02-10 21:39:36


Displaying 1-6 of 6 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.