glut game

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

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

#1 pbivens85   User is offline

  • D.I.C Addict

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

glut game

Posted 30 January 2018 - 06:54 PM

Well I have almost solved my problem. I have managed to get a rectangle to dim its color. I want to get it to undim its color as well. Basically I want a rectangle to dim and undim once. I have researched and google'd this problem a lot. I also have been working on this problem for a long period of time. I am using opengl(glut) and c++. here is some of the code I am working on.
void delay(int v)
{
	board[0][0] = 1;
	glutPostRedisplay();
	glutTimerFunc(1000, delay, 0);
}

void draw_button()
{
	if (board[0][0] == 1)
	{
		glColor3f(0.5f, 0.5f, 0.0f);
		glRectf(-90.0f, 90.0f, -10.0f, 10.0f);
		board[0][0] = 0;
	}
	if (board[0][1] == 1)
	{
		glColor3f(0.5f, 0.0f, 0.0f);
		glRectf(10.0f, 90.0f, 90.0f, 10.0f);
		board[0][1] = 0;
	}
	if (board[1][0] == 1)
	{
		glColor3f(0.0f, 0.5f, 0.0f);
		glRectf(-90.0f, -10.0f, -10.0f, -90.0f);
		board[1][0] = 0;
	}
	if (board[1][1] == 1)
	{
		glColor3f(0.0f, 0.0f, 0.5f);
		glRectf(10.0f, -10.0f, 90.0f, -90.0f);
		board[1][1] = 0;
	}
}

my problem is in the delay function. that is what dims the rectangle.

Is This A Good Question/Topic? 0
  • +

Replies To: glut game

#2 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6667
  • View blog
  • Posts: 27,299
  • Joined: 12-December 12

Re: glut game

Posted 30 January 2018 - 10:44 PM

"my problem is in the delay function."

What problem? What is your question? What happens? What have you tried? We've been here before, several times.

ask smart questions
Was This Post Helpful? 0
  • +
  • -

#3 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1554
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: glut game

Posted 31 January 2018 - 09:05 AM

well i suppose you are getting it to dim by setting board[0][0] to 1

it would be better to copy that code into your timer func then have some condition inside there like so

if some condition is met
dim the rectangle
else if rectangle already dimmed
brighten rectangle

Regards
Was This Post Helpful? 0
  • +
  • -

#4 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 31 January 2018 - 04:30 PM

thanks snoopy, I will try the if else structure.
Was This Post Helpful? 0
  • +
  • -

#5 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 01 February 2018 - 06:54 PM

thanks snoopy I tried the if./else structure and it works properly, here is the code I am using
void delay(int v)
{
	if (rect == false)
	{
		board[0][0] = 1;
		glColor3f(0.5f, 0.5f, 0.0f);
		glRectf(-90.0f, 90.0f, -10.0f, 10.0f);
		rect = true;
		glutPostRedisplay();
		glutTimerFunc(1000, delay, 0);
	}

	else if (rect == true)
	{
		board[0][0] = 0;
		glColor3f(1.0f, 1.0f, 0.0f);
		glRectf(-90.0f, 90.0f, -10.0f, 10.0f);
		rect = false;
		glutPostRedisplay();
	}
}


I have one small problem,when I select a rectangle it dims but does not undim.

This post has been edited by pbivens85: 01 February 2018 - 07:03 PM

Was This Post Helpful? 0
  • +
  • -

#6 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 01 February 2018 - 07:20 PM

I am so sorry but I have figured out my problem. I can actually solve problems. I am working hard and smart. thanks again snoopy.
Was This Post Helpful? 0
  • +
  • -

#7 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 02 February 2018 - 03:52 PM

I am so happy that I finally figured out my problem. next comes doing the AI for my game, this will be quite a challenge.
Was This Post Helpful? 0
  • +
  • -

#8 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 03 February 2018 - 07:14 PM

if anybody cares I am making a simon game, I am working on the computer player, I am uncertain of how to proceed. I just need a little hint. I will work on my game more.
Was This Post Helpful? -1
  • +
  • -

#9 ndc85430   User is offline

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

Reputation: 934
  • View blog
  • Posts: 3,740
  • Joined: 13-June 14

Re: glut game

Posted 03 February 2018 - 10:48 PM

We've been here before, haven't we? You need to ask a specific question and show us what you've tried. There's not nearly enough detail in there for anyone to be able to help you.
Was This Post Helpful? 1
  • +
  • -

#10 andrewsw   User is offline

  • head thrashing
  • member icon

Reputation: 6667
  • View blog
  • Posts: 27,299
  • Joined: 12-December 12

Re: glut game

Posted 03 February 2018 - 11:50 PM

Yes, we have been here before many times.

I will repeat once more with emphasis. This forum is not the place for random updates. That's what a blog is for, or a personal diary. The forum is for asking "clear" questions.
Was This Post Helpful? 1
  • +
  • -

#11 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1554
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: glut game

Posted 04 February 2018 - 12:16 PM

To the OP can I ask what age you are ?
Was This Post Helpful? 0
  • +
  • -

#12 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 04 February 2018 - 02:25 PM

well I am 50 why do you ask?
Was This Post Helpful? 0
  • +
  • -

#13 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1554
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: glut game

Posted 04 February 2018 - 03:23 PM

Just wondered....

How long have you been programming for..?

Just trying to get a background picture of your abilities....

Makes a change from -1'ing you....:)
Was This Post Helpful? 0
  • +
  • -

#14 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 04 February 2018 - 03:33 PM

I am wondering if I am too old to be programming, at least with c++ and opengl.
Was This Post Helpful? 0
  • +
  • -

#15 snoopy11   User is offline

  • Engineering ● Software
  • member icon

Reputation: 1554
  • View blog
  • Posts: 4,930
  • Joined: 20-March 10

Re: glut game

Posted 04 February 2018 - 04:15 PM

No not at all long as you put the work in.... like anything else really but you really need to adopt a thinking outside the box mentality....

I will be 50 in November myself and often program in directx or OpenGL...

mind you I have also read a lot of different books on the subject over the years... :)
Was This Post Helpful? 0
  • +
  • -

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