Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

loops not breaking

im having a simple problem that i cant find a solution to anywhere. i cant get any loops to end with break loop. i even made a new project to test diferent ways of doing it. i wanted to use it to display a map when the player hits action on an event. they press a button to erase the map picture. adter the picture was on the screen i went into a loop with a condition that if a button is pressed, erase picture and break the loop. seems simple enough, however, even in my other simplified tests, it still just freezes the game. i am experienced flash programmer and have used loops in several languages. i dont know why its not working. i even found tutorials tell me to do it this way but it doesnt work. im posting from my cellphone so i cant show screenshots or anything. sorry
 
Code:
loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Abort loop if screen is changed

      if Input.trigger?(Input::C)

        break

      end

    end

Did you do it this way? you need to update input in order to detect a button was pressed.
 
silver wind":3iy5trht said:
Code:
loop do

      # Update game screen

      Graphics.update

      # Update input information

      Input.update

      # Abort loop if screen is changed

      if Input.trigger?(Input::C)

        break

      end

    end

Did you do it this way? you need to update input in order to detect a button was pressed.
no i was talking about using the rpg maker xp commands. i used the loop command then a conditional branch in that loop with the condition being button press. under true, i put the loop break command and under else, i put nothing, or i ommit the else option. either way the game freezes even though im pressing the correct button.
 
Oh, sorry. It's weird though, I tried making a loop command too, it doesn't work what so ever. o.o
You know you can use parallel process instead ?

eventloop.png


On the 1st page simply switch A ON (set it to Action button).
 
i figured it out. it seems the loop is too fast to catch the button presses so i put a wait command in the beginning of the loop for 1 frame. it now works great. thanks for your efforts.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top