How do I do a while loop for a turn based game Forum Home > Construct 2 General > How do I....? |
Post Reply
|
| Author | |
Post Options
Quote Reply
Topic: How do I do a while loop for a turn based gamePosted: 01 Jan 2012 at 9:21am |
|
|
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 http://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 |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 9:40am |
|
|
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....
|
|
|
_____________________
You want help? Post your CAPX! virtus junxit mors non separabit |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 12:22pm |
|
|
@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... |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 1:15pm |
|
|
wrapped that up. Sorry no sound
http://dl.dropbox.com/u/23551572/C2/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 evaluated Edited by Yann - 01 Jan 2012 at 3:34pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 2:22pm |
|
|
So Yann beat me to that
Anyhow, I compiled a tutorial for the "Simon" challenge... Tutorial Edited by Weishaupt - 01 Jan 2012 at 2:23pm |
|
|
_____________________
You want help? Post your CAPX! virtus junxit mors non separabit |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 3:18pm |
|
|
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 Edited by Yann - 01 Jan 2012 at 3:37pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 3:42pm |
|
pffff...Very nice, especially the artwork. One can tell, that this is your profession ![]()
|
|
|
_____________________
You want help? Post your CAPX! virtus junxit mors non separabit |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 4:04pm |
|
|
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. |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 4:25pm |
|
![]() |
|
Post Options
Quote Reply
Posted: 01 Jan 2012 at 10:12pm |
|
|
Thanks everyone for helping me grasp this.
|
|
![]() |
|
Post Reply
|
| Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |