first commit
This commit is contained in:
39
pacman-project/coin.rkt
Normal file
39
pacman-project/coin.rkt
Normal file
@@ -0,0 +1,39 @@
|
||||
#lang r7rs
|
||||
|
||||
(define-library (pacman-project coin)
|
||||
(import (scheme base)
|
||||
(pp1 graphics)
|
||||
(pacman-project screen)
|
||||
(pacman-project maze))
|
||||
|
||||
(export draw-coins!
|
||||
remove-coin!)
|
||||
|
||||
(begin
|
||||
|
||||
(define coin-size-offset 20)
|
||||
|
||||
(define coins-layer (make-new-layer!))
|
||||
(define coin-tile (make-tile screen-width screen-height))
|
||||
((coins-layer 'add-drawable!) coin-tile)
|
||||
|
||||
;tekent de muntjes
|
||||
(define (draw-coins!)
|
||||
(do ((row 0 (+ row 1)))
|
||||
((= row maze-rows))
|
||||
(do ((col 0 (+ col 1)))
|
||||
((= col maze-cols))
|
||||
(when (cell-coin? row col)
|
||||
((coin-tile 'draw-rectangle!)
|
||||
(+ (* col cell-size) 7)
|
||||
(+ (* row cell-size) maze-offset-y 7)
|
||||
(- cell-size coin-size-offset)
|
||||
(- cell-size coin-size-offset)
|
||||
"yellow")))))
|
||||
|
||||
(draw-coins!)
|
||||
|
||||
;muntjes verwijderen
|
||||
(define (remove-coin! row col)
|
||||
((coin-tile 'clear!)) ;alle coins verwijderen en alleen de coins die niet verwijderdt zijn tekenen
|
||||
(draw-coins!))))
|
||||
Reference in New Issue
Block a user