Jump to content
IGNORED

Fire at a target without using divide? How did Missile Command do it?


wallaby
 Share

Recommended Posts

Hello!

 

I'm trying to make a projectile fire at a x / y location on the screen. Obviously, this is easy with a modern system and I'd normally use (pseudo code):

ProjectileVector = OriginXY - TargetXY
ProjectileVector.Normalize
MissileSpeed = ProjectileVector * MaximumSpeed

Normalizing the vector allows you to multiply it by your maximum missile speed and get set the proper X / Y velocity to strike the target.

 

What I'm doing now is:

 target_distance_x = (player3x - target_x)  / 4
 target_distance_y = (player3y - target_y)  / 4 

I'm using / 4 to get the projectile to follow a path based on my playfield resolution. player3 is my missile sprite. (Using DPC+)

 

This leaves me with, for example, target_distance_x = 5, target_distance_y = 3

 

Which is correct, but I can't just make those numbers my missile velocity because they're way too fast.

 

I don't how if it's possible to normalize target x and y (would need fixed point numbers and division) and if it is, you'd still need to multiply those by another number to get the right velocity.

 

If I divide the target_distance by 2 or 4 or whatever, the missile goes slower, but not to the right location. Rounding errors.

 

How did Missile Command aim missiles?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...