Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Eej

Ahh! Weapons again!

This topic is 5734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

In a Asteroids kinda game, I''m trying to make the weapon fire from the ship in the direction it is pointing. Unfortunately for me, pushing the button doesn''t exactly result in a weapon firing, was wondering if anyone could help debug.
  	glPushMatrix();
	weapon1[uint_loop].fp_xspeed = 0.1;
	weapon1[uint_loop].fp_deltavelocityx = cos(DEGTORAD * weapon1[uint_loop].fp_heading) * weapon1[uint_loop].fp_xspeed;
	weapon1[uint_loop].fp_deltavelocityy = sin(DEGTORAD * weapon1[uint_loop].fp_heading) * weapon1[uint_loop].fp_xspeed;   // Apply the change to the current velocity...

	weapon1[uint_loop].fp_velocityx += weapon1[uint_loop].fp_deltavelocityx;
	weapon1[uint_loop].fp_velocityy += weapon1[uint_loop].fp_deltavelocityy;
	
	weapon1[uint_loop].fp_x += weapon1[uint_loop].fp_velocityx;
	weapon1[uint_loop].fp_y += weapon1[uint_loop].fp_velocityy;
		
		glTranslatef(weapon1[uint_loop].fp_x,weapon1[uint_loop].fp_y,fp_z1);
	
//		}


	glRotatef(weapon1[uint_loop].fp_heading,0.0f,0.0f,1.0);
	
	glBegin(GL_QUADS);

	// Front Face

		glNormal3f( 0.0f, 0.0f, 0.4f);
		glVertex3f(-0.4f, -0.4f,  0.4f);
		glVertex3f( 0.4f, -0.4f,  0.4f);
		glVertex3f( 0.4f,  0.4f,  0.4f);
		glVertex3f(-0.4f,  0.4f,  0.4f);
		// Back Face

		glNormal3f( 0.0f, 0.0f,-0.4f);
		glVertex3f(-0.4f, -0.4f, -0.4f);
		glVertex3f(-0.4f,  0.4f, -0.4f);
		glVertex3f( 0.4f,  0.4f, -0.4f);
		glVertex3f( 0.4f, -0.4f, -0.4f);
		// Top Face

		glNormal3f( 0.0f, 0.4f, 0.0f);
		glVertex3f(-0.4f,  0.4f, -0.4f);
		glVertex3f(-0.4f,  0.4f,  0.4f);
		glVertex3f( 0.4f,  0.4f,  0.4f);
		glVertex3f( 0.4f,  0.4f, -0.4f);
		// Bottom Face

		glNormal3f( 0.0f,-0.4f, 0.0f);
		glVertex3f(-0.4f, -0.4f, -0.4f);
		glVertex3f( 0.4f, -0.4f, -0.4f);
		glVertex3f( 0.4f, -0.4f,  0.4f);
		glVertex3f(-0.4f, -0.4f,  0.4f);
		// Right face

		glNormal3f( 0.4f, 0.0f, 0.0f);
		glVertex3f( 0.4f, -0.4f, -0.4f);
		glVertex3f( 0.4f,  0.4f, -0.4f);
		glVertex3f( 0.4f,  0.4f,  0.4f);
		glVertex3f( 0.4f, -0.4f,  0.4f);
		// Left Face

		glNormal3f(-0.4f, 0.0f, 0.0f);
		glVertex3f(-0.4f, -0.4f, -0.4f);
		glVertex3f(-0.4f, -0.4f,  0.4f);
		glVertex3f(-0.4f,  0.4f,  0.4f);
		glVertex3f(-0.4f,  0.4f, -0.4f);
	glEnd();						

	if(boo_keys[VK_RETURN]){
			if (weapon1[uint_loop].fp_life<0.0f)					// If weapon1 Is Burned Out

			{
				weapon1[uint_loop].fp_life=2.0f;					// Give It New Life

				weapon1[uint_loop].fp_x=fp_x1;						// Center On X Axis

				weapon1[uint_loop].fp_y=fp_y1;						// Center On Y Axis

			}
	glPopMatrix();

	}  

Share this post


Link to post
Share on other sites
Advertisement
Check to make sure you''ve placed the firing function OUTSIDE of that big-assed loop. And hopefully you declared all the lives of all of the particles to < 0.0f (because you wont be firing anything if all their lives are defaulted to 0.0f).

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!