EntityMove

EntityMove
void EntityMove(int entity, string script)

Documentation

With this function you can set actions for the entity (specified by int reference) to follow using a 'movecode' string. In verge a movecode is a string of instructions for an entity to follow, one after the other, like a 'script'. Each command is a letter, sometimes followed by a number, here are a list of what each does:

ulrd (followed by number) Move the entity either up, down, left or right by set number of tiles.

xy (followed by number) Move an entity so a set x or y tile position

pt Changes movement to either pixel accurate, p, or tile accurate, t. Now works.

z (followed by number) Set the current frame of the entity, like setting entity.specframe

w (followed by number) The entity pauses for set number of timer ticks (default 100 = 1 second)

f (followed by number) Sets the entity's facing: use directional 0 moves instead, then you don't need to remember which number is which direction

b Loops the entire movecode, eternally

They can be either upper or lower case (which ever you think looks nicer) and don't need a space or anything between commands. Verge processes entity movecodes every call to ShowPage() so, if you need the game to 'pause' for a textbox or something, make sure you use SetEntitiesPaused() so the entities don't suddenly 'jump' to their next positions.

There are a few things to remember when moving entities around, firstly the entity needs to have their specframe set to 0 to enable the walk animation, rather than just sliding around. So if you change the frame, remember to set it back with “z0” before moving. Also, any movement is ignorant of obstructions and other entities, so make sure to test what you use to make sure it works as expected.

Note, unlike PlayerMove(), verge does not wait for this to finish before running the next line of code. So you can set several entities moving all at the same time. However, it is likely you will sometimes want to wait untill a particular entity has finished moving, so I recommend having a WaitForEntity() function.

Example Usage

// Examples adapted from Parallel Seven

// Moves the first party member to the x position 77, 
// then to the y position 42, then faces upwards
EntityMove(party[0].ent, "x77y42u0");

// Animate drunk picking up broken bottle
EntityMove(2, "z24w80z25w100");
// Waits till the entity is done with the movecode before continuing
WaitForEntity(2);

void IdleAnimPlayer(int pparty)
// Sets a party member into the idle animation
{
	EntityMove(party[pparty].ent, "z4w100z2w100b");
}
// Note: The 'b' at the end repeats this movecode

// Sets the party member to animated movement frame
EnityMove(party[pparty].ent, “z0”)
Talkback

Post a new comment?

Talkback #1 written by KingOfTheNorth on 2010-08-17.

As of Verge 3.0, it looks like "f" directional code for EntityMove( ) is:
- - - 1 - - -
2 - - - - 3+
- - - 0 - - -
Where f 0 faces down, f 1 faces up, f 2 faces left, f 3 (and up) faces right. Seems the case is the same with PlayerMove( )

Post a new comment?

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.