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

Get help using Construct 2

Post » Sun Jan 01, 2012 9:21 am

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

B
34
S
4
G
8
Posts: 67
Reputation: 5,857

Post » Sun Jan 01, 2012 9:40 am

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....
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sun Jan 01, 2012 12:22 pm

@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...
B
52
S
17
G
15
Posts: 1,029
Reputation: 26,339

Post » Sun Jan 01, 2012 1:15 pm

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
Last edited by Yann on Sun Sep 14, 2014 10:43 am, edited 1 time in total.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jan 01, 2012 2:22 pm

So Yann beat me to that

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

TutorialWeishaupt2012-01-01 14:23:30
B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sun Jan 01, 2012 3:18 pm

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.htmlYann2012-01-01 15:37:56
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jan 01, 2012 3:42 pm

[QUOTE=Yann] Ok I added sound :D

haha I'm wasting my time on it now :D
[/QUOTE]

pffff...

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



B
42
S
19
G
12
Posts: 723
Reputation: 13,911

Post » Sun Jan 01, 2012 4:04 pm

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.
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Sun Jan 01, 2012 4:25 pm

New to Construct ? Where to start

Image Image
Image Image

Please attach a capx to any help request or bug report !
Moderator
B
247
S
85
G
40
Posts: 7,000
Reputation: 57,795

Post » Sun Jan 01, 2012 10:12 pm

Thanks everyone for helping me grasp this.   
B
34
S
4
G
8
Posts: 67
Reputation: 5,857

Next

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 19 guests