Even if the player, Dizzy, is not a brush set from the map editor, it has a similar set of properties, accessible only from the script, during gameplay.
Some of them are basic properties, like position, tile or color and some of them are logic properties.
You can access them through two functions, also similar to those used to access objects.
This exported function returns the value of the specified player's property.
This exported function sets the value of the specified player's property.
The defines representing the player's properties are also exported.
For example, P_X and P_Y represent the player's position in the world and P_COLOR is the player's color.
The P_LIFE property stores the player's energy, with values from 0 to 100, and P_CREDITS stores the number of life credits.
Some of the player's parameters are more tricky to use by a beginner. For more details about them, check the player reference chapters.
Perhaps the most important properties of the player are his coordinates, P_X and P_Y.
They store the player's position in the world as horizontal and vertical coordinates.
They can be readed, to find where the player is, or they can be writed, to teleport the player to another location and even in another room.
Let's have a simple example.
Add Theo the wizard as an action object (tile=202, id=1000, type=dynamic, class=action),
as you did in the previous chapter, and set him the folowing ActionObject callback:
As you can see, when he you try to talk to Theo, Dizzy is teleported up in the air, by substracting 64 pixels from it's current vertical coordinate.
It makes sense, because the top left corner of the world has the 0,0 coordinates.
This technique is very common and you can move Dizzy at any specified set of coordinates in the map.
Try choosing a position in the other room and see what happends.
It is important to know, that the player's horizontal coordinate (P_X) must be multiple of 4 pixels.
That is because, when moving left or right, the player has a 4 pixels step.
The vertical coordinate (P_Y) has no such restriction.
So take care of this thing, when you position the player in the map.
The player movement is a pretty complex system that is responsable for interpreting the user input,
like pressing the left, right or jump key, and animate and change Dizzy's position. It knows when Dizzy should stand on the ground,
when he can't walk through a solid wall, or when he must fall through the air.
The player's P_STATUS property keeps track of the player's movement state,
like when he is in the idle position (STATUS_IDLE),
or when he is walking (STATUS_WALK), jumping up (STATUS_JUMP)
or falling down (STATUS_FALL).
The STATUS_SCRIPTED value can be used to specify that the movement system should not update the player as usual,
because the script wants to do some specific things with it, like in a cutscene.
The player's movement system uses other properties as well, and it is also responsable for changing the player's
animated tile (P_TILE) to corespond to it's current state.
Note that the player's properties defines are named starting with P_ and not with O_ as those used for objects. Do NOT mix them,
because, in most cases, the defines values are different.
So, DON'T use PlayerGet(O_X) instead PlayerGet(P_X).
All this movement system is implemented by default in the game's engine, so you don't have to bother with it too much.
However, advenced users have the chance to implement the player's movement themselfs, in the script, were they can
customize it as their game requires. The default movement that is implemented in the engine is also implemented in the
scripts, as a starting point for further customizations. See the P_CUSTOMMOVE property.
In the player.gs file, there is a set of functions to help you with simple requests about
player's movement. For example, you can force the player in the jumping state, without pressing the jump key, only by setting the necessary properties.
You can learn more about these functions in the reference chapters and by inspecting their implementation.
Try the following thing on Theo's callback.
There are two kinds of collisions that the player can have with dynamic objects.
The first one can call a collision handler and from there, a collision callback,
where the developer can make the game react as needed, depending on the colliding object.
This can have a lot of uses, from killer phantoms or other enemies, to simple areas that can
trigger an event when entered, or walked through.
This is the collision handler that is called by the engine when the player collides with a dynamic brush that
has the O_COLLIDER property set to call handler.
It can detect if this is the first time when the collision happened,
if the collision is still going on, or if it has just ended.
By default, it also deals with hurt or kill class objects.
This latent callback is requested from the collision handler, when the player collides
with a collider object (set to call handler), that has the same brush id, as specified in the callback's name (ID).
If the MODE number, from the callback's name, is 0, then the callback is called when the player and the object exit from collision.
If MODE is 2, the callback is called during the collsion, and if it's 1, the callback is called when the player enters in collsion
with the object for the first time.
Let's see an example of a trigger area that hurts the player while he's inside it.
In this case, a trigger is an invisible dynamic object (with the id=1001, w=48, h=40, draw=0, collider=call handler) that
has the following colliding callback associated. Place it in the map, left of Theo.
Each game cycle the player stands inside it (in collision with it), the callback will be called and
it will take a bit of Dizzy's energy bar.
You can even warn the player, at the first moment he enters in the trigger:
The second kind of dynamic collision, is with objects that have the collider property set to hard collision
This is usual to platforms, elevators, bridges or other similar things that must move.
The collision is not too precise, but it will try to rise the player on top of these objects.
No handlers are called, it's all part of the player's movement system.
Add the little box item from the bottom right of the tile=212
Set it to be a pickable item (type=dynamic, id=100, class=item)
and set the collider property to hard collision
Place it on the map at the right side of the room and save the map.
In the script, set it's name to "A HARD BOX", run the game and have a little fun with it.
Play a little with the player's basic properties.
For example try to make him green (only) while he's inside the hurting trigger.
Or, make him roll over, from time to time, like he being drunk.
Use PlayerEnterSpin in the player's update handler,
HandlerPlayerUpdate and have a random condition and a random rolling direction
For more details about the player you can check the reference chapters:
Default Template player reference
Engine exported player's properties and functions