How do I do a while loop for a turn based game

0 favourites
  • 10 posts
From the Asset Store
For Adventure, Action, Heroes, Sci-fi and Action-RPG games.
  • Having a hard time wrapping my ageing brain around this concept in the event system.

    So what I am trying to do is a simple memory game like Simon

    en.wikipedia.org/wiki/Simon_(game)

    Basically, the computer takes its turn, giving you a sequence to memorize, and then the player responds and attempts to duplicate. If the player is successful, the computer then repeats the sequence and adds one more step.

    I get that you can build an array, adding a random additional turn each time.

    What I am having a hard time figuring out is how do you confine things to turns within a loop.

    So

    Computer takes turn, blinks one of four boxes.

    Then we wait for player response

    If player is correct

    -computer repeats the original pattern, and adds one more, and then waits for the player.

    player takes his turn

    and so on

  • How about creating a statusvariable that will be comepare to a countvariable. So for example, if you expect the user to hit 4 button, have the count set to 4 ans increase the status by one, whenever the user hits the button. So you should be able to "create an event" to react to....

  • gazoogle,

    i'm sure others will better define the answer, but i don't think you need a classic loop to accomplish this. that's the beauty of the event system. you could simply cycle between the two; computer and player. with rules defining how they complete their turn.

    example...

    -setup array at beginning

    -setup variable for 'sequence' at beginning

    -computer add to 'sequence' random color

    -computer play 'sequence'

    -prompt player to copy 'sequence'

    -check if player 'sequence' matched computer sequence or not

    this is very vague pseudo code, but it should give you an idea of haw to proceed.

    hope it helps...

  • wrapped that up. Sorry no sound

    Simon.capx

    To answer your question, I believe that what you call a "while loop" in this case, is the game loop. Every tick, all the event are evaluatedYann2012-01-01 15:34:18

  • So Yann beat me to that <img src="smileys/smiley18.gif" border="0" align="middle">

    Anyhow, I compiled a tutorial for the "Simon" challenge...

    Tutorial

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Ok I added sound :D

    haha I'm wasting my time on it now :D

    http://dl.dropbox.com/u/23551572/C2-Games/Simon/index.html

  • Ok I added sound :D

    haha I'm wasting my time on it now :D

    <img src="smileys/smiley17.gif" border="0" align="middle" /> pffff...

    Very nice, especially the artwork. One can tell, that this is your profession

    <img src="smileys/smiley2.gif" border="0" align="middle" />

    <img src="smileys/smiley20.gif" border="0" align="middle" />

  • Well... I'm a 3D modeler in a game company :D... Soooo not my profession but I indeed went to artschool :D

    I'm sure you like the curves and the colors. Of course the design is all mine.

  • Thanks everyone for helping me grasp this.   <img src="smileys/smiley1.gif" border="0" align="middle" />

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)