Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 3 of 3

Thread: rotate sprite

  1. #1
    Junior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    154

    rotate sprite

    Code :
    	glVertex3f(-5.0625f+cos(angle)*up+horizontal+space_two, 0.625f + sin(angle)*up + vertical + space, 0.0f);
    	glTexCoord3f(1.0f, 0.0f, 0.0f);
     
    	glVertex3f(-5.0625f + cos(angle)*up + horizontal + space_two, 0.5f + sin(angle)*up + vertical + space, 0.0f);
    	glTexCoord3f(1.0f, 1.0f, 0.0f);
     
    	glVertex3f(-4.9375f + cos(angle)*up + horizontal + space_two, 0.5f + sin(angle)*up + vertical + space, 0.0f);
    	glTexCoord3f(0.0f, 1.0f, 0.0f);
     
    	glVertex3f(-4.9375f + cos(angle)*up + horizontal + space_two, 0.625f + sin(angle)*up + vertical + space, 0.0f);
    here is the code for my bullet , I want to rotate the bullet around my plane sprite with the same place as my plane sprite is facing.

  2. #2
    Junior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    154
    can I please get some help

  3. #3
    Junior Member Regular Contributor
    Join Date
    Jan 2013
    Posts
    154
    well I have worked on my code, I am stuck on how to rotate the bullet sprite around the plane sprite
    Code :
    	glPushMatrix();
     
    	glBegin(GL_POLYGON);
    	glTexCoord3f(0.0f, 0.0f, 0.0f);
     
    	glVertex3f(-5.0625f*cos(angle) - 0.5f*sin(angle), -5.0625f*sin(angle) + 0.5f*cos(angle)+up, 0.0f);
    	glTexCoord3f(1.0f, 0.0f, 0.0f);
     
    	glVertex3f(-5.0625f*cos(angle) - 0.625f*sin(angle), -5.0625*sin(angle) + 0.625f*cos(angle)+up, 0.0f);
    	glTexCoord3f(1.0f, 1.0f, 0.0f);
     
    	glVertex3f(-4.9375f*cos(angle) - 0.625f*sin(angle), -4.9375f*sin(angle) + 0.625f*cos(angle)+up, 0.0f);
    	glTexCoord3f(0.0f, 1.0f, 0.0f);
     
    	glVertex3f(-4.9375f*cos(angle) - 0.5f*sin(angle), -4.9375*sin(angle) + 0.5f*cos(angle)+up, 0.0f);
    	glEnd();
     
    	glPopMatrix();

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •