Skip over non-existent rows when moving in gui.
This commit is contained in:
parent
8951819d18
commit
22010bb6df
1 changed files with 6 additions and 1 deletions
7
gui.rkt
7
gui.rkt
|
@ -254,9 +254,14 @@
|
||||||
(send dia show #f))])
|
(send dia show #f))])
|
||||||
(send dia show #t)))
|
(send dia show #t)))
|
||||||
|
|
||||||
|
(define (non-existent-key? row col)
|
||||||
|
(and (< row 2) (or (= col 5) (= col 6))))
|
||||||
|
|
||||||
(define (move st dx dy)
|
(define (move st dx dy)
|
||||||
(set-state-row! st (modulo (+ dy (state-row st)) rows))
|
(set-state-row! st (modulo (+ dy (state-row st)) rows))
|
||||||
(set-state-col! st (modulo (+ dx (state-col st)) cols)))
|
(set-state-col! st (modulo (+ dx (state-col st)) cols))
|
||||||
|
(when (non-existent-key? (state-row st) (state-col st))
|
||||||
|
(move st dx dy)))
|
||||||
|
|
||||||
(define (change-layer st dir)
|
(define (change-layer st dir)
|
||||||
(set-state-layer! st (modulo (+ dir (state-layer st))
|
(set-state-layer! st (modulo (+ dir (state-layer st))
|
||||||
|
|
Loading…
Reference in a new issue