variable fd-out variable music-out variable sfx-out create str 0 , 0 , : playSound s" loadfile ./sounds/" sfx-out @ write-file throw sfx-out @ write-line throw sfx-out @ flush-file throw ; : init s" ginput" w/o create-file throw fd-out ! s" sfxInput" w/o create-file throw sfx-out ! \ s" soundInput" w/o create-file throw music-out ! s" start.mp3 " playSound ; : cleanup fd-out @ close-file throw sfx-out @ close-file throw \ music-out @ close-file throw ; : wr fd-out @ write-file throw ; : ln fd-out @ write-line throw fd-out @ flush-file throw ; : toStr '0 + str ! ; : lose s" game begin /lives lives 1 sub def end hud" ln s" pacdies.mp3 " playSound ; : eat \ precondition: there is something to eat :) s" world " wr toStr str 1 wr s" get " wr toStr str 1 wr s" 0 put" ln s" game begin /score score 1 add def end hud" ln ; : lookRight s" /renderPacman { renderPacmanRight } bind def" ln ; : lookLeft s" /renderPacman { renderPacmanLeft } bind def" ln ; : lookUp s" /renderPacman { renderPacmanBack } bind def" ln ; : lookDown s" /renderPacman { renderPacmanFront } bind def" ln ; : pac-up s" [0 0.3 0] vaoPacmanParts addToArrays" ln ; : pac-down s" [0 -0.3 0] vaoPacmanParts addToArrays" ln ; : rot-field-left s" /renderIdentity renderIdentity 4 rotationY mat*mat def" ln ; : rot-field-right s" /renderIdentity renderIdentity -4 rotationY mat*mat def" ln ; : setPacman swap dup 10 / toStr str 1 wr 10 mod toStr str 1 wr s" " wr dup 10 / toStr str 1 wr 10 mod toStr str 1 wr s" setPos" ln \ s" chomping.mp3 " playSound ; : setGhost swap dup 10 / toStr str 1 wr 10 mod toStr str 1 wr s" " wr dup 10 / toStr str 1 wr 10 mod toStr str 1 wr s" setGhostPos" ln ; : reset ; : play-win-sound s" intermission.mp3 " playSound \ todo: find correct sound ; : win s" frame" ln s" /frame { } def" ln s" hudStart " wr s" hudLine (You won!) show " wr s" hudEnd" ln ; : game-over s" frame" ln s" /frame { } def" ln s" hudStart " wr s" hudLine (Game Over n00b !) show " wr s" hudEnd" ln ; init