Classy Room Transition Automation!!!

Erm, well anyone who can read C style junk can see what I did here, I thought it was rather cleaver! Basically upon leaving the room, the player is moved then upon loading the room the player moves up till there is no longer a collision. As long as I have a solid surface under the area where I want the player to start, it should work like a charm. I should probably throw in some exception handling eventuially though for things like no solids and malicious Digimon attacks!

Intersect Room Boundary Event in obj_player

//exit room when leaving room
if x <= 0 {
if room_exists(room_previous(room)){
entry_num = -1
y = room_height
x -= sprite_width
room_goto_previous()
}
else{
x = xprevious
}
}
else if x >= room_width {
if room_exists(room_next(room)){
entry_num = 1
y = room_height
x += sprite_width
room_goto_next()
}
else{
x = xprevious
}
}

//reset the room after a deadly fall
if y >= room_height + sprite_height then room_restart()

Room Start Event in obj_player

//look for
if instance_exists(solid){
while(not place_free(x,y)){
y-=1
if y <= 0{
x += 1
y = room_height
if x >= room_width {
show_message(“This room is full of solids, that simply will not do, derp!”)
room_goto_previous()
}
}
}
}
else{
show_message(“oopse, this rooms empty… someone made a derp!”)
game_restart()
}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s