-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgraphics-engine.rkt
More file actions
83 lines (76 loc) · 2.42 KB
/
Copy pathgraphics-engine.rkt
File metadata and controls
83 lines (76 loc) · 2.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#lang racket
(require 2htdp/image)
(require srfi/43)
(require "main.rkt")
(require "sprites.rkt")
(require "globals.rkt")
(require "game-logic.rkt")
(define (whoseTurnText ws)
(let*
[
(isWhite (WS-isWhiteTurn ws))
(fontSize 70)
]
(cond
[isWhite (text "White to move" fontSize "black")]
[else (text "Black to move" fontSize "black")]
)
)
)
(define (respective-forfeit-button ws)
(let*
[
(isWhite (WS-isWhiteTurn ws))
]
(cond
[isWhite BUTTON-WHITE]
[else BUTTON-BLACK]
)
)
)
(define board-sprite
(above
(beside LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE)
(beside DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE)
(beside LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE)
(beside DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE)
(beside LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE)
(beside DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE)
(beside LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE)
(beside DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE DARK-SQUARE LIGHT-SQUARE)
))
(define (draw ws)
(cond
[(= (WS-winner ws) NONE)(let* [
(firstCoord (WS-firstCoord ws))
(firstCol (if (eq? firstCoord #f) -1 (BCoord-col firstCoord)))
(firstRow (if (eq? firstCoord #f) -1 (BCoord-row firstCoord)))
(highlight (square 128 "solid" (color 0 255 0 128)))
]
(scale scalar
(beside
(vector-fold
(lambda(y st row)
(vector-fold
(lambda(x img piece)
(if(eq? piece'null)
img
(place-image
(Piece-sprite piece)
(+(* x 128)64)
(+(* y 128)64)
(if (and (= x firstCol) (= y firstRow)) (place-image highlight (+(* x 128)64) (+(* y 128)64) img) img))))
st
row))
board-sprite
(WS-board ws))
(above
(whoseTurnText ws)
(respective-forfeit-button ws)
)
)
))]
[(= (WS-winner ws) WHITE) (scale scalar WHITE-WINS)]
[else (scale scalar BLACK-WINS)]))
(provide draw)
(provide respective-forfeit-button)