glut game

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

77 Replies - 5335 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=aee071eab9fba62acbe258047e523429&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

#1 pbivens85

Reputation: -13
• 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

Reputation: 6833
• Posts: 28,342
• 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.

#3 snoopy11

• Engineering ● Software

Reputation: 1556
• 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
brighten rectangle

Regards

#4 pbivens85

Reputation: -13
• 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.

#5 pbivens85

Reputation: -13
• 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

#6 pbivens85

Reputation: -13
• 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.

#7 pbivens85

Reputation: -13
• 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.

#8 pbivens85

Reputation: -13
• 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.

#9 ndc85430

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

Reputation: 990
• Posts: 3,887
• 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.

#10 andrewsw

Reputation: 6833
• Posts: 28,342
• 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.

#11 snoopy11

• Engineering ● Software

Reputation: 1556
• 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 ?

#12 pbivens85

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

Re: glut game

Posted 04 February 2018 - 02:25 PM

well I am 50 why do you ask?

#13 snoopy11

• Engineering ● Software

Reputation: 1556
• 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....

#14 pbivens85

Reputation: -13
• 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.

#15 snoopy11

• Engineering ● Software

Reputation: 1556
• 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...