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.

symon says minigame

Hey everyone,

For my game, the Player gets trapped in quick-sand and needs to get out by moving in the direction of what the screen tells him to.
As an example, what I want is a text screen to come up for about 2 seconds saying something like, "up down up down right left down up" and wait for the player to repeat these movements in the same order they were given. The player has to get this right three times, each with a different set of move combinations. However if he/she fails to repeat the given set of directions, the screen flashes red, returns to the first set of move combinations, and gives the player two more chances to get the set right (making a total of three errors possible before the character dies).

how exactly would I go about doing this? 

Thanks in advance
 
Hmm... Sounds like you're going to need to use the conditional branch command. Instead of thinking about whether or not the player has moved there, think about whether the player has pressed the button.

So, you'd have something like this;

@>Button Input Processing [Variable X]
@>Conditional Branch: Variable [Variable X] < 0
  @>Conditional Branch: Up button is being pressed
    @>Control Variables: [Variable Y] += 1
  : Else
    @> Die
  : Branch End

The button input and the following conditional branch will check if the player is actually pressing a button. Then, it checks to see what button they're pressing.

Variable Y is like, a counter. You would then have another page based on the variable Y (value: one more than the previous page) with the same code, but for a different button.

Hope it helps :D
 
Hmmm... I can't seem to get it to work.....

here's what I wrote,

@>Button Input Processing [Variable X]
@>Conditional Branch: Variable [Variable X] < 0
  @>Conditional Branch: Up button is being pressed
    @>Control Variables: [Variable Y] += 1
  : Else
    @> Text: wrong
    @> Game over
  : Branch End

: Else

: Branch End

when I press "up" nothing happens, the same thing happens even when I press down or any other button. it just carries on as if the event never happened.
So I figured I'd write instead,

@>Button Input Processing [Variable X]
@>Conditional Branch: Variable [Variable X] < 0
  @>Conditional Branch: Up button is being pressed
    @>Control Variables: [Variable Y] += 1
  : Else
   
  : Branch End

: Else
    @> Text: wrong
    @> Game over
: Branch End

but it flashes the game over screen even when i press "up"

what am I doing wrong?

also, how would I have a text screen appear for only two seconds? (I'm new at scripting events so you'll have to forgive any obvious errors)
 
Well first of all, you should probably change this:
Code:
@>Conditional Branch: Variable [Variable X] < 0
To this:
Code:
@>Conditional Branch: Variable [Variable X] > 0
since the variable will never be less then 0 when it comes to button input processing. That is why you are getting the game over screen, because the variable is not meeting the condition of being less than zero. Re-use the first code, except change the second conditional branch's sign. So it should look something like this:
Code:
@>Button Input Processing [Variable X]
@>Conditional Branch: Variable [Variable X] > 0 <<<=====
  @>Conditional Branch: Up button is being pressed
    @>Control Variables: [Variable Y] += 1
  : Else
    @> Text: wrong
    @> Game over
  : Branch End

: Else

: Branch End
That should increase variable Y, which would allow you continue the chain of button pressing. (I also think you could just get rid of that first conditional branch, but if you want to keep it just keep it changed to the greater than condition) To make a chain of buttons, I would add another conditional branch before button confirmation conditional branch to decipher where the player is in the chain. So in other words:
Code:
@>Button Input Processing [Variable X]
@>Conditional Branch: Variable [Variable X] > 0
  @>Conditional Branch: Variable [Variable Y] == 0  <<<=====
    @>Conditional Branch: Up button is being pressed
      @>Control Variables: [Variable Y] += 1
    : Else
      @> Text: wrong
      @> Game over
    : Branch End
  : Else
    @>Conditional Branch: Variable [Variable Y] == 1  <<<=====
      @>Conditional Branch: Right button is being pressed
        @>Control Variables: [Variable Y] += 1
      : Else
        @> Text: wrong
        @> Game over
      : Branch End
    : Else

    : Branch End
  : Branch End
: Else

: Branch End
I added the second part of the chain in the else case of the first part of the chain which is not neccessary, but can help you organize your chains a little better. (Though there is probably a more efficient way to go about making the mini-game than this idea)

Also, you could have the text appear through a show picture command which would run in another parallel process event or a common event. Then you could just do wait for 20 frames and then erase picture.
 
Some of those Conditional Branches are redundant; Button Input Processing can make it even easier.
For example, you can replace this code:
Code:
@>Conditional Branch: Variable [Variable X] > 0
  @>Conditional Branch: Up button is being pressed
    ...
   : Branch End
 : Branch End

with:
Code:
@>Conditional Branch: Variable [Variable X] == 8
  ...
 : Branch End

Button Input Processing doesn't just check if a button is pressed, but also can tell you which button by saving it into a variable. A few values would be 2=down, 4=left, 6=right, and 8=up. You can check other button values by using "Right click->What's this?" This way, you don't need the "if _ key is pressed".
 

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