Guest User

Untitled

a guest
May 16th, 2018
147
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Scheme 3.26 KB | None | 0 0
  1. (define draw-game
  2.   (lambda (g)
  3.     (letrec ((newgame ((game-behaviour g) g))
  4.              (pc (game-pacman g))
  5.              (f (game-field g))
  6.              (newscore (game-score newgame))
  7.              (newlives (score-lives newscore))
  8.              (offs (round (/ (- tile-width (* 2 (pacman-r pc))) 2)))
  9.              ; böse, aber aus Performancegründen leider notwendig
  10.              (_ (set! draw-field (if (= newlives 0)
  11.                                      (field-image start-field)
  12.                                      (freeze
  13.                                       (draw-tile " "
  14.                                                  (tile-x (field-tile f))
  15.                                                  (tile-y (field-tile f))
  16.                                                  draw-field))))))
  17.       (place-image (draw-score g)
  18.                    200 30
  19.                    (fold  
  20.                     (if ( < (+ (+ (* tile-width (pacman-col pc)) (span (pacman-offset-col pc))) offs) 0)
  21.                        
  22.                         (underlay/xy      
  23.                          draw-field
  24.                          0
  25.                          (+ (+ (* tile-width (pacman-row pc)) (span (pacman-offset-row pc))) offs)
  26.                          (crop 0 0 0 0 (draw-pacman pc)))
  27.                        
  28.                         (underlay/xy      
  29.                          draw-field
  30.                          (+ (+ (* tile-width (pacman-col pc)) (span (pacman-offset-col pc))) offs)
  31.                          (+ (+ (* tile-width (pacman-row pc)) (span (pacman-offset-row pc))) offs)
  32.                          (draw-pacman pc)))
  33.                        
  34.                        
  35.                     (lambda (gh img)
  36.                       (if ( < (+ (+ (* tile-width (pacman-col pc)) (span (pacman-offset-col pc))) offs) 0)
  37.                          
  38.                           (underlay/xy
  39.                            img
  40.                            0
  41.                            (+ (+ (* tile-width (ghost-row gh)) (span (ghost-offset-row gh))) offs)
  42.                            (crop 0 0 0 0(draw-ghost gh)))
  43.                      
  44.                           (underlay/xy
  45.                            img
  46.                            (+ (+ (* tile-width (ghost-col gh)) (span (ghost-offset-col gh))) offs)
  47.                            (+ (+ (* tile-width (ghost-row gh)) (span (ghost-offset-row gh))) offs)
  48.                            (draw-ghost gh))))
  49.                      
  50.                       (game-ghosts g))))))
  51.  
  52.  
  53. ;TICK
  54. (define tick-tick
  55.   (lambda (g)
  56.     (letrec ((newgame ((game-behaviour g) g))
  57.              (pc (game-pacman newgame))
  58.              (fd (game-field newgame))
  59.              (p (game-pacman g))
  60.              (f (game-field g))
  61.              (m (field-maze f))
  62.              (bl (maze-border-layout m))
  63.              (ft (field-tile f)))
  64.       (if (= (score-lives (game-score newgame)) 0)
  65.           initial-game
  66.           (make-game (if (collision? g)
  67.                          start-pacman
  68.                          (move-pacman pc fd))
  69.                      fd (game-behaviour g)
  70.                      (map (lambda (gh)
  71.                             (move-ghost gh g))
  72.                           (game-ghosts g))
  73.                      (eat-pills-or-clash? g))))))
Add Comment
Please, Sign In to add comment