So I'm pretty far into development of my new game and I am trying to figure out how to do a bullet that will look like it fires from a plane sprite I thought of a way it didn't work so I went back to my old code. I would appreciate if someone could help code a bullet.

I'll post my code only if asked for it.

Are you interested in the physics or its visual appreance? For the physics part, you can simply model the bulets by a vector that travels straight in its direction. But i'm not completely sure what exactly you need.

Are you having trouble with the bullet's trajectory or with its starting point? If its the trajectory (bullet path) don't forget to include the plane's direction/velocity/acceleration into the equation. If your problem is the bullet start point, make sure the bullet starts outside the collision detection spehere of your plane object.

you see the plane does not have any of that because its position is based on where the player moves the mouse.

You should know where the plane sprite is in space through the translations that have occurred. If you generate the bullet at the planes co-ordinates and then move it to the specified place to shoot from (i'm assuming the wing).

If the plane sprite is a 1X1 square for example assuming the middle of the plane is the (0,0) position. you could do something like.

bulletX = planeX - 0.5;
bulletY = planeY + 0.3;

That would be the start co-ordinate then just increase y axis (assuming your game is 2D) to have it travel forward.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.