
-----------------------------------
Bored
Sun Mar 20, 2005 6:55 pm

Calculate angle between two points
-----------------------------------
Heres the deal. I have a two player version of a little space game here. I want to make a one player version by making the second player into an ai. I thought i'd go about it by fist having him chase you and try to shoot you and work my way from there. To hav him chase you he must be able to able to calculate the angle at which the other player is so he will know which way to travel. What i need from you guys is how to do this. Just for reference upwards is 0 degrees and the controls are 
P1: 
   Up=Forward
   Down=Backward
   Left=Turn Left
   Right=Turn Right
   Ctrl=Sharp Turn
   Shift=Shoot
   Enter=Change Weapon
P2: 
  W=Forward
   S=Backward
   A=Turn Left
   D=Turn Right
   E=Sharp Turn
   Tab=Shoot
   Q=Change Weapon

-----------------------------------
Mr. T
Sun Mar 20, 2005 7:09 pm


-----------------------------------
nice little game, i like the way the bullets bounce off the planet thing...
one way of fixing the game, would be by decreasing the amount of hits it takes to destroy the planet... it took me 5 minutes of firing to destroy one  :o

-----------------------------------
Cervantes
Sun Mar 20, 2005 7:16 pm


-----------------------------------
Behold! The wonders of zylum approach!


%credit: zylum
fcn GETANGLE (x1, y1, x2, y2 : real) : real
    var dx, dy, ratio, angle : real
    dx := x2 - x1
    dy := y2 - y1
    if dx not= 0 then
        ratio := dy / dx
    else
        ratio := dy / 0.00000001
    end if
    angle := arctand (abs (ratio))
    if dx < 0 then
        angle := 180 - angle
    end if
    if dy < 0 then
        angle := 360 - angle
    end if
    result angle
end GETANGLE


lol  :D

-----------------------------------
Bored
Sun Mar 20, 2005 7:53 pm


-----------------------------------
thx alot for the help crevetes and for pwned the game is sopposed to take a bit of time and thats why the bases are so hard to destroy

-----------------------------------
Mr. T
Sun Mar 20, 2005 8:15 pm


-----------------------------------
his name is cervantes

-----------------------------------
Mr. T
Sun Mar 20, 2005 8:15 pm


-----------------------------------
thx alot for the help crevetes...

his name is Cervantes  :roll:

-----------------------------------
[Gandalf]
Mon Mar 21, 2005 7:39 pm


-----------------------------------
:? spam?  I refreshed a few times, and it didn't go away..?

Cool game btw!  Hope to see it in the 'submissions' section soon. :D

-----------------------------------
amz_best
Sun Oct 19, 2014 5:45 pm

RE:Calculate angle between two points
-----------------------------------
Can you do a tutorial on how to make those bullets, explode?
