GM:S 1.4 Problems with changing rooms on pressing Enter

Discussion in 'Programming' started by Anti-Icarus, Jun 27, 2016.

  1. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    I'm having a problem with room transitions in a game I've been working on. First, I place a controller object in a room and programmed the End Step event so that it would go to the next room upon pressing the Enter key. I duplicated that room and the controller object with minor adjustments to the two so that it would do the exact same thing, except go straight into the game upon entering the third room. Just last night, I was able to go to a third room upon pressing the Enter key twice. But today, I get stuck in the second room. I haven't done anything wrong that would cause this problem. All I did today was create a new object, add a bit of extra code for my player character, and placed the new object in the third room I would be going to. I'm sure this was not the cause of the problem.

    The code I have written for the End Step events of the two controller objects in the first two rooms went like this:

    var progress = keyboard_check_pressed(vk_enter);

    if (progress)
    {
    room_goto
    (rm_controls [and rm_House_of_Worship]);
    }

    But I have changed that code to look like this when the problem started:

    if (keyboard_check_pressed(vk_enter))
    {
    room_goto
    (rm_controls [and rm_House_of_Worship]);
    }

    So far, nothings changed. Now what could be causing the End Step of the second room's controller object to stop working? Now, I noticed two suspicious things during my runs. The first thing was that every time I get stuck in the second room where the Enter key stopped working and closing out the build, the buttons that runs the game and debugs it have been blocked out. The second thing was that according to the compile log, the game is still entering the main loop even though it's been closed out. It's as if Game Maker thinks that the game is still running and the game somehow got stuck compiling the data during the loading process.
     

    Attached Files:

  2. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    510
    when it doesnt seem to close out that usually means there is something preventing the game from continuing onward from that point (like a misstyped while loop for example). you need to press the little orange button next to the debug button to quit .
    but as for the question youre asking, what exactly are you trying to do? im a bit confused on that part.
    my understanding: you want to press enter you want to go to next room then in that room go to the next room?
     
  3. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    Yes, that's exactly what I'm trying to do. I was able to do so without problems just last night. Now I can't today.
     
  4. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    510
    well the simple way would be to create a persistent object and in the step event
    do something like this
    Code:
    var progress = keyboard_check_pressed(vk_enter);
    if (progress)
    {
       switch(room)
       {
        case room1_name:
           room_goto(room2_name);
        break;
    
         case room2_name:
            room_goto(room3_name);
         break;
    
         case room3_name:
            room_goto(room4_name);
         break;
         //etc...
        }
    }
    this way it checks the current room you are in and then proceeds to the next.
     
  5. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    I just tried that format, changed the End Step event to the Step event, made it persistent, and so far it changed nothing. It's like that whenever I enter the second room, the game gets stuck in the main loop upon entering it. That certainly didn't happen last night. The only new things I've done today before running into this problem were adding a new sprite, creating an object that would replenish the player character's ammunition upon collision, give said object the new sprite, initializing the player's ammo limit to three in the Create event, and adding a while loop that checks whether or not the player character has at least three ammo left before running empty in the Step event (while (hwStock > 0 && hwStock <= 3) by putting the code that basically shoots bullets upon pressing the Ctrl key inside it.
     
  6. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    510
    ok then its gotta be the while loop thats causing the lock up.
    try taking that out and see if it still locks up.

    and replace it with
    Code:
    if ammo<maxamount
    {
       ammo++;
    }
    that will do the same thing with less stress on the system .
     
  7. Anti-Icarus

    Anti-Icarus Member

    Joined:
    Jun 21, 2016
    Posts:
    34
    I removed the while loop and it solved the lock up problem. After a bit of tweaking, I am now able to move up to two rooms upon entering the Enter key without problems while also setting the ammo limit for my player character. Your input has made a huge difference and for that, I thank you.
     
  8. Jakylgamer

    Jakylgamer Member

    Joined:
    Jun 27, 2016
    Posts:
    510
    no problem, glad to have helped :D
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice