• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Help with objects touching - Disappearing floor

J

Jmarlin3

Guest
The idea is that when the player is touching the floor, it turns red. However, when there are multiple floors, so if the player isn't touching it, I will go away.

Code for floor: Step Event
Code:
if !place_meeting(x,y,obj_player){
  instance_create_layer(x,y,4,obj_redfloor);   
    instance_destroy();
}
Code for redfloor: Step Event

Code:
if !place_meeting(x,y,obj_player)
{
    instance_create_layer(x,y,4,obj_wall)
    instance_destroy();
}
Code for player: Create
Code:
spd = 4;
Step Event:

Code:
move_up = keyboard_check(vk_up);
move_down = keyboard_check(vk_down);
move_left = keyboard_check(vk_left);
move_right = keyboard_check(vk_right);

xx = move_right - move_left;
yy = move_down - move_up;

hspd = xx*spd;
vspd = yy*spd;


if(place_meeting(x+hspd,y,obj_wall)){
    while(!place_meeting(x+sign(hspd),y,obj_wall)){
    x+= sign(hspd);
    
    }
    hspd = 0;
}
x += hspd;

if(place_meeting(x,y+vspd,obj_wall)){
    while(!place_meeting(x,y+sign(vspd),obj_wall)){
        y+=sign(vspd);
    }
    vspd = 0;
}
y += vspd;

Is there something I can do to where it doesn't go away until after the player has touched it? I didn't want to do a timer.


Thank you for the help.
 
K

Kai_Kai

Guest
Couldn't you use multiple sprites and have the wall alternate between them, rather than having two separate objects.

Your collision is only happening with the obj_wall not obj_redfloor.
 
J

Jmarlin3

Guest
Couldn't you use multiple sprites and have the wall alternate between them, rather than having two separate objects.

Your collision is only happening with the obj_wall not obj_redfloor.
Sorry I’m not entirely sure what you mean.
Your saying that when it’s touching switch to the sprite red, right? Then make it disappear? How would I make it switch?
 
J

Jmarlin3

Guest
Wait my bad, that was a dumb question. I figured it out.But wouldn’t the same issue still apply?
 
J

Jmarlin3

Guest
Couldn't you use multiple sprites and have the wall alternate between them, rather than having two separate objects.

Your collision is only happening with the obj_wall not obj_redfloor.
Also I don't want it to be with red floor, just wall
 
Top