Advertisement

Help Me: Display the object in the right place

Started by January 10, 2000 11:45 AM
2 comments, last by BenB 25 years ago
Hello! I am making a spaceship game. I have maked so far that when the user click on the arrows, the stars are moving according to the direction. There is also the X & Y (In the Galaxy, not in the screen) of the spaceship. So how can I put another spaceship, enemy spaceship, that will move also according to the direction, and it will have also (galaxy) x & Y? I hope you have understanded what my problem is, if not, please tell me what you didn''t understanded.... Thanks!!!
quote:
Original post by BenB

Hello!
I am making a spaceship game. I have maked so far that when the user click on the arrows, the stars are moving according to the direction. There is also the X & Y (In the Galaxy, not in the screen) of the spaceship. So how can I put another spaceship, enemy spaceship, that will move also according to the direction, and it will have also (galaxy) x & Y?
I hope you have understanded what my problem is, if not, please tell me what you didn''t understanded....
Thanks!!!



I''m not sure what exactly yo uare saying, but if you are talking about making an enemy AI of a spaceship that just goes straight towards the users spaceship, try making the enemy spaceship (EX & EY) move according to the users spaceship (UX & UY) so if you were coding in C++, a very simple thing would be

while(EY < UY)
EY = EY + 1 (or 2 or whatever, depends on speed)
while(EY > UY)
EY = EY - 1

and im assuming you always have the spaceship coming towards the users ship in a side-scrolling fashion so you wouldnt need to change the EX in anyway since it will have a set speed hope that helps if it doesnt, and i didnt even come close to what you were tlaking about, email me


If I only had a nickle for every problem I''ve had, I wouldn''t have anymore problems, but then I guess I wouldn''t have anymore nickles either...
If I only had a nickle for every problem I''ve had, I wouldn''t have anymore problems, but then I guess I wouldn''t have anymore nickles either...
Advertisement
Well, all I want to do is very simple, I just didn''t explain it good.
All I want is the enemy not to move, and stay in his place forever(of course I will change it later, this is only for testing). So if I''m near him, for example, and I move right, he need to move left (on the screen) right? And when I move more right, I will not see him rihgt? That what I want to do!
Thank you...
You will want to render the enemy at a position relative to your own ship. If your ship is at (X,Y) and the enemies is at (EX,EY) in the world, you''ll want to take the difference (EX-X, EY-Y) and then add the position of your ship on the screen (CX,CY) then you''ll have the enemies coordinates on the screen (EX-X+CX,EY-Y+CY).

This topic is closed to new replies.

Advertisement