» Uncategorized Posts

sprite_change_offset

Changes the x and y offset (origin) of the sprite asset loaded from the /sprites folder. Coordinates are relative to the (0,0) position being the upper left corner of the sprite. The following image illustrates this:

ArgumentTypeDescription
sprite:stringThe name of the sprite to change the offset of
xoff:realThe x position of the origin
yoff:realThe y position of the origin

Example, called from init.gml:

// changing offset of the jump sprite to [94, 138]:
sprite_change_offset( "jump", 94, 138 );
// making it precise:
sprite_change_collision_mask( "jump", true, 0, 0, 0, 0, 0, 0 );

sprite_get

Returns the unique index (real) of the sprite asset loaded from the /sprites folder.

ArgumentTypeDescription
sprite:stringThe name of the game asset to get the index of

Example, called from animation.gml:

if (state == PS_WALK) {
sprite_index = sprite_get( "dash" );
}

take_damage

Deals damage to the specified player.

ArgumentTypeDescription
damaged_player:realPlayer number of the player to damage
attacking_player:realAttacker's player number. Only used for stat tracking, and should be set to -1 if the damage is not from another player
damage:realThe damage to deal. Negative damage values will heal the player instead

Example, called from attack_update.gml:

// heals 10 damage to self:
if (attack == AT_NSPECIAL) {
if (window == 4 && window_timer > 30 && window_timer < 41) {
take_damage( player, -1, -1 );
}
}

set_player_damage

Sets the amount of damage for the specified player.

ArgumentTypeDescription
player:realID of the player to set the damage of
value:realThe value to set

Example, called from attack_update.gml:

// fully heals your character at the end of window 2:
if (window == 2 && window_timer == 200) {
set_player_damage( player, 0 );
}

get_player_damage

Returns the amount of damage the specified player has.

ArgumentTypeDescription
player:realID of the player to get the damage of

Example, called from update.gml:

// this character has higher gravity when over 100%:
if (get_player_damage( player ) >= 100) {
gravity_speed = 1.0;
} else {
gravity_speed = 0.5;
}