adjust the planet cute images so they cooperate with executable creation better

This commit is contained in:
Robby Findler 2011-10-28 13:31:06 -05:00
parent f48e12240a
commit e9d32dfdff
56 changed files with 311 additions and 2 deletions

View File

@ -1,14 +1,48 @@
#lang racket/base
(require 2htdp/image
racket/runtime-path
(for-syntax "private/planetcute-image-list.rkt")
(for-syntax racket/base))
(define-syntax (definitions stx)
#`(begin
#,@(for/list ([img (in-list (apply append (map cdr images)))])
(define req (string->symbol (format "2htdp/planetcute/~a" (name->filename img))))
#`(begin
(provide #,img)
(define #,img (bitmap #,req))))))
(define-syntax #,img (make-planetcute-transformer '#,img))))))
(define-for-syntax (make-planetcute-transformer img)
(make-set!-transformer
(let ([saved-id-table (make-hasheq)])
(λ (stx)
(if (eq? 'expression (syntax-local-context))
;; In an expression context:
(let* ([key (syntax-local-lift-context)]
;; Already lifted in this lifting context?
[lifted-id
(or (hash-ref saved-id-table key #f)
;; No: lift the require for the image:
(syntax-local-lift-require `(lib ,(format "~a.rkt" img) "2htdp" "planetcute")
(datum->syntax stx img)))])
(when key (hash-set! saved-id-table key lifted-id))
;; Expand to a use of the lifted expression:
(with-syntax ([saved-id (syntax-local-introduce lifted-id)])
(syntax-case stx (set!)
[name (identifier? #'name) #'saved-id]
[(set! id arg)
(raise-syntax-error
'2htdp/planetcute
"cannot set! a Planet Cute variable"
stx #'id)]
[(name . more)
(raise-syntax-error
'2htdp/planetcute
"the Planet Cute variables cannot be used after an open parenthesis as they are not functions"
stx #'id)])))
;; In case of partial expansion for module-level and internal-defn
;; contexts, delay expansion until it's a good time to lift
;; expressions:
(quasisyntax/loc stx (#%expression #,stx)))))))
(definitions)

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide brown-block)
(require racket/draw racket/runtime-path)
(define-runtime-path brown-block-img "Brown Block.png")
(define brown-block (read-bitmap brown-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide character-boy)
(require racket/draw racket/runtime-path)
(define-runtime-path character-boy-img "Character Boy.png")
(define character-boy (read-bitmap character-boy-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide character-cat-girl)
(require racket/draw racket/runtime-path)
(define-runtime-path character-cat-girl-img "Character Cat Girl.png")
(define character-cat-girl (read-bitmap character-cat-girl-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide character-horn-girl)
(require racket/draw racket/runtime-path)
(define-runtime-path character-horn-girl-img "Character Horn Girl.png")
(define character-horn-girl (read-bitmap character-horn-girl-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide character-pink-girl)
(require racket/draw racket/runtime-path)
(define-runtime-path character-pink-girl-img "Character Pink Girl.png")
(define character-pink-girl (read-bitmap character-pink-girl-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide character-princess-girl)
(require racket/draw racket/runtime-path)
(define-runtime-path character-princess-girl-img "Character Princess Girl.png")
(define character-princess-girl (read-bitmap character-princess-girl-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide chest-closed)
(require racket/draw racket/runtime-path)
(define-runtime-path chest-closed-img "Chest Closed.png")
(define chest-closed (read-bitmap chest-closed-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide chest-lid)
(require racket/draw racket/runtime-path)
(define-runtime-path chest-lid-img "Chest Lid.png")
(define chest-lid (read-bitmap chest-lid-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide chest-open)
(require racket/draw racket/runtime-path)
(define-runtime-path chest-open-img "Chest Open.png")
(define chest-open (read-bitmap chest-open-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide dirt-block)
(require racket/draw racket/runtime-path)
(define-runtime-path dirt-block-img "Dirt Block.png")
(define dirt-block (read-bitmap dirt-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide door-tall-closed)
(require racket/draw racket/runtime-path)
(define-runtime-path door-tall-closed-img "Door Tall Closed.png")
(define door-tall-closed (read-bitmap door-tall-closed-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide door-tall-open)
(require racket/draw racket/runtime-path)
(define-runtime-path door-tall-open-img "Door Tall Open.png")
(define door-tall-open (read-bitmap door-tall-open-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide enemy-bug)
(require racket/draw racket/runtime-path)
(define-runtime-path enemy-bug-img "Enemy Bug.png")
(define enemy-bug (read-bitmap enemy-bug-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide gem-blue)
(require racket/draw racket/runtime-path)
(define-runtime-path gem-blue-img "Gem Blue.png")
(define gem-blue (read-bitmap gem-blue-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide gem-green)
(require racket/draw racket/runtime-path)
(define-runtime-path gem-green-img "Gem Green.png")
(define gem-green (read-bitmap gem-green-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide gem-orange)
(require racket/draw racket/runtime-path)
(define-runtime-path gem-orange-img "Gem Orange.png")
(define gem-orange (read-bitmap gem-orange-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide grass-block)
(require racket/draw racket/runtime-path)
(define-runtime-path grass-block-img "Grass Block.png")
(define grass-block (read-bitmap grass-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide heart)
(require racket/draw racket/runtime-path)
(define-runtime-path heart-img "Heart.png")
(define heart (read-bitmap heart-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide key)
(require racket/draw racket/runtime-path)
(define-runtime-path key-img "Key.png")
(define key (read-bitmap key-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide plain-block)
(require racket/draw racket/runtime-path)
(define-runtime-path plain-block-img "Plain Block.png")
(define plain-block (read-bitmap plain-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide ramp-east)
(require racket/draw racket/runtime-path)
(define-runtime-path ramp-east-img "Ramp East.png")
(define ramp-east (read-bitmap ramp-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide ramp-north)
(require racket/draw racket/runtime-path)
(define-runtime-path ramp-north-img "Ramp North.png")
(define ramp-north (read-bitmap ramp-north-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide ramp-south)
(require racket/draw racket/runtime-path)
(define-runtime-path ramp-south-img "Ramp South.png")
(define ramp-south (read-bitmap ramp-south-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide ramp-west)
(require racket/draw racket/runtime-path)
(define-runtime-path ramp-west-img "Ramp West.png")
(define ramp-west (read-bitmap ramp-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide rock)
(require racket/draw racket/runtime-path)
(define-runtime-path rock-img "Rock.png")
(define rock (read-bitmap rock-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-east)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-east-img "Roof East.png")
(define roof-east (read-bitmap roof-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-north-east)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-north-east-img "Roof North East.png")
(define roof-north-east (read-bitmap roof-north-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-north-west)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-north-west-img "Roof North West.png")
(define roof-north-west (read-bitmap roof-north-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-north)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-north-img "Roof North.png")
(define roof-north (read-bitmap roof-north-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-south-east)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-south-east-img "Roof South East.png")
(define roof-south-east (read-bitmap roof-south-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-south-west)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-south-west-img "Roof South West.png")
(define roof-south-west (read-bitmap roof-south-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-south)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-south-img "Roof South.png")
(define roof-south (read-bitmap roof-south-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide roof-west)
(require racket/draw racket/runtime-path)
(define-runtime-path roof-west-img "Roof West.png")
(define roof-west (read-bitmap roof-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide selector)
(require racket/draw racket/runtime-path)
(define-runtime-path selector-img "Selector.png")
(define selector (read-bitmap selector-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-east)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-east-img "Shadow East.png")
(define shadow-east (read-bitmap shadow-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-north-east)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-north-east-img "Shadow North East.png")
(define shadow-north-east (read-bitmap shadow-north-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-north-west)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-north-west-img "Shadow North West.png")
(define shadow-north-west (read-bitmap shadow-north-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-north)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-north-img "Shadow North.png")
(define shadow-north (read-bitmap shadow-north-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-side-west)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-side-west-img "Shadow Side West.png")
(define shadow-side-west (read-bitmap shadow-side-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-south-east)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-south-east-img "Shadow South East.png")
(define shadow-south-east (read-bitmap shadow-south-east-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-south-west)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-south-west-img "Shadow South West.png")
(define shadow-south-west (read-bitmap shadow-south-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-south)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-south-img "Shadow South.png")
(define shadow-south (read-bitmap shadow-south-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide shadow-west)
(require racket/draw racket/runtime-path)
(define-runtime-path shadow-west-img "Shadow West.png")
(define shadow-west (read-bitmap shadow-west-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide speechbubble)
(require racket/draw racket/runtime-path)
(define-runtime-path speechbubble-img "Speechbubble.png")
(define speechbubble (read-bitmap speechbubble-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide stone-block-tall)
(require racket/draw racket/runtime-path)
(define-runtime-path stone-block-tall-img "Stone Block Tall.png")
(define stone-block-tall (read-bitmap stone-block-tall-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide stone-block)
(require racket/draw racket/runtime-path)
(define-runtime-path stone-block-img "Stone Block.png")
(define stone-block (read-bitmap stone-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide tree-short)
(require racket/draw racket/runtime-path)
(define-runtime-path tree-short-img "Tree Short.png")
(define tree-short (read-bitmap tree-short-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide tree-tall)
(require racket/draw racket/runtime-path)
(define-runtime-path tree-tall-img "Tree Tall.png")
(define tree-tall (read-bitmap tree-tall-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide tree-ugly)
(require racket/draw racket/runtime-path)
(define-runtime-path tree-ugly-img "Tree Ugly.png")
(define tree-ugly (read-bitmap tree-ugly-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide wall-block-tall)
(require racket/draw racket/runtime-path)
(define-runtime-path wall-block-tall-img "Wall Block Tall.png")
(define wall-block-tall (read-bitmap wall-block-tall-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide wall-block)
(require racket/draw racket/runtime-path)
(define-runtime-path wall-block-img "Wall Block.png")
(define wall-block (read-bitmap wall-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide water-block)
(require racket/draw racket/runtime-path)
(define-runtime-path water-block-img "Water Block.png")
(define water-block (read-bitmap water-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide window-tall)
(require racket/draw racket/runtime-path)
(define-runtime-path window-tall-img "Window Tall.png")
(define window-tall (read-bitmap window-tall-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide wood-block)
(require racket/draw racket/runtime-path)
(define-runtime-path wood-block-img "Wood Block.png")
(define wood-block (read-bitmap wood-block-img))

View File

@ -0,0 +1,5 @@
#lang racket/base
(provide yellow-star)
(require racket/draw racket/runtime-path)
(define-runtime-path yellow-star-img "Yellow Star.png")
(define yellow-star (read-bitmap yellow-star-img))