DIM firepoints
(100) AS xy
' ---> is the same as 30 different varibles for X, and for Y. Number in parentheses say you, which number it is. so ' firepoints(10).x is the same as x10, firepoints(10).y the same as y10, firepoints(1).time is the same as time1....
'set canon position
cannonX = 512
cannonY = 384
nextalien = 0
al = 0
makealien:
IF cx
< cannonX
+ 60 AND cx
> cannonX
- 60 AND cy
> cannonY
+ 60 AND cy
< cannonY
- 60 THEN GOTO makealien:
r = 15
'get angle between player and canon
angle
= _ATAN2(playerY
- cannonY
, playerX
- cannonX
)
'draw canon
LINE (cannonX
, cannonY
)-(cannonX
+ COS(angle
) * 50, cannonY
+ SIN(angle
) * 50)
'calculate points for fire (points in line between current cannon angle and last position. Let say, maximal fire lenght is 300 (calculating here is for 30 steps)
FOR calcFireRoute
= 1 TO 30 RouteLenght = 30 + (calcFireRoute * 20) '10 * 30 = 300
IF firepoints
(calcFireRoute
).x
= 0 THEN firepoints
(calcFireRoute
).x
= cannonX
+ COS(angle
) * RouteLenght
'calcFireRoute is just number. Number 1 to 30. So is this number is 1, you do X1 and Y1. If is 2, you do X2 and Y2....
IF firepoints
(calcFireRoute
).y
= 0 THEN firepoints
(calcFireRoute
).y
= cannonY
+ SIN(angle
) * RouteLenght
'is used the same principle as calculating for barrel
cannonX
= cannonX
+ COS(angle
) cannonY
= cannonY
+ SIN(angle
) position = position + 1
position = 1 'number in parenthesis is named "index". Maximal index number for array firepoints is 30. This number say us, which position is actual
'previous position must be set back to zero, for new calculating (see conditions in FOR NEXT loop)
firepoints(30).x = 0 'set first X to zero
firepoints(setZero).x = 0
firepoints(setZero).y = 0
'draw fire
CIRCLE (firepoints
(position
).x
, firepoints
(position
).y
), 10, &HFFFF0000 'fire color is red (FF = 255, it is &H ALPHA, RED, GREEN, BLUE), here is full ALPHA and full RED. How find, what is FF: Try PRINT VAL("&HFF") PAINT (firepoints
(position
).x
, firepoints
(position
).y
), &HFF506070, &HFFFF0000 IF cx
> firepoints
(position
).x
- 20 AND cx
< firepoints
(position
).x
+ 20 AND cy
> firepoints
(position
).y
- 20 AND cy
< firepoints
(position
).y
+ 20 THEN al
= 1: score
= score
+ 1: score$
= STR$(score
):
_TITLE score$
nextalien = 1
'draw player
'draw alien
IF al
= 0 THEN fillCircle cx
, cy
, r
, c
LINE (cx
- 5, cy
- 5)-(cx
- 3, cy
- 3), _RGB32(0, 0, 0), BF
LINE (cx
+ 5, cy
- 5)-(cx
+ 3, cy
- 3), _RGB32(0, 0, 0), BF
LINE (cx
- 5, cy
+ 7)-(cx
+ 5, cy
+ 5), _RGB32(0, 0, 0), BF
LINE (cx
- 5, cy
- 7)-(cx
- 10, cy
- 20), _RGB32(0, 255, 0) LINE (cx
+ 5, cy
- 7)-(cx
+ 10, cy
- 20), _RGB32(0, 255, 0)
'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