Skip to content

Interactions

Raluca D. Gaina edited this page Feb 12, 2018 · 2 revisions

This section explains the InteractionSet section in the Game Description File. The InteractionSet section is responsible for defining the actions that happens when two sprites collides. The defined action affects the first object only. Interactions are written in the following way:

InteractionSet
    sprite_1 sprite_2 > interaction parameters

where sprite_1 and sprite_2 are two sprite objects defined in the sprite section, interaction is the action taken place over sprite_1 due to the collision followed by its parameters. At each interaction line scoreChanged parameter can be added which takes an integer number that add it to the current score. For example:

enemy bullet > killSprite scoreChange=1

This line says when an enemy collides with a bullet then kill the enemy and change the score by 1.

In multi player games, the score change must be specified for each player, for example, in a 2 player game, meaning first player gets 5 points, while the second's score remains unchanged:

enemy bullet > killSprite scoreChange=5,0

One last thing, the current VGDL Engine applies the interaction rules once per time tick. The following list contains all the supported interactions in the current GVG-AI Framework.

List of Interactions:

killSprite:

Description: Kill the first sprite.

killAll:

Description: Kills all sprites of a given type.
Properties:

  • stype: type of the sprite to kill. All sprites present in the game at this moment of this type are killed.

killIfHasMore:

Description: Kill the first sprite if it has a resource value larger than or equal to a certain limit.
Properties:

  • resource: The resource name used in checking.
  • limit: The limit which the resource is compared with.

killIfHasLess:

Description: Kill the first sprite if it has a resource value smaller than or equal to a certain limit.
Properties:

  • resource: The resource name used in checking.
  • limit: The limit which the resource is compared with.

killIfFromAbove:

Description: Kill the first sprite if the second object approached the first object from above (like in Super Mario).

killIfOtherHasMore:

Description: Kill the first sprite if the second object has a resource value larger than or equal to a certain limit.
Properties:

  • resource: The resource name used in checking.
  • limit: The limit which the resource is compared with.

transformToSingleton:

Description: It transform all sprites of stype to stype_other then create a new stype at the collision location.
Properties:

  • stype: The destroyed sprite name.
  • stype_other: The transformed sprite name.

spawnBehind:

Description: Create a new sprite behind the second sprite in the interaction. Properties:

  • stype: the spawned sprite name.

spawnIfHasMore:

Description: Create a new sprite if the first object has a resource value larger than or equal to a certain limit.
Properties:

  • stype: the spawned sprite name.
  • resource: the resource name used for checking.
  • limit: The limit which the resource is compared with.

spawnIfHasLess:

Description: Create a new sprite if the first object has a resource value smaller than or equal to a certain limit.
Properties:

  • stype: the spawned sprite name.
  • resource: the resource name used for checking.
  • limit: The limit which the resource is compared with.

cloneSprite:

Description: Clone the first sprite with same current parameters.

transformTo:

Description: change the first sprite into stype.
Properties:

  • stype: the target sprite name to be transformed to.
  • forceOrientation: forces an orientation copy from the initial sprite. Default is false.

transformIfCounts:

Description: change the first sprite into stype if there is a determined amount of sprites of stypeCount in the game.
Properties:

  • stype: the target sprite name to be transformed to.
  • stypeCount: the reference sprite to check the count.
  • geq: Condition "Greater or equal than" to check the amount of sprites of the reference type stypeCount. Default value is 0.
  • leq: Condition "Less or equal than" to check the amount of sprites of the reference type stypeCount. Default value is Game.MAX_SPRITES.

transformToRandomChild:

Description: variation of the transformTo effect which changes the first sprite into a random child of stype.
Properties:

  • stype: the target sprite parent name.

updateSpawnType:

Description: updates the spawn type of a SpawnPoint, to replace the second sprite in the interaction.
Properties:

  • stype: the new spawn type.
  • spawnPoint: the SpawnPoint which should receive the update.

removeScore:

Description: resets the score of the avatar to 0, if the first sprite in the interaction is an avatar. If an 'stype' is supplied, it resets that sprites score to 0, if it is an avatar.

  • stype: the avatar whose score should be reset.

addHealthPoints:

Description: adds health points to the first sprite in the interaction. If the value supplied added to the current number of health points would exceed the maximum number of health points, this interaction is ignored.

  • value: how many health points should be added.

addHealthPointsToMax:

Description: adds health points to the first sprite in the interaction. If the value supplied added to the current number of health points would exceed the maximum number of health points, the new number of health points is set to the maximum allowed.

  • value: how many health points should be added.

subtractHealthPoints:

Description: subtracts health points from the first sprite in the interaction. If an 'stype' is supplied, the health points are subtracted from that sprite instead.

  • value: how many health points should be subtracted.
  • stype: sprite from which health points should be subtracted. Default is 'null'.

increaseSpeedToAll:

Description: increase speed to all sprites of type 'stype' by the value specified.

  • value: how much the speed should be increased.
  • stype: sprite type whose speed should be increased.

decreaseSpeedToAll:

Description: decrease speed to all sprites of type 'stype' by the value specified.

  • value: how much the speed should be decreased.
  • stype: sprite type whose speed should be decreased.

setSpeedForAll:

Description: set the speed of all sprites of type 'stype' to the value specified.

  • value: new speed of the sprites.
  • stype: sprite type whose speed should be adjusted.

stepBack:

Description: undo the last movement of first sprite.

undoAll:

Description: undo all actions happened in the last time tick (not only the collided objects).


flipDirection:

Description: Change the first sprite orientation to a new random orientation.

reverseDirection:

Description: Reverse the first sprite orientation to the opposite direction.

attractGaze:

Description: Change the first sprite orientation to be equal to the second sprite orientation.

align:

Description: Change the first sprite's position and orientation to that of the second one.


turnAround:

Description: Reverse the first sprite direction to the opposite direction and change the sprite position to one tile below.

wrapAround:

Description: Wrap the first sprite around in the game screen.

teleportToExit:

Description: Teleport the first object to a certain sprite position defined in the second sprite (Second sprite should be Portal sprite). If the certain sprite is not found, it will kill the first sprite.

pullWithIt:

Description: Move the first sprite the same amount and direction like the second sprite (used for moving platforms).

bounceForward:

Description: Push the first sprite one step in same direction of the second sprite.


collectResource:

Description: Destroy the first object and change the resource value of the second sprite by the a certain amount (The first sprite must be of type Resource).

changeResource:

Description: Change the a certain resource value in the first sprite by a certain amount.
Properties:

  • resource: the resource name in the first object.
  • value: the amount of change to that resource.

Examples:

enemy missile > killSprite scoreChange=1

When an enemy sprite collided with a missile sprite, the enemy sprite will be destroyed and the score will be changed by 1.

avatar log    > pullWithIt

When an avatar sprite collides with a log sprite, both sprites will move in the same direction every update.

enemy wall    > reverseDirection

When an enemy sprite collides with a wall sprite, the enemy sprite will reverse its orientation.

weapon avatar   > collectResource scoreChange=2

When avatar B collides with a 'blue' type, update the spawn type 'blue' to 'blueB' in all SpawnPoints of type blockSpawn.

avatarB blue > updateSpawnType stype=blueB spawnPoint=blockSpawn

When a weapon sprite (weapon is a defined as Resource in the SpriteSet) collides with an avatar sprite, the weapon sprite will be destroyed and the avatar resource will be updated based on the weapon defined parameters.

Table of Contents:

Clone this wiki locally