Handbook
Glossary
snake-gadget
Vocabulary
snake-game
.
ui
Definition
USING:
ui.gadgets
;
IN:
snake-game.ui
TUPLE:
snake-gadget
<
gadget
snake-game timer textures
;
Methods
USING:
accessors
kernel
namespaces
opengl
snake-game.game
snake-game.ui
ui.render
;
M:
snake-gadget
draw-gadget*
[
textures>>
game-textures
]
keep
[
snake-game>>
[
food-loc>>
[
draw-food
]
when*
]
[
[
snake-loc>>
]
[
snake-dir>>
opposite-dir
]
[
snake>>
]
tri
draw-snake
]
bi
]
curry
[
[
draw-background
{
10 10
}
]
]
dip
[
with-translation
]
curry
compose
with-variable
;
USING:
accessors
calendar
kernel
snake-game.sprites
snake-game.ui
timers
ui.gadgets
;
M:
snake-gadget
graft*
dup
[
do-updates
]
curry
200
milliseconds
every
>>timer
snake-textures
>>textures
drop
;
USING:
accessors
combinators
combinators.short-circuit
kernel
snake-game.ui
ui
ui.gestures
;
M:
snake-gadget
handle-gesture
swap
[
key-down?
]
1check
[
sym>>
{
{
[
dup
quit-key?
]
[
drop
close-window
]
}
{
[
dup
pause-key?
]
[
drop
toggle-game-pause
]
}
{
[
dup
new-game-key?
]
[
drop
start-new-game
]
}
[
key-dir
[
swap
snake-game>>
dup
{
~quotation~ ~quotation~
}
1&&
[
next-turn-dir<<
]
[
2drop
]
if
]
[
drop
]
if*
]
}
cond
]
[
2drop
]
if
f
;
USING:
kernel
math
sequences
snake-game.game
snake-game.ui
ui.gadgets
;
M:
snake-gadget
pref-dim*
drop
snake-game-dim
[
snake-game-cell-size
*
20
+
]
map
;
USING:
accessors
assocs
destructors
kernel
snake-game.ui
timers
ui.gadgets
ui.gadgets.worlds
;
M:
snake-gadget
ungraft*
[
stop-timer
f
]
change-timer
dup
find-gl-context
[
values
dispose-each
f
]
change-textures
drop
;