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

[SOLVED] Game won't restart

L

LunarIceCream

Guest
I was following the Shaun Spalding Platformer tutorial(part 7), and was at the part of having the game draw black bars when it restarted, but it wouldn't work, and this is what happened when I tried.

Before Pressing R, theres a 1 in the corner of the screen(debug).
After pressing R, the 1 has changed into a 0.01, and the beginning of the bars appear at the top and bottom, but the game doesn't restart, and nothing else changes if I press R again.

All the relevant code posted here.

Code:
///@desc Key Press - R
slidetrans(TRANS_MODE.RESTART);
Code:
/// @description 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));
Code:
/// @desc Size variables & mode setup

w = display_get_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;
target = room;
 

Joe Ellis

Member
I can't tell cus the slidetrans script code isn't shown, everything else makes sense but I don't know what slidetrans does when
TRANS_MODE.RESTART is passed into it
 
L

LunarIceCream

Guest
Slidetrans script
Code:
/// @desc SlideTransition(mode, targetroom)
/// @arg Mode sets transition between next, restart and goto.
/// @arg Target sets target room when using the goto mode.

with (oTransition)
{
    mode = argument[0];
    if (argument_count > 1) target = argument[1];
}
 
L

LunarIceCream

Guest
I don't really know what that means, but ignore the top part of that bit of code oof
 

Joe Ellis

Member
Oh i don't know sorry, its late here, it seems theres a few more scripts affecting the whole thing, to be honest, I don't like shaun spalding's stuff, that's not why I posted here, but I've seen a few people with problems with his code... Ideally, if your a good teacher, your students shouldn't have any problems, at least not to bring on the forums,

I dunno, I suggest go out on your own,

Theres alot of scripts depending on other scripts and you've no idea why other than being told that they're needed for the project to work,
if you don't know why they're needed, then you need to learn why, rather than using them, im sorry if that sounds offensive, but that is a pretty *placeholder* way of teaching about code, if you don't know what it does, learn why you don't know what it does. etc.
 
L

LunarIceCream

Guest
Imma clarify myself, I just didn't really get what you said xd
 

TheouAegis

Member
He's saying show the rest of the code, because the code blocks you posted here don't even have anything to do with restarting the room or going to another room. All I see is code dealing with drawing rectangles, although that's based on a variable percent which I don't even see getting modified to 0.1 anywhere in your code that you posted. That means you did not post all relevant code. Then again, you also said the black bars don't get drawn fully, which suggests that you don't even have code to complete the transition.
 
L

LunarIceCream

Guest
That's the problem, I don't know what IS relevant.
There's this,

Code:
if (mode != TRANS_MODE.OFF)
{
    if (mode == TRANS_MODE.INTRO)
    {
        percent = max(0,percent, - max((percent/10),0.005));
    }
    else
    {
        percent = min(1,percent, + max(((1 - percent)/10),0.005));
    }
    
    if (percent == 1) || (percent == 0)
    {
        switch (mode)
        {
            case TRANS_MODE.INTRO:
            {
                mode = TRANS_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;
            }
        }
    }
}
But I don't know how relevant it is.
 

Joe Ellis

Member
"I don't know what IS relevant." thats what I was saying, if you don't understand it, stop using it, your not gonna learn anything from it
 

TheouAegis

Member
- max((percent/10),0.005));
It's very relevant. You need to study the tutorials, not just try to copy them.

percent = max(0,percent, ??? -max((percent/10),0.005));

percent = min(1,percent, ??? + max(((1 - percent)/10),0.005));

I am guessing you don't want the commas after "percent" in those lines. Those lines are what make your transition an actual transition.
 
L

LunarIceCream

Guest
Oh, thanks, that solved it.
You need to study the tutorials, not just try to copy them.
And yeah, I sort of left the whole thing alone for a few months, so it would probably help to rewatch some of them later.

Thanks again!
 
Top