Thread: Help with 2d OpenGL top-down shooter.

  1. #1
    Registered User
    Join Date
    Sep 2002
    Posts
    10

    Question Help with 2d OpenGL top-down shooter.

    Hi, I'm trying to make top-down shooter game with
    C/SDL/OpenGL

    http://w1.853.telia.com/~u85324201/game.zip

    The problem is that when you shoot, the bullets don't come from the plane but from somewhere from the middle of the screen.

    Here is the source:
    http://w1.853.telia.com/~u85324201/src.htm


    Could somebody help?

  2. #2
    Registered User xds4lx's Avatar
    Join Date
    Nov 2001
    Posts
    630
    I dont have time to compleatly read through your code, but are you updating the bullets position relative to where your plane is? I didnt see this occuring anywhere in your code but i only skimed it real fast beacuase im in class right now
    "only two things are infinite, the universe and human stupidity, and im not sure about the former." - albert einstein

  3. #3
    Registered User
    Join Date
    Sep 2002
    Posts
    10
    The bullet gets the planes position when you fire it.


    void fireBullet()

    {

    int i = getBullet();

    if (i != -1)
    {
    Bullet[i].Xpos = Xpos;

    Bullet[i].Ypos = Ypos;

    Bullet[i].Active = true;
    }

    }

  4. #4
    Registered User heat511's Avatar
    Join Date
    Dec 2001
    Posts
    169
    are you positive you're updating xpos and ypos everytime the ship moves?

  5. #5
    Registered User
    Join Date
    Sep 2002
    Posts
    10
    Xpos and Ypos are the planes position so
    they are updated or the plane don't move

    Like I said before the bullets gets the planes position once it's fired and then the bullets Ypos increases with 0.50 every frame.

    This bug is really weird...

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 16
    Last Post: 09-22-2006, 03:39 PM
  2. Why only 32x32? (OpenGL) [Please help]
    By Queatrix in forum Game Programming
    Replies: 2
    Last Post: 01-23-2006, 02:39 PM
  3. OpenGL Window
    By Morgul in forum Game Programming
    Replies: 1
    Last Post: 05-15-2005, 12:34 PM
  4. 2D Programming in OpenGL
    By guyver137 in forum Game Programming
    Replies: 2
    Last Post: 01-18-2003, 03:31 PM
  5. Stack functions as arrays instead of node pointers
    By sballew in forum C Programming
    Replies: 8
    Last Post: 12-04-2001, 11:13 AM