Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Turing Help for Making Simon Says Game
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
unicorn-ellie




PostPosted: Sat Dec 28, 2013 10:43 pm   Post subject: Turing Help for Making Simon Says Game

Hi, I'm an ICS student who is currently learning how to operate Turing.
I've been given a problem and I need to make a game that is a replica of Simon Says.

The problem:
Write a "Simon Says" game based on a flashing sequence of colour combinations (displayed on a colour wheel) that increase in difficulty by speeding up the sequence. The colour sequences will be random and the game will have 3 levels each of which will increase in difficulty based on the time interval between flashes as well as the number of colours displayed. The game will automatically reset if the user plays again.

I just want to know how to make the colours display in a colour wheel, make them flash and make them random based on the level.
I have tried variables and if statements, but I just don't know how to make it work.

Do I have to use arrays or something?

Any input or help would be greatly appreciated.

P.S: For those who do not know Simon Says, here is the link to the game: http://www.freegames.ws/games/kidsgames/simon/simon.htm
Sponsor
Sponsor
Sponsor
sponsor
DaBigOne




PostPosted: Sat Dec 28, 2013 11:00 pm   Post subject: RE:Turing Help for Making Simon Says Game

Array method:

var colours : array 1 .. 5 of int := init (1,2,3,4,5)
%you can choose your own colors

for i : 1 .. 5
drawfilloval (320, 200, 150, 150, Rand.Int (1, colours (i)))
end for

The non-array method:

for i : 1 .. 10
drawfilloval (320, 200, 150, 150, Rand.Int (1, i))
delay (50)
end for

I?m not really sure what you mean by ?flashing?. Are you talking about the speed of how long each colour is displayed?
unicorn-ellie




PostPosted: Sun Dec 29, 2013 3:55 pm   Post subject: Re: Turing Help for Making Simon Says Game

Ah, thank you so much for your help! I really appreciate it!

As for flashing, I'm talking about how long the colour flashes on screen.
So for example, for level 1, the flash of the colour would take 1 second and then the colour would reappear on screen again for user input.

If you are still confused, just tell me.
Once again, thank you for your help.
np_123




PostPosted: Sun Dec 29, 2013 5:30 pm   Post subject: RE:Turing Help for Making Simon Says Game

DaBigOne, using your 'array method' the likelihood of getting one of the 'desired colours' is low, unless unicorn-ellie plans on using the numbers 1-5 to specify the colour

Additionally, seeing as the pattern is to be repeated then added to each time, you will have to store the order of colours you use in a variable, preferably an array

Using Rand.Int will be able to give you the next colour to add to the sequence though

Suggestion:

code:


var colours : array 1 .. 5 of int := init (red, blue, green, yellow, black)
var pattern : array 1 .. 10 of int

for i : 1 .. 10
     pattern (i) := colours (Rand.Int (1,5))
end for

for count : 1 .. 10
    for i : 1 .. count
        drawfilloval (x, y, xradius, yradius, pattern (i))
    end for
end for



One array for your desired colours, one for your pattern
One counted loop to initialize your pattern
Nested counted loops to display the colours
And don't forget to add a delay

With that method you'd have to call a procedure from within the loop though, if you're gonna get user-input between displaying patterns
unicorn-ellie




PostPosted: Sun Dec 29, 2013 7:49 pm   Post subject: Re: Turing Help for Making Simon Says Game

Thank you for both of your help, np_123 and DaBigOne.

I have decided to go use DaBigOne's method and give it a try, as I am just getting used to/learning arrays.

However, when I try to make the colours appear on screen, then make them flash, after the flash, it appears as a different colour.
Is there a way to fix this?

This is the code I've done:

code:

 var colours : array 1 .. 9 of int := init (red, black, blue, yellow, green, magenta, gray, purple, brown)

for x : 1..2
    drawfilloval (200, 200, 50, 50, 0)
    delay (1000)
    drawfilloval (200, 200, 50, 50, Rand.Int (1, colours (x)))
    delay (1000)

    drawfilloval (450, 200, 50, 50, 0)
    delay (1000)
    drawfilloval (450, 200, 50, 50, Rand.Int (1, colours (x)))
    delay (1000)

    drawfilloval (320, 300, 50, 50, 0)
    delay (1000)
    drawfilloval (320, 300, 50, 50, Rand.Int (1, colours (x)))
    delay (1000)

    drawfilloval (320, 100, 50, 50, 0)
    delay (1000)
    drawfilloval (320, 100, 50, 50, Rand.Int (1, colours (x)))
    delay (1000)
end for


I just want to fix my mistakes here. If you could tell me where I went wrong, that would be great!
np_123




PostPosted: Sun Dec 29, 2013 9:03 pm   Post subject: RE:Turing Help for Making Simon Says Game

so when you say after the flash, do you mean for the second time it flashes?

the way your program would run:

the code in the 'for loop' runs twice

-the first time:
It draws a white circle
Draws a coloured circle using a *random* colour between 1 and 4

-the second time:
It draws the white circle overtop
Draws a coloured circle using a *random* colour between 1 and 7

Red is assigned the integer value 4
Black is assigned the integer value 7
Rand.Int chooses a random colour between the two values you put there

Because you are using Rand.Int to select a colour, it will most likely be a different colour each time you draw a circle
np_123




PostPosted: Sun Dec 29, 2013 9:17 pm   Post subject: RE:Turing Help for Making Simon Says Game

The easiest way to fix it would be to perform the random integer for the colours before the loop, and then assign the value to either 4 variables or an array.
Then use the declared colours in the for loop, and don't change their values.

Also, you should use choose each colour using

code:

colour1 := colours (Rand.Int (1,9))


Using like I mentioned, either 4 different variables for the different colours or an array
This will limit it to the colours you declared in your array
unicorn-ellie




PostPosted: Sun Dec 29, 2013 9:48 pm   Post subject: Re: Turing Help for Making Simon Says Game

Ah, thank you. The code works to how I want it now.
I think I was unclear in my last post, as I just needed the circles to flash once and then return back to their original colour.

The code below now works fine:
code:

var colours : array 1 .. 9 of int := init (red, black, blue, yellow, green, magenta, gray, purple, brown)
var colour1 := colours (Rand.Int (1, 9))
var colour2 := colours (Rand.Int (1, 9))
var colour3 := colours (Rand.Int (1, 9))
var colour4 := colours (Rand.Int (1, 9))

for x : 1 .. 2
    drawfilloval (200, 200, 50, 50, 0)
    delay (1000)
    drawfilloval (200, 200, 50, 50, colour1)
    delay (1000)

    drawfilloval (450, 200, 50, 50, 0)
    delay (1000)
    drawfilloval (450, 200, 50, 50, colour2)
    delay (1000)

    drawfilloval (320, 300, 50, 50, 0)
    delay (1000)
    drawfilloval (320, 300, 50, 50, colour3)
    delay (1000)

    drawfilloval (320, 100, 50, 50, 0)
    delay (1000)
    drawfilloval (320, 100, 50, 50, colour4)
    delay (1000)
end for


Now, is there a way to make the flashing of the circles random as well?

I'm sorry for the sudden question, but I realized that I also have to make the flashing random as well. Sorry for any inconvenience.

Once again, thank you np_123 and DaBigOne for your help. I really appreciate it.
Sponsor
Sponsor
Sponsor
sponsor
np_123




PostPosted: Sun Dec 29, 2013 10:27 pm   Post subject: RE:Turing Help for Making Simon Says Game

Combine Rand.Int and an array of procedures

Procedures would be responsible for drawing the circles, including your 'white' circle to show the flashing

Calling procedures from an array randomly would produce your random flashing

I suggest, if you don't know about procedures, look it up in either the Turing Documentation or perhaps search for a walkthrough in the Tutorial section
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 9 Posts ]
Jump to:   


Style:  
Search: