Skip to content

Instantly share code, notes, and snippets.

@hgcummings
Created July 24, 2016 21:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hgcummings/baddebdca0ed7504b82916412e9fef1c to your computer and use it in GitHub Desktop.
Save hgcummings/baddebdca0ed7504b82916412e9fef1c to your computer and use it in GitHub Desktop.
My First Code: YA Cave
'All code (c) Harry Cummings 2002
'Original concept (c) SunFlat
'For additional information and instructions,
'see readme.txt. For the latest version, see
'http://yabasic.electricweb.org.uk/
open window 640,512
draw = 1
p = 0
hs = 0
label intro
pause 0.2
clear window
setrgb 0,128,128,255
hs$ = "High score: " + str$(int(hs))
ls$ = "Last score: " + str$(int(p))
label introloop
for cr = 1 to 10
setdrawbuf draw
clear window
setrgb 1,64,64,128
if (int(cr / 10) / 2) = int(int(cr / 10) / 2) setrgb 1,64,72,128
fill circle 320,256,80
setrgb 1,0,0,0
text 325,205,"electricweb.org.uk YACave","cc"
setrgb 1,255,255,255
text 320,200,"electricweb.org.uk YACave","cc"
text 320,256,ls$,"cc"
text 320,270,hs$,"cc"
setrgb 1,255,0,0
text 550,500,"Press X to start","cc"
setdispbuf draw
draw = 1 - draw
if and(peek("port1"),16384) > 0 then goto start fi
next
for cr = 80 to 240
setdrawbuf draw
clear window
setrgb 1,64,64,128
if (int(cr / 10) / 2) = int(int(cr / 10) / 2) setrgb 1,64,72,128
fill circle 320,256,cr
setrgb 1,0,0,0
text 325,205,"electricweb.org.uk YACave","cc"
setrgb 1,255,255,255
text 320,200,"electricweb.org.uk YACave","cc"
text 320,256,ls$,"cc"
text 320,270,hs$,"cc"
setrgb 1,255,0,0
text 550,500,"Press X to start","cc"
setdispbuf draw
draw = 1 - draw
if and(peek("port1"),16384) > 0 goto start
next
for cr = 1 to 10
setdrawbuf draw
clear window
setrgb 1,64,64,128
if (int(cr / 10) / 2) = int(int(cr / 10) / 2) setrgb 1,64,72,128
fill circle 320,256,240
setrgb 1,0,0,0
text 325,205,"electricweb.org.uk YACave","cc"
setrgb 1,255,255,255
text 320,200,"electricweb.org.uk YACave","cc"
text 320,256,ls$,"cc"
text 320,270,hs$,"cc"
setrgb 1,255,0,0
text 550,500,"Press X to start","cc"
setdispbuf draw
draw = 1 - draw
if and(peek("port1"),16384) > 0 goto start
next
for cr = 240 to 80 step -1
setdrawbuf draw
clear window
setrgb 1,64,64,128
if (int(cr / 10) / 2) = int(int(cr / 10) / 2) setrgb 1,64,72,128
fill circle 320,256,cr
setrgb 1,0,0,0
text 325,205,"electricweb.org.uk YACave","cc"
setrgb 1,255,255,255
text 320,200,"electricweb.org.uk YACave","cc"
text 320,256,ls$,"cc"
text 320,270,hs$,"cc"
setrgb 1,255,0,0
text 550,500,"Press X to start","cc"
setdispbuf draw
draw = 1 - draw
if and(peek("port1"),16384) > 0 goto start
next
goto introloop
label start
setrgb 0,0,0,0
clear window
s = 0
p = 0
h = 432
dim col(32)
dim ctop(32)
dim cflr(32)
dim cbar(32)
dim rib(35)
colset = 64
colpol = -1
for x = 1 to 32
col(x) = colset
if colset = 0 colpol = 1
if colset = 64 colpol = -1
colset = colset + (8 * colpol)
ctop(x) = 40
cflr(x) = 472
cbar(x) = 0
next x
for x = 1 to 35
rib(x) = 200
next x
label loop
draw = 1 - draw
setdrawbuf draw
clear window
xcol = 0
for x = 1 to 32
setrgb 1,(128 - col(x)),255,(128 - col(x))
fill rectangle xcol,0 to (xcol + 16),512
xcol = xcol + 16
next x
xcav = 0
for x = 1 to 32
setrgb 1,col(x),0,0
fill rectangle xcav,ctop(x) to (xcav + 16),cflr(x)
xcav = xcav + 16
next x
setrgb 1,128,255,128
xbar = 0
for x = 1 to 32
if cbar(x) > 0 fill rectangle xbar,cbar(x) to (xbar + 16),(cbar(x) + 64)
xbar = xbar + 16
next x
xrib = 0
setrgb 1,128,128,255
for x = 1 to 35
fill rectangle xrib,rib(x) to (xrib + 4),(rib(x) + 16)
xrib = xrib + 4
next x
fill rectangle 512,0 to 640,512
setrgb 1,255,255,255
scr$ = "Score: " + str$(int(p))
text 576,200,scr$,"cc"
setdispbuf draw
if h > 100 h = (-0.328 * p) + 432
if and(peek("port1"),16384) > 0 then s = s - 0.2 else s = s + 0.2 fi
if rib(35) < (ctop(9) - 8) goto hit
if (rib(35) + 8) > (cflr(9)) goto hit
if cbar(9) > 0 then if rib(35) > (cbar(9) - 8) then if rib(35) < (cbar(9) + 56) then goto hit fi fi fi
if frac(p) = 0 then
for x = 1 to 31
col(x) = col(x + 1)
ctop(x) = ctop(x + 1)
cflr(x) = cflr(x + 1)
cbar(x) = cbar(x + 1)
next x
col(32) = col(1)
c = 4 * (int(ran(4) + 0.5))
if ctop(32) > (496 - h) then d = -1 else if ctop(32) < 16 then d = 1 else if ran(10) < 9 then d = d else d = d * -1 fi fi fi
if d = 0 then ctop(32) = ctop(32) + c else ctop(32) = ctop(32) + (c * d) fi
cflr(32) = ctop(32) + h
cbar(32) = 0
if int(p / 10) = (p / 10) cbar(32) = int(ran(h - 32) + 0.5) + ctop(32) + 8
fi
for x = 1 to 34
rib(x) = rib(x + 1)
next x
rib(35) = rib(35) + s
p = p + 0.25
goto loop
label hit
if p > hs hs = p
hc = rib(35) + 8
setrgb 1,255,0,0
for hr = 1 to 184 step 3
circle 140,hc,hr
pause 0.04
next
setrgb 1,0,0,0
fill rectangle 192,224 to 320,280
setrgb 1,255,255,255
rectangle 192,224 to 320,280
setrgb 1,48,48,255
text 257,246," Game Over!","cc"
if p = hs then
setrgb 1,255,255,0
text 261,266,"High Score!","cc"
fi
inkey$
goto intro
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment