glut game

  • (6 Pages)
  • +
  • « First
  • 4
  • 5
  • 6

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

#76 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 13 August 2018 - 04:18 PM

I think my problem is that I don't have an excellent understanding of the glutTimerFunc function, I will do some research on this topic.
Was This Post Helpful? 0
  • +
  • -

#77 pbivens85   User is offline

  • D.I.C Addict

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

Re: glut game

Posted 19 August 2018 - 06:34 PM

well I have asked this question before but never got a clear answer. I am working on a 1945 plane game. I have got a bullet to hit a plane and then draw collision sprite but then it redraws the plane sprite again. I want it to black out the plane sprite after the collision sprite is drawn for a brief period of time. I am using the sleep function to make a small delay. here is the code I am working on.
void collision(int value)
{
//	flag[0][0] = 1;
	glutTimerFunc(1000, collision, 5);
}

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

	float xTwo = -7.5f;
	float yTwo = 9.0f + down;
	float oTwoWidth = 1.0f;
	float oTwoHeight = 1.5f;

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

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

void drawScene()
{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glMatrixMode(GL_MODELVIEW);
	glLoadIdentity();
	bullet();
	drawScene_plane_two();
	coll_plane_one();
	erase_sprite();
	drawScene_plane_one();
	glutSwapBuffers();
}


Was This Post Helpful? 0
  • +
  • -

#78 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 14859
  • View blog
  • Posts: 59,283
  • Joined: 12-June 08

Re: glut game

Posted 19 August 2018 - 08:27 PM

Start a new thread. This has been six pages of who-knows-what, endless bumps, and what evers.
Was This Post Helpful? 0
  • +
  • -

  • (6 Pages)
  • +
  • « First
  • 4
  • 5
  • 6