Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / i need some help on some kind of line algorithym

Author
Message
DirkDiggler456
19
Years of Service
User Offline
Joined: 7th Jan 2003
Location:
Posted: 9th Jan 2003 03:11
okay so I have say 2 riflemen on opposite sides of the screen. Now I want to know how to get rifleman1's bullet to get to rifleman2 any where in the screen. I don't know if i explaned it right but a line from xy1 to xy2 would be fine except I want small pixel sprites to follow the same line path and to be able to intercept anything on it's flight. Some sort of code to fire a shot at any angle would be great. thank you.
comanighttrain
19
Years of Service
User Offline
Joined: 12th Jan 2003
Location:
Posted: 14th Jan 2003 01:34
Thats a tough one, id imagine that you would haveto store the bullets destination coordinates and make sure the bullet kept heading that way, you could use an array ie
y(n) x(n) for the coordinates and increment y and x everytime a bullet is fired(ie bullet(1) goes to x(1) and y(1) bullet(2) moves to x(2) and y(2) .....but if a game went on long enough you might end up with a problem when you ran out of numbers

Login to post a reply

Server time is: 2022-12-06 16:35:38
Your offset time is: 2022-12-06 16:35:38