glut game

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

77 Replies - 4236 Views - Last Post: 19 August 2018 - 08:27 PM Rate Topic: -----

#31 andrewsw   User is online

  • dependency injected
  • member icon

Reputation: 6668
  • View blog
  • Posts: 27,315
  • 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?
Was This Post Helpful? 0
  • +
  • -

#32 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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.
Was This Post Helpful? 0
  • +
  • -

#33 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

Re: glut game

Posted 08 February 2018 - 04:19 PM

the mouse selects the button that already been selected
Was This Post Helpful? 0
  • +
  • -

#34 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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.
Was This Post Helpful? 0
  • +
  • -

#35 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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
Was This Post Helpful? 0
  • +
  • -

#36 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 936
  • Posts: 3,751
  • 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?
Was This Post Helpful? 0
  • +
  • -

#37 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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.
Was This Post Helpful? 0
  • +
  • -

#38 ndc85430   User is offline

  • I think you'll find it's "Dr"
  • member icon

Reputation: 936
  • Posts: 3,751
  • 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.
Was This Post Helpful? 0
  • +
  • -

#39 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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.
Was This Post Helpful? 0
  • +
  • -

#40 andrewsw   User is online

  • dependency injected
  • member icon

Reputation: 6668
  • View blog
  • Posts: 27,315
  • 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?)
Was This Post Helpful? 0
  • +
  • -

#41 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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[2][2] = { 0 };
int flag[2][2] = { 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
Was This Post Helpful? 0
  • +
  • -

#42 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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.
Was This Post Helpful? -1
  • +
  • -

#43 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14693
  • View blog
  • Posts: 58,724
  • 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.
Was This Post Helpful? 0
  • +
  • -

#44 pbivens85   User is offline

  • D.I.C Addict

Reputation: -13
  • View blog
  • Posts: 507
  • Joined: 22-October 13

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?
Was This Post Helpful? 0
  • +
  • -

#45 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14693
  • View blog
  • Posts: 58,724
  • 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.
Was This Post Helpful? 1
  • +
  • -

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