Skip to content

Instantly share code, notes, and snippets.

@y-ack
Created February 9, 2018 01:07
Show Gist options
  • Save y-ack/a3d1ee296fbbdb0286e5ff8c34b0f3ed to your computer and use it in GitHub Desktop.
Save y-ack/a3d1ee296fbbdb0286e5ff8c34b0f3ed to your computer and use it in GitHub Desktop.
smilebasic joke hello world "A Game About Anime"
CLS
DIM CONSHEIGHT%:CONSHEIGHT% = 30
DIM TITLE$,START$:TITLE$ = "a game about anime":START$ = "PRESS START"
GOSUB @INITTIMERS
TITLEPRINT TITLE$, 0, 0
EAT CREATETIMER("TEXTON", 40)
EAT CREATETIMER("TEXTOFF", 80)
WHILE !BUTTON(8192)
VSYNC 2
UPDATETIMERS
WEND
? " CONGRATULATION!"+CHR$(10)+CHR$(10)+" Design Program"+CHR$(10)+"Pixel-Voxel "+CHR$(&H2602)+" Lumage"
END
DEF EAT SAND END
DEF CENTER TEXT$ OUT X%, Y%
X% = FLOOR(24 - LEN(TEXT$) / 2) 'MAX(FLOOR(24 - LEN(TEXT$) / 2), 0)
Y% = FLOOR(CONSHEIGHT% / 2) - 1
END
DEF TITLEPRINT TEXT$, XOFS%, YOFS%
VAR X%,Y%
CENTER TEXT$ OUT X%,Y%
LOCATE X% + XOFS%, Y% + YOFS%
?TEXT$
END
DEF TEXTON
COLOR 15
TITLEPRINT START$, 0, 2
END
DEF TEXTOFF
COLOR 0
TITLEPRINT START$, 0, 2
COLOR 15
END
@INITTIMERS
DIM TIMERS%, PREVTIME%: PREVTIME% = MAINCNT
TIMERS% = 2
DIM TIMERK$[TIMERS%] 'callback
DIM TIMERV%[TIMERS%] 'value
DIM TIMERT%[TIMERS%] 'start
RETURN
DEF UPDATETIMERS
VAR I%, CURTIME%
I% = LEN(TIMERK$)-1
CURTIME% = MAINCNT
WHILE(TIMERK$[I%] != "")
TIMERV%[I%] = TIMERV%[I%] - (CURTIME% - PREVTIME%)
IF TIMERV%[I%] <= 0 THEN
IF TIMERK$[I%] != "" THEN 'CALL TIMERK$[I%]
IF TIMERK$[I%] == "TEXTON" THEN TEXTON
IF TIMERK$[I%] == "TEXTOFF" THEN TEXTOFF
ENDIF
TIMERV%[I%] = TIMERT%[I%] + TIMERV%[I%]
ENDIF
I% = I% - 1
WEND
PREVTIME% = MAINCNT
END
DEF CREATETIMER(CALLBACK$, INTERVAL%)
IF TIMERS% < 1 THEN THROW "Surpassed Timer limit",1
TIMERS% = TIMERS% - 1
TIMERK$[TIMERS%] = CALLBACK$
TIMERV%[TIMERS%] = INTERVAL%
TIMERT%[TIMERS%] = INTERVAL%
RETURN TIMERS%
END
DEF THROW MSG$, TERMINATE%
COLOR 3
?MSG$
COLOR 15
IF TERMINATE% THEN END
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment