Jump to content
  • Advertisement

phil67rpg

Member
  • Content Count

    1506
  • Joined

  • Last visited

Community Reputation

448 Neutral

2 Followers

About phil67rpg

  • Rank
    Contributor

Personal Information

  • Role
    Programmer
  • Interests
    Programming

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. phil67rpg

    plane game

    this is my stubbed out code that draws a circle, I am doing this in order to understand more about rotations. #include <iostream> #include <math.h> #include <glut.h> using namespace std; float angle = 0.0f, point_x = 1.0f, rotate_x = 0.0f, point_y = 0.0f, rotate_y = 0.0f; float const PI = 3.1415925; void RenderScene(void) { glClear(GL_COLOR_BUFFER_BIT); glColor3f(1.0f, 1.0f, 1.0f); glBegin(GL_LINE_STRIP); glVertex3f(0.0f, 10.0f, 0.0f); glVertex3f(0.0f, -10.0f, 0.0f); glEnd(); glBegin(GL_LINE_STRIP); glVertex3f(-10.0f, 0.0f, 0.0f); glVertex3f(10.0f, 0.0f, 0.0f); glEnd(); glBegin(GL_POINTS); for (float angle = 0.0f; angle <= PI*2.0; angle += 0.001) { rotate_x = point_x*cos(angle) - point_y*sin(angle); rotate_y = point_x*sin(angle) + point_y*cos(angle); glVertex3f(rotate_x, rotate_y, 0.0f); } glEnd(); glutSwapBuffers(); } void SetupRC(void) { glOrtho(-10.0f, 10.0f, -10.0f, 10.0f, 1.0f, -1.0f); glClearColor(0.0f, 0.0f, 0.0f, 0.0f); } int main(int argc, char* argv[]) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(500, 300); glutInitWindowSize(800, 600); glutCreateWindow("Rotate"); glutDisplayFunc(RenderScene); SetupRC(); glutMainLoop(); return 0; }
  2. phil67rpg

    plane game

    I have stubbed out some code to help me understand how to rotate a point. #include <iostream> #include <math.h> using namespace std; float angle = 0.0f, point_x = 0.0f, rotate_x = 0.0f, point_y = 0.0f, rotate_y = 0.0f; int main() { cout << "Point X: "; cin >> point_x; cout << endl; cout << "Point Y: "; cin >> point_y; cout << endl; cout << "Angle(radians): "; cin >> angle; cout << endl; rotate_x = point_x*cos(angle) - point_y*sin(angle); rotate_y = point_x*sin(angle) + point_y*cos(angle); cout << "Rotate X: " << rotate_x << endl; cout << "Rotate Y: " << rotate_y << endl; system("pause"); return 0; }
  3. phil67rpg

    plane game

    I am using opengl c++ and soil, I have drawn two planes and have move around the screen using keys, I also have the first plane to shoot bullets, I am working on rotating the bullets around my plane sprite so that they shoot from wherever the plane is facing. rutin has been a lot of help. well rutin I am studying the linear algebra links you posted.
  4. phil67rpg

    plane game

    I have to work on this problem.
  5. phil67rpg

    plane game

    I am taking a class in linear algebra we are working with vectors, the distance formula is what you are talking about, the magnitude of a vector is what you are referring to.
  6. phil67rpg

    plane game

    thanks for the visual, this is how my sprite is reacting, I 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); know what I want it to do which is rotate around the blue square. in my code is where I am not rotating the sprite around its center, this is where I am having a problem. What you want is to rotate both together to maintain proper position and rotation by changing the center for the orange rectangle. You do this by having the orange rectangle rotate on the center point of the blue square:
  7. phil67rpg

    plane game

    can I get some input on my code, I have almost solved my problem I am still a little confused on rutins post.
  8. phil67rpg

    plane game

    here is the code for drawing my bullets glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, texture[2]); glPushMatrix(); if (angle == (3.0 * PI) / 2.0f) { space = -1.125f; } if (angle == PI / 2.0f) { space = 0.0f; } if (angle == PI) { space_two = 0.001f; } if (angle == 0.0f) { space_two = 0.0f; } glBegin(GL_POLYGON); glTexCoord3f(0.0f, 0.0f, 0.0f); 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); glEnd(); glPopMatrix(); glDisable(GL_TEXTURE_2D);
  9. phil67rpg

    plane game

    I will work on it. can I post some code?
  10. phil67rpg

    plane game

    well kind of, I am able to shoot bullets up and down left and right, I am unable to get the bullet to get drawn in front of the plane depending on what way the plane is heading.
  11. phil67rpg

    plane game

    https://imgur.com/a/TtLvTxX here is my screenshot
  12. phil67rpg

    2D Game Programmer Required

    what language and libraries are you using, I am good with c++ and opengl
  13. phil67rpg

    2D Game Programmer Required

    well what do you need help with?
  14. phil67rpg

    plane game

    well I have drawn two plane sprites and have them move around the screen using keys. one them can also shoot bullets, I have drawn an animated collision sprite
  15. phil67rpg

    shooting bullets

    well I finally solved my problem
  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!