opengl game

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

49 Replies - 6803 Views - Last Post: 01 August 2018 - 02:18 PM Rate Topic: -----

#1 pbivens85   User is offline

  • D.I.C Addict

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

opengl game

Posted 22 June 2018 - 04:10 PM

void collision(int value)
{
	board[0][0] = 1;
	glutTimerFunc(1000, collision, 5);
}

void collision_one(int v)
{
	sprite[0][0] = 1;
	glutTimerFunc(1000, collision_one, 5);
}

void coll_bug_one()
{
	float x = -0.5f + scroll;
	float y = -8.0f + up;
	float oWidth = 0.5f;
	float oHeight = 0.5f;

	float xTwo = 0.0f;
	float yTwo = 9.0f;
	float oTwoWidth = 0.5f;
	float oTwoHeight = 0.5f;

	if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1)
	{
		glutTimerFunc(1000, collision_one, 5);
		flag[0][0] = 1;
		glutTimerFunc(1000, collision, 5);
	}
}

void collision_sprite()
{
	if (sprite[0][0] == 1)
	{
		collision_bug_one(0.0f, 10.0f);
	}
}

void coll_sprite()
{
	if (board[0][0] == 1)
	{
		flag[0][0] = 1;
	}
}

void erase_sprite()
{
	if (flag[0][0] == 1)
	{
		glColor3f(0.0f, 0.0f, 0.0f);
		glBegin(GL_POLYGON);
		glVertex3f(0.0f, 10.0f, 0.0f);
		glVertex3f(0.0f, 9.0f, 0.0f);
		glVertex3f(1.0f, 9.0f, 0.0f);
		glVertex3f(1.0f, 10.0f, 0.0f);
		glEnd();
	}
}

void drawScene() {
	glClear(GL_COLOR_BUFFER_BIT);
	drawScene_bug_one(0.0f, 10.0f);
	coll_bug_one();
	coll_sprite();
	erase_sprite();
	collision_sprite();
	bullet();
	drawScene_ship_one();
	glutSwapBuffers();
}


I have made some progress on my game. I am able to shoot a bug sprite and have it change to a collision sprite I just want this sprite to be blacked out after a second of time. I also am able to black out the bug sprite but not to draw the collision sprite. I have been working on this problem for a long time, I am doing my best to solve this problem.

Is This A Good Question/Topic? 0
  • +

Replies To: opengl game

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,007
  • Joined: 12-June 08

Re: opengl game

Posted 22 June 2018 - 05:48 PM

Also seen here.

Are you certain your 'if' statement is being reached?
Was This Post Helpful? 0
  • +
  • -

#3 pbivens85   User is offline

  • D.I.C Addict

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

Re: opengl game

Posted 22 June 2018 - 05:55 PM

which if are you referring to?
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,007
  • Joined: 12-June 08

Re: opengl game

Posted 22 June 2018 - 06:57 PM

The one where the collision is detected, and the sprite blacks out.
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: opengl game

Posted 23 June 2018 - 02:50 PM

well the if(flag[0]0]==1) on line 51 in my code
Was This Post Helpful? 0
  • +
  • -

#6 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12508
  • View blog
  • Posts: 45,642
  • Joined: 27-December 08

Re: opengl game

Posted 23 June 2018 - 04:19 PM

Yes. So per Modi's question, is that if statement being reached? If so, how do you know? If not, set some break points and run the debugger to figure out why not.
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: opengl game

Posted 23 June 2018 - 05:45 PM

well I checked and yes it is being reached, because I use the exit(0) command to see if the if is being executed and yes it is being reached.
Was This Post Helpful? 0
  • +
  • -

#8 ndc85430   User is online

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

Reputation: 956
  • View blog
  • Posts: 3,789
  • Joined: 13-June 14

Re: opengl game

Posted 23 June 2018 - 10:07 PM

What then does that tell you? Come on now, as you've been told many times before, the questions asked are meant to point you in the right direction. That means that you're supposed to use them to help you think about where the problem could be, not simply answer them and wait for someone to tell you what the next step is.

I dare say I know how this thread will end up...
Was This Post Helpful? 0
  • +
  • -

#9 andrewsw   User is offline

  • awks lol ffs
  • member icon

Reputation: 6693
  • View blog
  • Posts: 27,474
  • Joined: 12-December 12

Re: opengl game

Posted 24 June 2018 - 12:15 AM

Quote

I am able to shoot a bug sprite and have it change to a collision sprite I just want this sprite to be blacked out after a second of time.


Whereabouts in the code is a bug sprite changed to a collision sprite? Where is it blacked out and a timer introduced? Which code is running after a second and failing to black out the collision sprite?

That is, isolate, and tell us, at what point the code changes from working to not working.
Was This Post Helpful? 0
  • +
  • -

#10 pbivens85   User is offline

  • D.I.C Addict

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

Re: opengl game

Posted 24 June 2018 - 02:33 PM

well I finally solved my problem YEAH!!!!!!!!!! thanks for all the help!!!!!! maybe I can get an upvote for solving my problem!!!!!!!
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,007
  • Joined: 12-June 08

Re: opengl game

Posted 25 June 2018 - 05:09 AM

Perhaps explain, and show, what you fixed and why.
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: opengl game

Posted 25 June 2018 - 01:56 PM

well I simply used the sleep command.
void coll_bug_one()
{
	float x = -0.5f + scroll;
	float y = -8.0f + up;
	float oWidth = 0.5f;
	float oHeight = 0.5f;

	float xTwo = -2.0f;
	float yTwo = 9.0f;
	float oTwoWidth = 0.5f;
	float oTwoHeight = 0.5f;

	if (checkCollide(x, y, oWidth, oHeight, xTwo, yTwo, oTwoWidth, oTwoHeight) == 1)
	{
		collision_bug_one(-2.0f, 10.0f);
		Sleep(50);
		glutTimerFunc(25, collision, 5);
	}
}


Was This Post Helpful? 0
  • +
  • -

#13 pbivens85   User is offline

  • D.I.C Addict

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

Re: opengl game

Posted 27 June 2018 - 01:51 PM

can I get an upvote for actually solving my problem, even though it was a small fix.
Was This Post Helpful? 0
  • +
  • -

#14 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14761
  • View blog
  • Posts: 59,007
  • Joined: 12-June 08

Re: opengl game

Posted 27 June 2018 - 02:28 PM

Kudos for the fix. Why does sleep work there? What's it doing to make for an image to be shown?
Was This Post Helpful? 0
  • +
  • -

#15 pbivens85   User is offline

  • D.I.C Addict

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

Re: opengl game

Posted 27 June 2018 - 02:31 PM

well sleep works because it gives a pause for the collision sprite to be shown.
Was This Post Helpful? 0
  • +
  • -

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