• 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!

Windows Cant figure out GOTO/NEXT transitions (GML)

F

Fatality

Guest
Recently I've been working on a top down game and ive moved into working on screen transitions for my main way of moving between areas. I have figured a few parts out with the help of some YouTube videos and understand decent amounts of coding and have been using an enum with constants of an intro which draws a visual transition, a constant that moves me to the next room, and a constant that brings me to a specified room. former being the intro works properly but I'm having trouble with the latter. when using goto it gives me no errors, although I know it interacted due to the loss of movement as specified in my coding. My other problem originates in my next which allows me to move from the first to the second room but does not let me move to the third giving me a fatal error with not much description as far as I can tell

////oTransition
/// @desc Size variables and mode setup
w = display_get_gui_width();
h = display_get_gui_height();
h_half = h * 0.5;
enum TRANS_MODE
{
OFF,
Next,
GOTO,
RESTART,
INTRO
}
mode = TRANS_MODE.INTRO;
percent = 1.2;
target = room;

/// @desc Progress the transition
if (mode != TRANS_MODE.OFF)
{
if (mode == TRANS_MODE.INTRO)
{
percent = max(0,percent - max((percent/10),0.005));
}
else
{
percent = min(1.2,percent + min(((1.2 - percent)/10),0.005));
}
if (percent == 1.2;) || (percent == 0)
{
switch (mode)
{
case TRANS_MODE.INTRO:
{
mode = TRANAS_MODE.OFF;
break;
}
case TRANS_MODE.NEXT:
{
mode = TRANS_MODE.INTRO;
***room_goto_next();
break;
}
case TRANS_MODE.GOTO:
{
mode = TRANS_MODE.INTRO;
room_goto(target);
break;
}
case TRANS_MODE.RESTART:
{
game_restart();
break;
}
}
}
}

/// @desc Draw black bars
if (mode != TRANS_MODE.OFF)
{
draw_set_color(c_black);
draw_rectangle(0,0,w,percent*h_half,false);
draw_rectangle(0,h,w,h-(percent*h_half),false);
}
draw_set_color(c_white);
draw_text(50,50,string(percent));

////SlideTransition
/// @desc SlideTransition(mode, targetroom)
/// @arg mode sets transition mode between next, restart and goto
/// @arg Target sets target room when using the goto mode
with (oTransition)
{
mode = argument[0];
if (argument_count > 1) taget = argument[1];
}

////o player - Key press R
/// @desc Restart
SlideTransition(TRANS_MODE.RESTART)

//// oAreaMovement
/// @desc Move to next room
with (oPlayer)
{
if (hascontrol)
{
hascontrol = false;
***SlideTransition(TRANS_MODE.NEXT,other.target);
}
}

ive also tried this for direct movement

//// oAreaMovement
/// @desc Move to next room
with (oPlayer)
{
if (hascontrol)
{
hascontrol = false;
***SlideTransition(TRANS_MODE.GOTO,other.target);
}
}

ive set the target inside the specific objects for GOTO

three stars represent the lines that Ive been having trouble with
 

TheouAegis

Member
Did you fix the spelling of "taget" in slide_transition, too?

So room3 is placed below room2 in the Resource Tree, right? Because room_goto_next() functions based on the resource tree specifically. If you are in the very last room in the resource tree, even if you called it room0, it's still the last room in the game, so room_goto_next() won't work in it.
 
F

Fatality

Guest
yeah it goes rOne, rTwo, rThree in order. the transition from room one to two works but the third gives the a fatal error saying theres something wrong with the room_goto_next();
 

TheouAegis

Member
Post the actual error message.

It could also be an actual bug in frontend. But that would mean you would have to delete room 3 and then recreate it.
 
F

Fatality

Guest
I tried that and it still doesn't work. the fatal eror showed up again and idk whats wrong with it


___________________________________________
############################################################################################
FATAL ERROR in
action number 1
of Step Event0
for object oTransition:
Moving to next room after the last room.
at gml_Object_oTransition_Step_0 (line 26) - room_goto_next();
############################################################################################
--------------------------------------------------------------------------------------------
stack frame is
gml_Object_oTransition_Step_0 (line 26)

which is

room_goto_next();
 

FrostyCat

Redemption Seeker
If you stay on that "next room" state for too long, then you end up going to the "next" room over and over again until there are no more rooms.
 
F

Fatality

Guest
that's setup code for my collision event with the next line being break, where if I collide with the object It will overwrite the room im in with the next, so id imagine that itd only move one over every time I hit the object seeing how it does on the first collision right?


edit: ive been testing out my game as well as continue working on it in different areas and after creating a fourth room I realized that instead of going from my second room to my third room after hitting the transition area my code brought me to the fourth, I also tested this through removing the background which would show the overwritten rooms if they were drawn but it was even drawn in which case I believe that like FrostyCat said it repeated itself, any idea how this may have happened?
 
Last edited by a moderator:

TheouAegis

Member
You transitioned from room 2 to room 3 and immediately collided with the transition object again because you didn't position yourself in room 3 so that you were outside of the collision, so it immediately transitioned to room 4.
 
F

Fatality

Guest
the collision object should only be in room one where at the edge of the screen I collide with the player and start in the middle of the second, how do I hit it twice, I doubt its from the room, 2018-12-29 at 11.51.14 AM.png 2018-12-29 at 11.54.25 AM.png 2018-12-29 at 11.54.46 AM.png
 

TheouAegis

Member
Oh wait, you said the player's not persistent. lol

There's something wrong with room 3's code. Are you certain you don't have anything in room 3's creation code? And you're the transition object or whatever is handled with a collision in 3 room 3 and not in a step event? Or if it's in a step event, are you sure you didn't negate the collision check with ! before it?

I'm fishing for ideas here. lol
 
F

Fatality

Guest
other than the transition area at the end there is no creation code, and in the object I put target = room four; .

Edit: I figured it out, I put a transition object in every room for some reason instead of putting it in only the first making the transition object run twice. thank you TheouAegis for helping. also while testing this out my goto command always brings me back to the first room from my second when I have it set to the third and if I put a transition object it brings me to my first then my third, any idea why?
 
Last edited by a moderator:
Top