Advertisement

moving objects...

Started by February 15, 2000 07:39 PM
2 comments, last by ViPeR007 25 years ago
I have a question that concerns how you move objects, like a weapon''s bullet/pulse, around the world according to the player''s position. Like lets say the player is in a ship in the middle of the screen, it can go anywhere it wants (its not just limited to either left or right, or up and down). Now the ship doesn''t really have to be moved because it stays in the middle of the screen, but when you fire your weapon the weapon''s bullet does have to be moved. If you only move it with screen x/y''s then when you move to the right the image would move with you. Of course what you would want is when the player moves right the bullet would move left as well as in its current direction. This would simulate you moving away from the gun''s bullet. Now is there any way easier to do this than saying: if player_x++ then bullet_x--? And then tracking each bullet until it reaches a little past off screen. Thanx, ViPeR
I''m not sure if this is directly answering your question(I don''t quite understand it), but I think you want to know how you would move a bullet with your velocity + the bullets usual velocity. This would be done with vectors. You would take the velocity of your player, and find the coordinate/velocity of the bullet by adding it to the human''s vector. Hope that helped somewhat.
Advertisement
That is an easy one. First you must store a variable that is the players/camera world position. After that store your object, say your bullet, in another variable. These two objects will move seperately. When you want them drawn to the screen do this.

1. Draw world according to position
2. Draw (object - world_position)

Basically you subtract the objects position from the world. Hopefully that helped.
I thought moving it around the world coordinates would work too though I wasn''t sure. Now the only problem is figuring out how to do that with the methode Im using to scroll and create the world with (CDXMappy lib).

Thanx for your help,
ViPeR

This topic is closed to new replies.

Advertisement