'QB64 X 64 version 1.2 20180228/86 from git b301f92
'2018-07-28 translated from
'bomb.bas for SmallBASIC 0.12.2 [B+=MGA] 2016-05-09
'from explosion study
CONST max_particles
= 1000 CONST air_resistance
= .95
'main
NewDot i
rounds = 100
DrawSky
DrawGround
DrawBomb
DrawFuse i
LINE (0, 0)-(xmax
, ymax
), _RGB32(255, 255, 255), BF
FOR loop_count
= 0 TO 150 DrawSky
DrawGround
COLOR _RGB(64 - 8 * loop_count
, 40 - 4 * loop_count
, 32 - 4 * loop_count
) IF loop_count
< 8 THEN fcirc xmax
/ 2, ymax
/ 2, 30 * (1 - loop_count
* .25) dots(i).x = dots(i).x + dots(i).dx
dots(i).y = dots(i).y + dots(i).dy
IF RND < .2 AND rounds
> 10 AND dots
(i
).y
> ymax
/ 2 THEN dots
(i
).dx
= 0: dots
(i
).dy
= 0 dots(i).dx = dots(i).dx * air_resistance
IF dots
(i
).dy
<> 0 THEN dots
(i
).dy
= air_resistance
* dots
(i
).dy
+ .4 'air resistance and gravity LINE (dots
(i
).x
, dots
(i
).y
)-STEP(dots
(i
).size
, dots
(i
).size
), dots
(i
).kolor
, BF
fcirc dots(i).x, dots(i).y, dots(i).size / 2
IF rounds
< max_particles
THEN NewDot (rounds + i)
rounds = rounds + 100
dots
(i
).x
= xmax
/ 2 + RND * 30 * COS(angle
) dots
(i
).y
= ymax
/ 2 + RND * 30 * SIN(angle
) r
= RND 'STxAxTIC recommended for rounder spreads dots
(i
).dx
= r
* 45 * COS(angle
) dots
(i
).dy
= r
* 45 * SIN(angle
) dots
(i
).tf
= (RND * 2) \
1
cx = xmax / 2: cy = ymax / 2 - 70: radius = 10
fcirc cx, ymax / 2, i
FOR angle
= 0 TO 180 'fuse shaft x1
= cx
+ radius
* COS(rad_angle
) y1
= cy
+ radius
* .25 * SIN(rad_angle
) LINE (x1
, y1
)-STEP(0, 20), _RGB32(127 + 127 * COS(rad_angle
), 127 + 127 * COS(rad_angle
), 127 + 127 * COS(rad_angle
)) fEllipse cx, cy, radius, .25 * radius
cx = xmax / 2: cy = ymax / 2 - 70
LINE (cx
, cy
- (5 + 2 * length
))-STEP(2, 5), , BF
fcirc cx, cy - (1 + 2 * length), 2
x1
= cx
+ 7 * COS(rad_angle
): x2
= cx
+ 14 * COS(rad_angle
) y1
= cy
- (1 + 2 * length
) + 9 * SIN(rad_angle
): y2
= cy
- (1 + 2 * length
) + (RND * 13 + 9) * SIN(rad_angle
) y1
= 3 * .25 * SIN(rad_angle
)
LINE (0, i
)-STEP(xmax
, 0), _RGB32(0, 160 - 96 * (i
- ymax
/ 2) \
(ymax
/ 2), 0)
RadiusError = -subRadius
X = subRadius
Y = 0
' Draw the middle span here so we don't draw it twice in the main loop,
' which would be a problem with blending turned on.
LINE (CX
- X
, CY
)-(CX
+ X
, CY
), , BF
RadiusError = RadiusError + Y * 2 + 1
LINE (CX
- Y
, CY
- X
)-(CX
+ Y
, CY
- X
), , BF
LINE (CX
- Y
, CY
+ X
)-(CX
+ Y
, CY
+ X
), , BF
X = X - 1
RadiusError = RadiusError - X * 2
Y = Y + 1
LINE (CX
- X
, CY
- Y
)-(CX
+ X
, CY
- Y
), , BF
LINE (CX
- X
, CY
+ Y
)-(CX
+ X
, CY
+ Y
), , BF
scale = yRadius / xRadius
LINE (CX
, CY
- yRadius
)-(CX
, CY
+ yRadius
), , BF
y
= scale
* SQR(xRadius
* xRadius
- x
* x
) LINE (CX
+ x
, CY
- y
)-(CX
+ x
, CY
+ y
), , BF
LINE (CX
- x
, CY
- y
)-(CX
- x
, CY
+ y
), , BF