# glut game

• (6 Pages)
• • 1
• 2
• 3
• 4
• 5
• Last »

## 77 Replies - 5332 Views - Last Post: 19 August 2018 - 08:27 PMRate Topic:     //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'https://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=409011&amp;s=565085236ee396fe96120de458e9c0d1&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #31 andrewsw Reputation: 6833
• Posts: 28,342
• Joined: 12-December 12

## Re: glut game

Posted 08 February 2018 - 02:02 AM

```initialize num to 1 to 4
```

What is the intention of this? Typically you would initialize something to a single value, unless it is an array or some other structure: num doesn't suggest this.

Or maybe you want to repeat something 4 times?

```if mouse pointer is square selected
```

This is not clear. Is it a square? Or selected? Or a square has been selected?

## Re: glut game

Posted 08 February 2018 - 04:13 PM

well num is a random number from 1 to 4, this is the value for the initial computer player button.

## Re: glut game

Posted 08 February 2018 - 04:19 PM

the mouse selects the button that already been selected

## Re: glut game

Posted 10 February 2018 - 08:21 PM

here is my updated pseudocode
```computer turn off and on first square
player select square
if player selects square that computer selected turn off and on square
if player selects square that computer has not selected then end program
computer selects two squares and turn off and on both squares
if player selects two squares in proper sequence turn both off and on squares
computer selects three squares and turn off and on squares
if player selects three squares in proper sequence turn three off and on squares

```

this is mainly English statements.is this good for developing my computer and player interactions for my simon game?
I am going to turn these statements into more strict pseudocode.

## Re: glut game

Posted 11 February 2018 - 03:41 PM

well as promised here is my more strict pseudocode
```initialize random num from 1 to 4
initialize boolean flags to false
intialize flag to true
initialize rect to false
if rect is false
dim the square
else rect is true
brighten the square
player selects the square
if flag is true
dim the square
brighten the square
else flag is false
end program
computer selects two squares
dim the squares
brighten the squares
player selects the same two squares in previous order
if flags is true
dim the squares
brighten the squares
else flags are false
end program
etc...

```
let me know what you think

### #36 ndc85430 Reputation: 988
• Posts: 3,887
• Joined: 13-June 14

## Re: glut game

Posted 11 February 2018 - 11:36 PM

The question I had in post 30 still stands: if you initialise rect to false, why do you then need an if/else on lines 5 to 8? Is there code between those steps that you've missed out?

## Re: glut game

Posted 12 February 2018 - 02:52 PM

actually lines from 5 to 8 work well, I have problem with lines from 9 to 14, I have a problem with interactivity between the computer player and the human player. I am working on this problem as we post.

### #38 ndc85430 Reputation: 988
• Posts: 3,887
• Joined: 13-June 14

## Re: glut game

Posted 12 February 2018 - 11:57 PM

But surely the else branch is never executed, since rect is false.

## Re: glut game

Posted 13 February 2018 - 04:29 PM

can I get some input on lines from 9 to 14,that is what I am working on.

### #40 andrewsw Reputation: 6833
• Posts: 28,342
• Joined: 12-December 12

## Re: glut game

Posted 13 February 2018 - 04:42 PM

How would "player selects the square" affect the flag? Otherwise, the only mention of the flag before this is the fact that you've initialised it to false... so it will still be, and remain, false. This has already been pointed out but you've skipped it.

What are flags and flag? What are they flagging? Why is rect a boolean? (Is it some kind of rectangle?)

## Re: glut game

Posted 16 February 2018 - 06:54 PM

well I have subbed out some code for my game, I just wanted to get your opinion on what I have got so far.
```#include <iostream>
#include <time.h>

using namespace std;

int board = { 0 };
int flag = { 0 };
bool flag_one = false, flag_two = false, flag_three = false, flag_four = false;
int square = 0;

int main()
{
srand(time(NULL));
int num = rand() % 4 + 1;

if (num == 1)
{
flag_one = true;
cout << "Blink Yellow Square" << endl;
}
if (num == 2)
{
flag_two = true;
cout << "Blink Red Square" << endl;
}
if (num == 3)
{
flag_three = true;
cout << "Blink Blue Square" << endl;
}
if (num == 4)
{
flag_four = true;
cout << "Blink Green Square" << endl;
}

cout << "Select Yellow Square(1): " << endl;
cout << "Select Red Square(2): " << endl;
cout << "Select Blue Square(3): " << endl;
cout << "Select Green Square(4): " << endl;
cout << "Select Square(1-4): ";
cin >> square;
cout << endl;

if (flag_one && square == 1)
{
cout << "Blink Yellow Square" << endl;
}
if (flag_two && square == 2)
{
cout << "Blink Red Square" << endl;
}
if (flag_three && square == 3)
{
cout << "Blink Blue Square" << endl;
}
if (flag_four && square == 4)
{
cout << "Blink Green Square" << endl;
}
if (flag_one && square == 2)
{
cout << "Exit Program" << endl;
}
if (flag_one && square == 3)
{
cout << "Exit Program" << endl;
}
if (flag_one && square == 4)
{
cout << "Exit Program" << endl;
}
if (flag_two && square == 1)
{
cout << "Exit Program" << endl;
}
if (flag_two && square == 3)
{
cout << "Exit Program" << endl;
}
if (flag_two && square == 4)
{
cout << "Exit Program" << endl;
}
if (flag_three && square == 1)
{
cout << "Exit Program" << endl;
}
if (flag_three && square == 2)
{
cout << "Exit Program" << endl;
}
if (flag_three && square == 4)
{
cout << "Exit Program" << endl;
}
if (flag_four && square == 1)
{
cout << "Exit Program" << endl;
}
if (flag_four && square == 2)
{
cout << "Exit Program" << endl;
}
if (flag_four && square == 3)
{
cout << "Exit Program" << endl;
}

system("pause");
return 0;
}

```

I hope I didn't post too much code

## Re: glut game

Posted 17 February 2018 - 03:26 PM

can I please get some input, I am actually making some progress on my game.

### #43 modi123_1 • • Suitor #2
•    Reputation: 15493
• Posts: 62,050
• Joined: 12-June 08

## Re: glut game

Posted 17 February 2018 - 07:33 PM

Why wouldn't your 'if (num ==' statements be in a switch?
Why not store the sequence in an array or collection? It would handle more than one in a sequence.

## Re: glut game

Posted 17 February 2018 - 07:42 PM

why did you ding me again macosxnerd, I am trying my best code, I thought it would be easier if I stubbed out some code.

what should I store in an array?

### #45 modi123_1 • • Suitor #2
•    Reputation: 15493
• Posts: 62,050
• Joined: 12-June 08

## Re: glut game

Posted 17 February 2018 - 07:48 PM

This is Simon, right? The flashing lights game with four buttons? The last time I played it would show me, the player, a sequence of one to many flashing colors and I had to repeat it. It would follow to replicate that with using the 'random' you should store the randomly generated numbers (that correspond to the buttons) to be able to show the player the flashing as well as verify their input.

• (6 Pages)
• • 1
• 2
• 3
• 4
• 5
• Last »

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }