fix remaining functions for grid becoming a structure
This commit is contained in:
parent
8ffad3c7b6
commit
0584652a18
4
gui.rkt
4
gui.rkt
|
@ -18,6 +18,8 @@
|
|||
|
||||
; Make a frame by instantiating the frame% class
|
||||
(define g (grid-lines (GameState-grid game)))
|
||||
(define w (grid-width (GameState-grid game)))
|
||||
(define h (grid-height (GameState-grid game)))
|
||||
(define t 0)
|
||||
(define frame (new frame%
|
||||
[label "Game Analysis"]
|
||||
|
@ -30,7 +32,7 @@
|
|||
[paint-callback
|
||||
(lambda (canvas dc)
|
||||
(send dc clear)
|
||||
(render-grid (grid (take g t) 6 6) dc))]))
|
||||
(render-grid (grid (take g t) w h) dc))]))
|
||||
|
||||
(define log (new list-box%
|
||||
[label ""]
|
||||
|
|
8
main.rkt
8
main.rkt
|
@ -189,9 +189,9 @@
|
|||
; renders grid on the given drawing context.
|
||||
; TODO setting line color doesn't seem to be always working?
|
||||
; TODO color in squares
|
||||
(define (render-grid grid dc)
|
||||
(define (render-grid g dc)
|
||||
(define passed '())
|
||||
(for ([l (grid-lines grid)]) ; reversed for fill-drawing malarkey.
|
||||
(for ([l (grid-lines g)]) ; reversed for fill-drawing malarkey.
|
||||
(if (empty? passed) (set! passed (list l)) (set! passed (append passed (list l))))
|
||||
(cond
|
||||
[(= (line-player l) 0) (send dc set-pen "red" 4 'solid)] ; player 1 draws in red
|
||||
|
@ -203,8 +203,8 @@
|
|||
(+ 4 (* GRID-SCALE (point-y (line-to l))))) ; draw the line
|
||||
(let ([boxes (boxes-for l)])
|
||||
(for ([b boxes])
|
||||
(if (= (count-square b passed) 4)
|
||||
(send dc draw-text
|
||||
(if (= (count-square b (grid passed (grid-width g) (grid-height g))) 4)
|
||||
(send dc draw-text
|
||||
(if (= (line-player l) 0) "R" "B")
|
||||
(+ 6 (* GRID-SCALE (point-x b)))
|
||||
(+ 3 (* GRID-SCALE (point-y b))))
|
||||
|
|
Loading…
Reference in New Issue