'The Dreadnaught Factor 64
'Clone 2018/10/29-13:10 Cobalt
'V0.1
'added title screen
'added startup data
'added player blaster shot
'
Engines
AS _BYTE 'Engines remaining 0-4 Vents
AS _BYTE 'Vents remaining 0-16 (0 explodes ship) Silos
AS _BYTE 'Silos remaining 0-5 Ships
AS _BYTE 'Dreadnaughts destroied Distance
AS _BYTE 'Dreadnaught Distance remaining Shipcount
AS _BYTE '1,1,2,5,10,15,100rem out '$include:'Dreadnaughts.txt'
CONST TRUE
= -1, FALSE
= NOT TRUE
, SPRITES
= 0, MASK
= 3, SHIP
= 4, COLLISION
= 8 CONST Shot
= 1, Bomb
= 2, SGun
= 3, LGun
= 4, STorp
= 5, LTorp
= 6, Trakr
= 7 CONST max
= 7, min
= 1, Stars
= 50
'INIT---------------------------------------
INITGame
'+++++++++++++++++++++++++++++++++++++++++++
TitleScreen
ShipStartdata
PlayerStartdata
LaunchScreen
'_SNDLOOP SFX(12)
'Start data
'END
LoadDreadnaughtlayout
DrawDreadNaughtBase SHIP
Star
(i%
).Xpos
= INT(RND * 640) Star
(i%
).Ypos
= INT(RND * 470) + 5
exitflag%% = TRUE
Controls 'arrow key processes
IF P.ShotsFired
THEN ProcessPlayerShots
movestarfield
drawstarfield
_PUTIMAGE (P.Xpos
, P.Ypos
- 136), Layer
(SHIP
), Layer
(2) DrawDreadnaught P.Xpos, P.Ypos - 136, 2
_PUTIMAGE (64, 226), Layer
(SPRITES
), Layer
(2), (0, 162)-(31, 175) 'player DrawPlayerShot 2 'draw shots to layer 2
ClearLayer 2
P.Xpos = P.Xpos - P.SpeedX
IF P.Xpos
<= -920 THEN UpdateShipDistance: LaunchScreen
P.Ypos = P.Ypos + P.SpeedY
IF P.Ypos
> 480 THEN P.Ypos
= 480: P.SpeedY
= 0 IF P.Ypos
< -720 THEN P.Ypos
= -720: P.SpeedY
= 0 Delta:
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0T
,0V
,0F,0A
,0A
,0I
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,0A
,0A
,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1V
,1V
,1U
,0A
data 00,00,00,00,00,00,00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1F,1A
,1A
,1A
,1A
,0A
data 00,00,00,00,00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1F,1A
,1A
,1A
,1A
,1A
,1A
,0A
data 00,00,00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1F,1A
,1A
,1A
,1A
,2T
,2V
,2U
,1A
,0A
data 00,00,00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1F,1A
,1A
,1A
,1A
,1A
,1A
,2A
,2A
,2A
,1A
,0A
data 00,00,00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1F,1A
,1A
,1A
,1A
,1A
,1A
,2T
,2F,2A
,2A
,2A
,1A
,0A
data 00,0T
,0F,0A
,0A
,0A
,0A
,0A
,1T
,1F,1A
,1A
,1A
,1A
,2T
,2A
,1A
,1A
,2A
,2A
,2A
,3T
,3A
,1A
,0A
data 0B
,0A
,0A
,0A
,0A
,0A
,0A
,1L
,1A
,1A
,1A
,1A
,1A
,2B
,3L
,3A
,1A
,1A
,2A
,2A
,3L
,3A
,3A
,1A
,0A
data 0C
,0A
,0A
,0A
,0A
,0A
,0A
,1M
,1A
,1A
,1A
,1A
,1A
,2C
,3M
,3A
,1A
,1A
,2A
,2A
,3M
,3A
,3A
,1A
,0A
data 00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1G
,1A
,1A
,1A
,1A
,2J
,2A
,1A
,1A
,2A
,2A
,2A
,3J
,3A
,1A
,0A
data 00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1G
,1A
,1A
,1A
,1A
,1A
,1A
,2J
,2G
,2A
,2A
,2A
,1A
,0A
data 00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1G
,1A
,1A
,1A
,1A
,1A
,1A
,2A
,2A
,2A
,1A
,0A
data 00,00,00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1G
,1A
,1A
,1A
,1A
,2J
,2W
,2K
,1A
,0A
data 00,00,00,00,00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1G
,1A
,1A
,1A
,1A
,1A
,1A
,0A
data 00,00,00,00,00,00,00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1G
,1A
,1A
,1A
,1A
,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,1J
,1W
,1W
,1K
,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,0A
,0A
,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0J
,0G
,0A
,0A
,0A
,0A
,0A
,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,0J
,0W
,0G
,0A
,0A
,0H
DeltaWepondry:
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2G
,00,00,0E
,0F,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2A
,00,00,00,00,1E
,1F,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2E
,00,00,0I
,0J
,00,00,00,00,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,2A
,00,00,0I
,0J
,00,00,00,0E
,0F,00,0A
data 00,00,00,00,00,00,00,00,00,00,00,2G
,00,00,0I
,0J
,00,00,2A
,00,00,1E
,1F,00,1A
data 00,00,00,00,00,00,00,00,00,2A
,00,00,0I
,0J
,00,00,0E
,0F,00,00,00,00,00,00,00 data 00,00,00,00,00,00,00,2E
,00,00,0I
,0J
,00,00,00,00,1E
,1F,00,00,2A
,00,0M
,00,00 data 00,00,00,00,00,2A
,00,00,0I
,0J
,00,00,00,00,2A
,00,00,00,00,00,2A
,00,1M
,00,0A
data 00,00,00,2A
,00,00,0I
,0J
,00,00,00,2A
,00,00,00,2C
,00,0M
,2A
,0I
,0J
,00,2C
,00,1A
data 00,2A
,00,0E
,0F,00,0M
,00,2A
,00,0E
,0F,00,00,00,0C
,00,1M
,2A
,00,00,00,0C
,00,00 data 00,2A
,00,1E
,1F,00,1M
,00,2A
,00,1E
,1F,00,00,00,1C
,00,0M
,2A
,00,00,00,1C
,00,00 data 00,00,00,2A
,00,00,0I
,0J
,00,00,00,2A
,00,00,00,2C
,00,1M
,2A
,0I
,0J
,00,2C
,00,0A
data 00,00,00,00,00,2A
,00,00,0I
,0J
,00,00,00,00,2A
,00,00,00,00,00,2A
,00,0M
,00,1A
data 00,00,00,00,00,00,00,2E
,00,00,0I
,0J
,00,00,00,00,0E
,0F,00,00,2A
,00,1M
,00,00 data 00,00,00,00,00,00,00,00,00,2A
,00,00,0I
,0J
,00,00,1E
,1F,00,00,00,00,00,00,00 data 00,00,00,00,00,00,00,00,00,00,00,2G
,00,00,0I
,0J
,00,00,2A
,00,00,0E
,0F,00,0A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,2A
,00,00,0I
,0J
,00,00,00,1E
,1F,00,1A
data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2E
,00,00,0I
,0J
,00,00,00,00,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2A
,00,00,00,00,0E
,0F,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,2G
,00,00,1E
,1F,00 data 00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00
test~&
= POINT(PS
(id%%
).Xpos
, PS
(id%%
).Ypos
) IF test~&
<> EmptySpace
THEN Result~&
= test~&
ELSE Result~&
= FALSE
CollisionTarget = Result~&
STATIC SlowFlag%%
, CoastFlag%%
, ShotLock%%
IF _KEYDOWN(18432) THEN P.SpeedY
= P.SpeedY
+ .25: CoastFlag%%
= FALSE
IF P.SpeedY
>= 4 THEN P.SpeedY
= 4
IF P.SpeedX
< .5 THEN P.SpeedX
= .5 IF P.SpeedX
> max
THEN P.SpeedX
= max
IF _KEYDOWN(20480) THEN P.SpeedY
= P.SpeedY
- .25: CoastFlag%%
= FALSE
IF P.SpeedY
<= -4 THEN P.SpeedY
= -4
P.SpeedX
= P.SpeedX
- .05:
IF P.SpeedX
< min
THEN P.SpeedX
= min: SlowFlag%%
= TRUE
IF NOT CoastFlag%%
THEN 'allow coast up and down P.SpeedY = P.SpeedY - .05
IF P.SpeedY
<= .2 THEN CoastFlag%%
= TRUE: P.SpeedY
= 0 P.SpeedY = P.SpeedY + .05
IF P.SpeedY
>= -.2 THEN CoastFlag%%
= TRUE: P.SpeedY
= 0
'shoot blaster
ShotLock%% = TRUE 'must release key to shoot again
P.ShotsFired = P.ShotsFired + 1
IF P.ShotsFired
< 3 THEN MakeShot P.ShotsFired
, Shot
ELSE P.ShotsFired
= 2 ShotLock%% = FALSE
' IF _FILEEXISTS("shotdebug.txt") THEN KILL "shotdebug.txt"
' OPEN "shotdebug.txt" FOR OUTPUT AS #2
' PRINT #2, ID~&
' PRINT #2, "---------------------"; S.Xsize * S.Ysize
IF ArmsID
(x%
, y%
) <> 0 THEN PRINT #2, ArmsID
(x%
, y%
); x%; y%
PRINT x%
, y%; ArmsID
(x%
, y%
), Arms
(x%
, y%
, 1) ArmsID(x%, y%) = EmptySpace
Arms(x%, y%, 1) = Arms(x%, y%, 1) + 1
PRINT x%
, y%; ArmsID
(x%
, y%
), Arms
(x%
, y%
, 1) ' CLOSE
SUB DrawDreadnaught
(Xloc%
, Yloc%
, LayerID%%
) 'find last tile to display
Endx%% = (640 - Xloc%) / 32
Endy%% = (400 - Yloc%) / 32
'range check keep values within array size(or dreadnaught data size)
IF Endx%%
> S.Xsize
THEN Endx%%
= S.Xsize
IF Endy%%
> S.Ysize
THEN Endy%%
= S.Ysize
'find first tile to display
Startx%% = (0 + Xloc%) / 32
Starty%% = (0 + Yloc%) / 32
'make sure value is always negative(-) otherwise start at 0
IF Startx%%
> 0 THEN Startx%%
= 0 IF Starty%%
> 0 THEN Starty%%
= 0 'fix negative value to positive, this means that portion is off screen so
'start at the + array location in other words don't bother with whats off
'screen
ClearLayer COLLISION
FOR y%
= Starty%%
TO Endy%%
FOR x%
= Startx%%
TO Endx%%
layer% = Arms(x%, y%, 0) + 4
xoff% = 32 * (Arms(x%, y%, 1) - 65)
XL% = Xloc% + x% * 32
YL% = Yloc% + y% * 32
'draw ship targets(guns\vents\ect)
_PUTIMAGE (XL%
, YL%
), Layer
(SPRITES
), Layer
(LayerID%%
), (0 + xoff%
, 64 + ((layer%
- 4) * 32))-(31 + xoff%
, 95 + ((layer%
- 4) * 32)) 'make collision layer(colored boxes for collision detections)
LINE (XL%
, YL%
)-STEP(32, 32), ArmsID
(x%
, y%
), BF
_DEST Layer
(1) 'restore to _display layer
SUB DrawDreadNaughtBase
(LayerID%%
) layer% = Ship(x%, y%, 0)
xoff% = 16 * (Ship(x%, y%, 1) - 65)
XL% = Xloc% + x% * 32
YL% = Yloc% + y% * 32
IF layer%
> 0 THEN _PUTIMAGE (XL%
, YL%
)-(XL%
+ 32, YL%
+ 32), Layer
(SPRITES
), Layer
(LayerID%%
), (0, 0 + ((layer%
- 1) * 16))-(15, 15 + ((layer%
- 1) * 16)) _PUTIMAGE (XL%
, YL%
)-(XL%
+ 32, YL%
+ 32), Layer
(SPRITES
), Layer
(LayerID%%
), (0 + xoff%
, 0 + (layer%
* 16))-(15 + xoff%
, 15 + (layer%
* 16))
SUB DrawPlayerShot
(tag%%
) FOR i%%
= 1 TO P.ShotsFired
_PUTIMAGE (PS
(i%%
).Xpos
, PS
(i%%
).Ypos
), Layer
(sprite
), Layer
(tag%%
), (98, 186)-(107, 199) _PUTIMAGE (PS
(i%%
).Xpos
, PS
(i%%
).Ypos
), Layer
(sprite
), Layer
(tag%%
), (108, 186)-(117, 199) _PUTIMAGE (PS
(i%%
).Xpos
, PS
(i%%
).Ypos
), Layer
(sprite
), Layer
(tag%%
), (119, 186)-(146, 199)
LINE (Star
(i%
).Xpos
, Star
(i%
).Ypos
)-STEP(2, 2), Star
(i%
).Colr
, BF
PS(id%%).Xpos = 0
PS(id%%).Ypos = 0
PS(id%%).Time = 0
PS(id%%).Kind = 0
Layer
(0) = _LOADIMAGE("DFsprit64.PNG") ' Sprite Layer Layer
(2) = _NEWIMAGE(640, 480, 32) 'Armorment draw layer Layer
(3) = _NEWIMAGE(640, 480, 32) 'screen mask, top 32 and bottom 80 pixels masked Layer
(4) = _NEWIMAGE(1408, 1024, 32) 'Ship base layer Layer
(5) = _NEWIMAGE(640, 480, 32) 'Star Field Layer
(8) = _NEWIMAGE(640, 480, 32) 'Dreadnaught weapon collision box layer
'DIM Size(64) AS LONG, FOffset&(64)
' OPEN "dreadnaughtfactor.SFX" FOR BINARY AS #1
' GET #1, , c%%
' FOR w% = 1 TO c%%
' GET #1, , foffset&
' GET #1, , Size(w%)
' NEXT
' FOR w% = 1 TO c%%
' OPEN "temp.dat" FOR BINARY AS #3
' dat$ = SPACE$(Size(w%))
' GET #1, , dat$
' PUT #3, , dat$
' CLOSE #3
' SFX(w%) = _SNDOPEN("temp.dat")
' IF _FILEEXISTS("temp.dat") THEN KILL "temp.dat"
' NEXT w%
' CLOSE
FFX
(1) = _LOADFONT("PixelIntv.otf", 40, "monospace")
'change gate color based on level
_PUTIMAGE (400, 222), Layer
(SPRITES
), Layer
(1), (256, 96 + ((G.Level
- 2) * 12))-(287, 107 + ((G.Level
- 2) * 12)) _PUTIMAGE (400, 217)-STEP(31, -11), Layer
(SPRITES
), Layer
(1), (256, 96 + ((G.Level
- 2) * 12))-(287, 107 + ((G.Level
- 2) * 12)) v1$
= LTRIM$(STR$(G.Score
)) 'create strings for printing ic%% = G.Lives
IF ic%%
> 15 THEN ic%%
= 15 'only display upto 15 extra ships yy%% = yy%% + 8
'display Dreadnaught
_PUTIMAGE (418 + (G.Distance
* 2), 206)-STEP(31, 27), Layer
(SPRITES
), Layer
(1), (32, 161)-STEP(15, 13)
FOR i%%
= 0 TO 71 'move next hyperfighter to gate xx~%% = xx~%% + 2
i%% = 0
i%%
= i%%
+ 1:
IF i%%
= 100 THEN i%%
= 0 '_SNDSTOP SFX(12)
'_SNDPLAY SFX(15)
SUB LoadDreadnaughtlayout
SUB MakeShot
(id%%
, tag%%
) PS(id%%).Xpos = 85
PS(id%%).Ypos = 226
PS(id%%).Time = 0
PS(id%%).Kind = tag%%
Star(i%).Xpos = Star(i%).Xpos - P.SpeedX
IF Star
(i%
).Xpos
<= -1 THEN newstar i%
, 1 Star(i%).Ypos = Star(i%).Ypos + P.SpeedY
IF Star
(i%
).Ypos
<= -1 THEN newstar i%
, 3 IF Star
(i%
).Ypos
>= 480 THEN newstar i%
, 2
Star(num%).Xpos = 640
Star
(num%
).Ypos
= INT(RND * 470) + 5 Star
(num%
).Colr
= INT(RND * 240) + 15 Star
(num%
).Colr
= _RGB32(Star
(num%
).Colr
, Star
(num%
).Colr
, Star
(num%
).Colr
) Star(num%).Xpos = Star(num%).Xpos
Star(num%).Ypos = 0
Star(num%).Xpos = Star(num%).Xpos
Star(num%).Ypos = 479
G.Lives = 10
G.Score = 0
G.Ships = 0
P.Xpos = (G.Distance * 30) ' distance from gate to ship
P.Ypos = 0
FOR i%%
= 1 TO P.ShotsFired
PS(i%%).Xpos = PS(i%%).Xpos + P.SpeedX + 7
PS(i%%).Time = PS(i%%).Time + 1
PS(i%%).Ypos = PS(i%%).Ypos + P.SpeedY
HIT~& = CollisionTarget(i%%) 'check if shot hit a target
IF HIT~&
OR PS
(i%%
).Time
> 100 OR PS
(i%%
).Ypos
< 26 OR PS
(i%%
).Ypos
> 410 OR PS
(i%%
).Xpos
> 630 THEN IF i%%
= 2 THEN P.ShotsFired
= P.ShotsFired
- 1: EraseShot
2 SWAP PS
(1), PS
(2): P.ShotsFired
= P.ShotsFired
- 1: EraseShot
2 P.ShotsFired = 0
EraseShot 1
IF HIT~&
THEN DestroyTarget HIT~&: HIT~&
= 0
S.Vents = 16
S.Engines = 4
S.Silos = 5
G.Distance = 93 - (G.Level - 1)
exitflag%% = FALSE
G.Distance = G.Distance - (G.Level + (2 * S.Engines))
P.Xpos = G.Distance * 30