External Exam Download Resources Web Applications Games Recycle Bin

platform | invert gravity | gml

objPlayer Step

// ... using an inverted pickup object that
// is used once only, and destroys itself:

var i = instance_place(x,y,objInvertedPickup);
if (i != noone) {
    instance_destroy(i);
    grav = grav * -1;
    image_yscale = image_yscale * -1;
}

// ... could use any location or point of contact,
// such as an objInverted platform block on
// both top and bottom sides of inversion:

if place_meeting(x,y+1,objInverted) or
   place_meeting(x,y-1,objInverted)
{
    grav = grav * -1;
    image_yscale = image_yscale * -1;
}

// to enable jumping when upside down:

if(grav > 0){
    if (place_meeting(x, y+1, objBlock)) 
    and (keyboard_check(vk_up)) 
    { 
        vert = jump_speed;
    }
}

if(grav < 0){
    if (place_meeting(x, y-1, objBlock)) 
    and (keyboard_check(vk_up)) 
    { 
        vert = -jump_speed; 
    }
}