Okay so i am started a project for a java class of mine, i would like to make the game simon, you know where there are four different colored buttons and it plays random sequences and you have to repeat them. I was thinking of using the random function, but i have never used it before. So if anyone can help me with any ideas, and if possible explain how i could use the random function in this case it would be greatly appreciated. Any help or ideas would be great? thanks

Recommended Answers

All 2 Replies

Being familiar with the Java API, available online here, is imperative if you plan to program any further in Java. Another fantastic resource is http://www.javadocexamples.com. This has most of the Java API with example code. For instance, if you had looked through that site, you would have found the Random class, with example code, here. Good luck.

You want game logic ideas?


Pseudo code:
const integer max_level = NN;

integer sequence[max_level];

for ( i = 1 to max_level) // for each level
{
for ( j = 0 to i) // get a random sequence length i
{
sequence[j] = random number 1-n for n buttons)
}
for ( j = 0 to i) // display goal sequence
{
show the user the sequence (flash the buttons?)
}
for ( j = 0 to i) // let user have a stab at it
{
get the user input for sequence[j]
compare it to sequence[j]
if(not correct input)
show failure message and break out of i loop

}
}

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.