gives the remainder when dividing, e.g. 20 mod 5 = 0 (because 5 goes evenly into 20). 6 mod 4 = 2 (because 4 goes into 6 once, with a remainder of 2).
instance_create_depth(x, y, depth, object)
function
spawns an object at an x and y position at a given depth. The greater the depth, the more 'underneath' things it will appear. Think of depth as a 'z axis' while you are learning. This function can also return the instance id of the object being spawned.
draw_set_color(colour)
function
sets colour for drawing. use the GM constant colours (e.g. c_lime, c_red, etc.
draw_text(x, y, string)
function
draws text at a location. use in a Draw event.
Sprite
Images
sprPerson
sprRock
You can drag and drop the sprRock.gif into GMS2 and it will translate the animation frames accordingly:
Object
Sprite
Properties
objRock
sprRock
Visible
objSpawner
no sprite
objPerson
sprPerson
Visible
No need to add any instances of objRock to the room, we will spawn these with the objSpawner object.
objPerson Step event:
switch (keyboard_key) {
case vk_left: hspeed = -5; break;
case vk_right: hspeed = +5; break;
case vk_nokey: hspeed = 0; break;
}
objRock Step event:
if place_meeting(x,y,objPerson){
image_speed = 1;
}
if (image_index == sprite_get_number(sprRock) - 1){
instance_destroy();
}