_TITLE "Plasma Laser Cannon demo" 'b+ 2020-11-11
newTarget
drawBall tx, ty, tr, tc
fcirc tx
, ty
, r
, _RGBA32(255, 255 - r
, 0, 10) newTarget
SUB PLC
(baseX
, baseY
, targetX
, targetY
, targetR
) ' PLC for PlasmaLaserCannon ta
= _ATAN2(targetY
- baseY
, targetX
- baseX
) ' angle of target to cannon base dist
= _HYPOT(targetY
- baseY
, targetX
- baseX
) ' distance cannon to target dr = targetR / dist
c = c + .3
fcirc x
, y
, dr
* r
, _RGB32(128 + 127 * SIN(r
* c
), 128 + 127 * SIN(g
* c
), 128 + 127 * SIN(b
* c
)) c = c + 1
fcirc x
, y
, rr
, _RGB32(128 + 127 * SIN(r
* c
), 128 + 127 * SIN(g
* c
), 128 + 127 * SIN(b
* c
))
f = 1 - rr / r
fcirc x
, y
, rr
, _RGB32(rred
* f
, grn
* f
, blu
* f
)
SUB drawShip
(x
, y
, colr
AS _UNSIGNED LONG) 'shipType collisions same as circle x, y radius = 30 fellipse x
, y
, 6, 15, _RGB32(r
, g
- 120, b
- 100) fellipse x
, y
, 18, 11, _RGB32(r
, g
- 60, b
- 50) fellipse x
, y
, 30, 7, _RGB32(r
, g
, b
) fcirc x
- 30 + 11 * light
+ ls
, y
, 1, _RGB32(ls
* 50, ls
* 50, ls
* 50) ls = ls + 1
w2 = xr * xr: h2 = yr * yr: h2w2 = h2 * w2
LINE (CX
- xr
, CY
)-(CX
+ xr
, CY
), C
, BF
y = y + 1
x
= SQR((h2w2
- y
* y
* w2
) \ h2
) LINE (CX
- x
, CY
+ y
)-(CX
+ x
, CY
+ y
), C
, BF
LINE (CX
- x
, CY
- y
)-(CX
+ x
, CY
- y
), C
, BF
'vince version fill circle x, y, radius, color
x0 = R: y0 = 0: e = 0
y0 = y0 + 1
LINE (x
- x0
, y
+ y0
)-(x
+ x0
, y
+ y0
), C
, BF
LINE (x
- x0
, y
- y0
)-(x
+ x0
, y
- y0
), C
, BF
e = e + 2 * y0
LINE (x
- y0
, y
- x0
)-(x
+ y0
, y
- x0
), C
, BF
LINE (x
- y0
, y
+ x0
)-(x
+ y0
, y
+ x0
), C
, BF
x0 = x0 - 1: e = e - 2 * x0
LINE (x
- R
, y
)-(x
+ R
, y
), C
, BF
'from Steve Gold standard
Radius
= ABS(R
): RadiusError
= -Radius: X
= Radius: Y
= 0 LINE (CX
- X
, CY
)-(CX
+ X
, CY
), C
, BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), C
, BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), C
, BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), C
, BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), C
, BF