File tree Expand file tree Collapse file tree 4 files changed +35
-0
lines changed
Expand file tree Collapse file tree 4 files changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ #lang racket
2+ (require 2htdp/image)
3+ (require 2htdp/universe)
4+
5+ (define (background t)
6+ (overlay/xy (bitmap "background.png " )
7+ 500 175
8+ (empty-scene 0 0 )))
9+
10+ (big-bang '(20 . 450 )
11+ (to-draw background))
12+
13+
Original file line number Diff line number Diff line change 1+ #lang racket
2+ (require 2htdp/image)
3+ (require 2htdp/universe)
4+
5+ (define player (bitmap "character_sprite.png " ))
6+
7+ (define (character t) ;t =WorldState
8+ (place-image player
9+ (car t)
10+ (cdr t)
11+ (empty-scene 500 500 )))
12+
13+ (define (change w a-key)
14+ (cond
15+ [(key=? a-key "left " ) (cons (-(car w) 5 ) (cdr w))]
16+ [(key=? a-key "right " ) (cons (+ 5 (car w)) (cdr w))]
17+ [(= (string-length a-key) 1 ) w]
18+ [else w]))
19+
20+ (big-bang '(20 . 450 )
21+ (to-draw character)
22+ (on-key change))
You can’t perform that action at this time.
0 commit comments