Space dust and proper key handling/animations (no art yet)

This commit is contained in:
stevenhowes
2021-01-30 22:10:54 +00:00
parent 300c6a2009
commit 60deea7682
3 changed files with 31 additions and 15 deletions
Binary file not shown.
+31 -15
View File
@@ -12,11 +12,18 @@ DEF PROC_main
PlayerVelocity%=0 PlayerVelocity%=0
PlayerShields%=100 PlayerShields%=100
PlayerStructuralIntegrity%=100 PlayerStructuralIntegrity%=100
XMovePerCent%=5 XMovePerCent%=10
ResetShipSprite% = 0
REM Show/hide debug display REM Show/hide debug display
DebugOut%=0 DebugOut%=0
DIM SpecLocations%(1,49)
FOR Spec%=0 TO 49
SpecLocations%(0,Spec%) = RND(1600)
SpecLocations%(1,Spec%) = RND(1200)
NEXT Spec%
REM Used for centiseconds per frame calcs REM Used for centiseconds per frame calcs
Cents% = TIME Cents% = TIME
@@ -34,10 +41,18 @@ DEF PROC_main
REM Set grpahics buffer to one that's not in use REM Set grpahics buffer to one that's not in use
SYS "OS_Byte",112,Scr% SYS "OS_Byte",112,Scr%
CLS CLS
FOR Spec%=0 TO 49
GCOL 0,0
LINE SpecLocations%(0,Spec%),SpecLocations%(1,Spec%),SpecLocations%(0,Spec%),SpecLocations%(1,Spec%)
SpecLocations%(1,Spec%) = SpecLocations%(1,Spec%) - (Cents% - LastCents%)
IF SpecLocations%(1,Spec%) < 0 THEN
SpecLocations%(1,Spec%) = 1200
SpecLocations%(0,Spec%) = RND(1600)
ENDIF
NEXT Spec%
REM Draw LCARS in top left REM Draw LCARS in top left
PROCdraw_sprite("lcars",0,940) PROCdraw_sprite("lcars",0,940)
@@ -45,6 +60,10 @@ DEF PROC_main
PROCdebugoutput PROCdebugoutput
ENDIF ENDIF
IF Cents% > ResetShipSprite% THEN
ShipSprite$ = "player_ship"
ENDIF
REM Handle Key inputs REM Handle Key inputs
PROCinputs PROCinputs
@@ -68,7 +87,7 @@ DEF PROC_main
PRINT PlayerVelocity% PRINT PlayerVelocity%
REM Draw player ship REM Draw player ship
PROCdraw_sprite("player_ship",PlayerLocation%(0),PlayerLocation%(1)) PROCdraw_sprite(ShipSprite$,PlayerLocation%(0),PlayerLocation%(1))
REM Wait for rendering to complete REM Wait for rendering to complete
WAIT WAIT
@@ -85,16 +104,18 @@ ENDPROC
REM Input handling REM Input handling
DEF PROCinputs DEF PROCinputs
REM TODO: Scan individual keys so we can handle specials (e.g. arrows) *FX 4
KEY = INKEY(0) IF INKEY(-122) THEN
ShipSprite$ = "player_shipr"
IF KEY = 100 THEN ResetShipSprite% = Cents% + 20
PlayerLocation%(0) = PlayerLocation%(0) + (XMovePerCent% * (Cents% - LastCents%)) PlayerLocation%(0) = PlayerLocation%(0) + (XMovePerCent% * (Cents% - LastCents%))
ENDIF ENDIF
IF KEY = 97 THEN IF INKEY(-26) THEN
ShipSprite$ = "player_shipl"
ResetShipSprite% = Cents% + 20
PlayerLocation%(0) = PlayerLocation%(0) - (XMovePerCent% * (Cents% - LastCents%)) PlayerLocation%(0) = PlayerLocation%(0) - (XMovePerCent% * (Cents% - LastCents%))
ENDIF ENDIF
IF KEY = 113 THEN IF INKEY(-17) THEN
IF DebugOut% = 1 THEN DebugOut% = 0 ELSE DebugOut% = 1 IF DebugOut% = 1 THEN DebugOut% = 0 ELSE DebugOut% = 1
ENDIF ENDIF
ENDPROC ENDPROC
@@ -103,11 +124,6 @@ REM Debug prints
DEF PROCdebugoutput DEF PROCdebugoutput
MOVE 0,500 MOVE 0,500
PRINT "X: " + STR$(PlayerLocation%(0)) " Y: " STR$(PlayerLocation%(1)) PRINT "X: " + STR$(PlayerLocation%(0)) " Y: " STR$(PlayerLocation%(1))
IF KEY <> -1 THEN
PRINT "Key: " + STR$(KEY)
ELSE
PRINT "Key:"
ENDIF
PRINT "CPF: " + STR$(Cents% - LastCents%) PRINT "CPF: " + STR$(Cents% - LastCents%)
ENDPROC ENDPROC
Binary file not shown.