Ooops
January 26, 2021, 06:26:07 AM
Welcome,
Guest
. Please
login
or
register
.
Did you miss your
activation email
?
1 Hour
1 Day
1 Week
1 Month
Forever
Login with username, password and session length
Home
Forum
Help
Search
Gallery
Login
Register
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Homing Missile Algorithm by Mr Brine [ 1+ years ago ]
« previous
next »
Print
Pages: [
1
]
Go Down
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
; (c)oded by Mr Brine
;
Graphics
640
,
480
SetBuffer
(
BackBuffer
(
)
)
Global
o.gradobj =
New
gradobj
Repeat
Cls
Text
0
,
0
,
"* = your ship"
Text
0
,
12
,
"# = homing missile"
Text
0
,
24
,
"click the lmb to make homing missile home in on your ship"
Text
0
,
36
,
"press esc to quit"
If
(
MouseHit
(
1
)
)
CalcGrad
(
o,
MouseX
(
)
,
MouseY
(
)
)
Text
MouseX
(
)
,
MouseY
(
)
,
"*"
Text
ox, oy,
"#"
AddGrad
(
o,
2
)
Flip
VWait
Until
KeyHit
(
1
)
; ----------------------------------------------------------------------------------------------------
Type
GradObj
Field
x#, y#
Field
xg#, yg#
Field
xd#, yd#
Field
ld#
End Type
Function
CalcGrad
(
o.GradObj, newx#, newy#
)
oxd = newx - ox
oyd = newy - oy
old =
Sqr
(
oxd * oxd + oyd * oyd
)
oxg = oxd / old
oyg = oyd / old
End Function
Function
AddGrad
(
o.GradObj, speed#
)
ox = ox + oxg * speed
oy = oy + oyg * speed
End Function
Comments :
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!
Logged
Print
Pages: [
1
]
Go Up
« previous
next »
SyntaxBomb - Indie Coders
»
Languages & Coding
»
Blitz Code Archives
»
Algorithms
»
[bb] Homing Missile Algorithm by Mr Brine [ 1+ years ago ]
SimplePortal 2.3.6 © 2008-2014, SimplePortal