side scrolling shoot-em up game
dude,
I''m trying to make a side scrolling shoot-em up game, so far I got a sprite A (player) and sprite B (enemy) on the screen (moving).
Can someone help me on how to calculate the x,y co-ordinate of a bullet fired by sprite B to hit sprite A.
My ideas is to get the x,y co-ordinate of both sprites when sprite B try to hit sprite A and use y=mx+c (a straight line equation) some how??
Also, any help on how to calculate a homing missle.
any help will be welcome, thanks dude..
GliTch
Use vectors, it greatly simplifies everything.
y=mx+c won''t work if the two object are right above/below each other for starters...
You need to decide how fast the bullets move, then you set the bullet''s initial position to the position of sprite A, and set the bullet''s direction vector equal to the sprite''s motion vector. Then every frame multiply the bullet''s velocity vector by the elapsed time and add it to it''s position.
Magmai Kai Holmlor
- Not For Rent
y=mx+c won''t work if the two object are right above/below each other for starters...
You need to decide how fast the bullets move, then you set the bullet''s initial position to the position of sprite A, and set the bullet''s direction vector equal to the sprite''s motion vector. Then every frame multiply the bullet''s velocity vector by the elapsed time and add it to it''s position.
Magmai Kai Holmlor
- Not For Rent
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement