Ooops
January 26, 2021, 06:26:07 AM

### Author Topic: [bb] Homing Missile Algorithm by Mr Brine [ 1+ years ago ]  (Read 402 times)

#### BlitzBot

• Jr. Member
• Posts: 1
##### [bb] Homing Missile Algorithm by Mr Brine [ 1+ years ago ]
« on: June 29, 2017, 12:28:41 AM »
Title : Homing Missile Algorithm
Author : Mr Brine
Posted : 1+ years ago

Description : See the example

Code :
Code: BlitzBasic
1. ; (c)oded by Mr Brine
2. ;
3.
4. Graphics 640, 480
5.
6. SetBuffer(BackBuffer())
7.
9.
10. Repeat
11.
12.         Cls
13.
14.         Text 0, 0, "* = your ship"
15.         Text 0, 12, "# = homing missile"
16.         Text 0, 24, "click the lmb to make homing missile home in on your ship"
17.         Text 0, 36, "press esc to quit"
18.
19.
20.         If(MouseHit(1)) CalcGrad(o, MouseX(), MouseY())
21.
22.         Text MouseX(), MouseY(), "*"
23.         Text ox, oy, "#"
24.
26.
27.         Flip
28.         VWait
29.
30. Until KeyHit(1)
31.
32.
33. ; ----------------------------------------------------------------------------------------------------
34.
35.
37.
38.         Field x#, y#
39.         Field xg#, yg#
40.         Field xd#, yd#
41.         Field ld#
42.
43. End Type
44.
45.
46.
48.
49.         oxd = newx - ox
50.         oyd = newy - oy
51.
52.         old = Sqr(oxd * oxd + oyd * oyd)
53.
54.         oxg = oxd / old
55.         oyg = oyd / old
56.
57. End Function
58.
59.
60.
62.
63.         ox = ox + oxg * speed
64.         oy = oy + oyg * speed
65.
66. End Function

Floyd(Posted 1+ years ago)

The uploaded code is broken. All the  characters are gone, e.g. ox has become ox.

Mr Brine(Posted 1+ years ago)

Thanks floyd, now fixed!

elseano(Posted 1+ years ago)

Thanks!

SimplePortal 2.3.6 © 2008-2014, SimplePortal