1945 game

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

47 Replies - 2175 Views - Last Post: 27 August 2018 - 09:06 PM Rate Topic: *---- 2 Votes

#1 pbivens85   User is offline

  • D.I.C Addict

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

1945 game

Posted 20 August 2018 - 01:58 PM

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);
	bullet();
	drawScene_plane_two();
	coll_plane_one();
	erase_sprite();
	drawScene_plane_one();
	glutSwapBuffers();
}



Is This A Good Question/Topic? 0
  • +

Replies To: 1945 game

#2 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,615
  • Joined: 12-June 08

Re: 1945 game

Posted 20 August 2018 - 02:01 PM

... Ok. so what is it doing now?

Seriously - you've been here for some years, have a large number of posts, but continue to do this. When will an actual question come with the topic? Maybe some explanation of what is actually going on. You know - the reoccurring questions folk have for your topics.
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: 1945 game

Posted 20 August 2018 - 02:21 PM

well I am able to get my plane sprite to shoot a bullet sprite at an enemy plane sprite. when the bullet hits the plane it draws a collision sprite which is an explosion sprite and then it redraws the plane sprite again which I don't want. I want to black out the collision sprite. according to my code when my collision detection is true I draw a collision sprite and then use sleep to make a small delay to show the collision sprite.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,615
  • Joined: 12-June 08

Re: 1945 game

Posted 20 August 2018 - 02:30 PM

Seems if you are having an issue drawing your plane, where ever that happens, too much then you would want to look at stopping that from happening with what ever condition is met.
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: 1945 game

Posted 20 August 2018 - 07:20 PM

is there anyway I can turn off drawing my plane I need to adjust this section of code
void drawScene()
{
	glClear(GL_COLOR_BUFFER_BIT);
	bullet();
	drawScene_plane_two();
	coll_plane_one();
	erase_sprite();
	drawScene_plane_one();
	glutSwapBuffers();
}


This post has been edited by pbivens85: 20 August 2018 - 07:21 PM

Was This Post Helpful? 0
  • +
  • -

#6 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,615
  • Joined: 12-June 08

Re: 1945 game

Posted 20 August 2018 - 08:49 PM

I would imagine a basic IF statement should do the trick.
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: 1945 game

Posted 21 August 2018 - 02:16 PM

where should I place the if statement?
Was This Post Helpful? 0
  • +
  • -

#8 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,615
  • Joined: 12-June 08

Re: 1945 game

Posted 21 August 2018 - 02:21 PM

You tell me.. Would it make sense to put it around the thing you want to conditionally have happen or not?
Was This Post Helpful? 0
  • +
  • -

#9 pbivens85   User is offline

  • D.I.C Addict

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

Re: 1945 game

Posted 21 August 2018 - 02:38 PM

ha ha your going to make me think :sweatdrop:
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: 1945 game

Posted 21 August 2018 - 05:32 PM

well I have made some progress. here is my code so far.
void collision(int value)
{
	glutPostRedisplay();
	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)
	{
		sprite[0][0] = 1;
	}
}

void erase_sprite()
{
		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);
	bullet();
	drawScene_plane_two();
	coll_plane_one();
	if (sprite[0][0] == 1)
	{
	drawScene_collision_one(-7.5f, 10.0f);
	glutPostRedisplay();
	glutTimerFunc(1000, collision, 5);
	erase_sprite();
	}
	drawScene_plane_one();
	glutSwapBuffers();
}


when I take out the erase_sprite() function it draws a collision sprite but does not black out the sprite, if I put erase_sprite() function back in it blacks out the sprite but does not draw the collision sprite. my problem is in the erase_sprite() function.
Was This Post Helpful? 0
  • +
  • -

#11 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,615
  • Joined: 12-June 08

Re: 1945 game

Posted 21 August 2018 - 10:00 PM

Why would you think the issue is the 'erase sprite'?
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: 1945 game

Posted 22 August 2018 - 01:56 PM

because the erase_sprite() function blacks out the sprite without drawing the collision sprite.
Was This Post Helpful? 0
  • +
  • -

#13 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 14929
  • View blog
  • Posts: 59,615
  • Joined: 12-June 08

Re: 1945 game

Posted 22 August 2018 - 02:03 PM

Are you sure it is not drawing _OVER_ the collision?
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: 1945 game

Posted 22 August 2018 - 02:12 PM

good point I think I am drawing over the collision. is there anyway I can draw the collision sprite before I draw over the collision sprite.
Was This Post Helpful? 0
  • +
  • -

#15 macosxnerd101   User is online

  • Games, Graphs, and Auctions
  • member icon




Reputation: 12566
  • View blog
  • Posts: 45,688
  • Joined: 27-December 08

Re: 1945 game

Posted 22 August 2018 - 02:16 PM

Think about that logic a little bit. You are proposing drawing the collision sprite, then drawing over the collision sprite. Based on modi123_1's last post, does your proposal make sense? Justify your answer.
Was This Post Helpful? 1
  • +
  • -

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