end of day, it's in the state that it is in
This commit is contained in:
parent
568ea6e2cc
commit
9fb0ca3def
12
main.rkt
12
main.rkt
|
@ -161,6 +161,7 @@
|
|||
(define (play-game s players)
|
||||
(let ([g (GameState-grid s)]
|
||||
[p (GameState-player s)])
|
||||
(print (render-grid-bitmap g))
|
||||
(cond
|
||||
[(= (length g) (length ALL-LINES)) s] ; end of the game
|
||||
[else
|
||||
|
@ -186,14 +187,15 @@
|
|||
; renders grid on the given drawing context.
|
||||
; TODO color in squares
|
||||
(define (render-grid grid dc)
|
||||
(for ([l grid])
|
||||
(for ([l (reverse grid)])
|
||||
(cond
|
||||
[(= (line-player l) 0) (send dc set-pen "red" 4 'solid)] ; player 1 draws in red
|
||||
[(= (line-player l) 1) (send dc set-pen "blue" 4 'solid)]) ; player 2 draws in blue
|
||||
[(= (line-player l) 0) (send dc set-pen "red" 4 'solid) (send dc set-brush "red" 'bdiagonal-hatch)] ; player 1 draws in red
|
||||
[(= (line-player l) 1) (send dc set-pen "blue" 4 'solid) (send dc set-brush "blue" 'fdiagonal-hatch)]) ; player 2 draws in blue
|
||||
(send dc draw-line
|
||||
(+ 4 (* GRID-SCALE (point-x (line-from l))))
|
||||
(+ 4 (* GRID-SCALE (point-y (line-from l))))
|
||||
(+ 4 (* GRID-SCALE (point-x (line-to l))))
|
||||
(+ 4 (* GRID-SCALE (point-y (line-to l)))))) ; draw the line
|
||||
|
||||
(send dc draw-bitmap EMPTY-GRID 0 0)) ; overlay dot grid
|
||||
(send dc draw-bitmap EMPTY-GRID 0 0)) ; overlay dot grid
|
||||
|
||||
(play-game (GameState '() 0 '(0 0)) (list random-player random-player))
|
Loading…
Reference in New Issue