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.

Moving Images by Keystroke

Want I am trying to do is get a map in my game which can be scrolled through by keystrokes. I tried doing it all in Common Events and made Conditional Branches such as Button Left do a Move Picture event. It works perfectly but only moves once. Is it possible for the movement to work again and again to pan around ??? I need help please.
 
A script isn't necessary.  Start with a couple of variables to store the X and Y of the center of the map.  Then, start a "Loop...End Loop" segment.  Inside, have your four conditionals that check for a direction pressed, but instead of moving the image when a key is pressed, change the X or Y value in the variables that represent your picture's coordinates.  So, if the user presses the right arrow, subtract 1 from X (remember, you're scrolling, so you need to think in the opposite direction of what would seem normal).  Then after the four conditionals, but still inside the loop, have the picture move to the X and Y variables in reference to the center point.  Add a "Wait 1 Frame" statement just before the end of the loop so it doesn't hang up on you.  You can also add additional waits if it scrolls too fast.  Lastly, have a conditional to check for the action key ('C') being pressed, and when it is, you should delete the picture and jump to a label outside of the loop so the player isn't stuck forever.

With this method, you can also check when the variables reach certain limits (like, the edges of the screen) and either stop the player from scrolling further or have it wrap to the other side.
 

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