-
Notifications
You must be signed in to change notification settings - Fork 0
/
spook-adt.rkt
78 lines (57 loc) · 2.05 KB
/
spook-adt.rkt
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
#lang racket
(#%require "variabelen-en-procedures.rkt")
(#%provide spook-adt)
;;;;;;;;;;;;;;;;;
;; Spook-adt ;;
;;;;;;;;;;;;;;;;;
(define (spook-adt positie)
;! Startposities !;
(define start-positie-x (positie 'get-x))
(define start-positie-y (positie 'get-y))
;! Spook-status !;
(define spook-status 'op-platforme)
(define (verander-spook-status nieuwe-status)
(set! spook-status nieuwe-status))
;! Spook-richting !;
(define spook-richting 'rechts)
(define (verander-spook-richting nieuwe-status)
(set! spook-richting nieuwe-status))
(define (reset-spook-richting)
(set! spook-richting 'rechts))
;! Spook-limiet? !;
(define bots? 'nee)
(define (verander-bots nieuwe-bots)
(set! bots? nieuwe-bots))
;! Spook-bots? !;
(define (spook-mario-bots? mario-adt)
(bots
positie
mario-adt
mario-adt
spook-interval
spook-interval
spook-interval
spook-interval))
;! Teken-functie !;
(define (teken! adt)
((adt 'teken-spook!) dispatch-spook-adt))
(define (dispatch-spook-adt msg)
(cond ((eq? msg 'get-x) (positie 'get-x))
((eq? msg 'get-y) (positie 'get-y))
((eq? msg 'set-x!) (positie 'set-x!))
((eq? msg 'set-y!) (positie 'set-y!))
((eq? msg 'voet) (+ (positie 'get-y) spook-voet))
((eq? msg 'dikte) (+ (positie 'get-x) spook-dikte))
((eq? msg 'startpositie-x) start-positie-x)
((eq? msg 'startpositie-y) start-positie-y)
((eq? msg 'richting) spook-richting)
((eq? msg 'status) spook-status)
((eq? msg 'verander-status) verander-spook-status)
((eq? msg 'verander-richting) verander-spook-richting)
((eq? msg 'reset-richting) (reset-spook-richting))
((eq? msg 'bots?) bots?)
((eq? msg 'verander-bots) verander-bots)
((eq? msg 'spook-mario-bots?) spook-mario-bots?)
((eq? msg 'teken!) teken!)
(else (error " adt: dispatch-spook-adt -- file: spook-adt -- error:" msg))))
dispatch-spook-adt)