aUCBLogo Demos and Tests / cursorgame
be cursorgame
maxx=80
maxy=30
score=0
pluses=0
minuses=0
init
p=list int maxx/2 int maxy/2
v=list 1 0
running=true
while [running]
[ setCursor p
setTextColor black yellow
type "X
waitms 100
setCursor p
setTextColor white black
type "\
if key?
[ k=rawASCII readChar
if k==27 [running=false]
if k==255
[ k=readCharExt
v=case k
[ [WXK_LEFT list -1 0]
[WXK_RIGHT list 1 0]
[WXK_UP list 0 -1]
[WXK_DOWN list 0 1]
[else v]
]
]
]
p=p+v
if (or (first p) < 0 (last p) < 1
(first p) > maxx-1 (last p) > maxy)
[ p=p-v
v=(list 0 0)-v
]
setCursor p
c=CharUnderCursor
case c
[ ["# p=p-v v=(list 0 0)-v]
["+ score=score+100 pluses=pluses-1
playWave init::wavPlus 1
]
["- score=score-100 minuses=minuses-1
playWave init::wavMinus 1
]
[else score=score-1]
]
prsc
if or pluses==0 minuses==0 [running=false]
]
setCursor list int maxx/2-18 int maxy/2
(type [\ \ \ \ \ \ \ \ Final Score was:\ ] score [\ \ \ \ \ \ \ \ ])
setCursor list 0 maxy+2
pr "cursorgame
notFullScreen
be setc
setTextColor white black
end
be init
allFullScreen
TextScreen
clearText
setTextFont [Courier New]
boldTextMode
setTextSize 17
::black=RGB 0 0 0
::white=RGB 1 1 1
::red=RGB 1 0 0
::green=RGB 0 1 0
::blue=RGB 0 0 1
::yellow=RGB 1 1 0
setc
str "\ maxx
(pr)
repeat maxy
[ repeat maxx
[ ifelse rnd < 0.1
[ ifelse rnd < 0.25
[ ifelse rnd < 0.5
[ setTextColor yellow blue
type "- minuses=minuses+1
setc
][ setTextColor green red
type "+ pluses=pluses+1
setc
]
][ setTextColor black white
type "#
setc
]
][ type "\
]
]
(pr)
]
setc
overwriteMode
ifelse LogoVersion.3 == "Linux
[ wavPlus=[/usr/share/sounds/KDE_Click.wav]
wavMinus=[/usr/share/sounds/KDE_Click.wav]
][ ifelse SubString? "Windows LogoVersion.3
[ wavPlus="C:\Windows\Media\Ding.wav
wavMinus="C:\Windows\Media\Chord.wav
][ wavPlus=[]
wavMinus=[]
]
]
end
be prsc
setCursor list int maxx/2-6 0
setTextColor yellow black
(type [Score:\ ] score [\ \ \ \ \ ])
end
be str c n
repeat n [type c]
end
end