added chat noir

svn: r11944
This commit is contained in:
Robby Findler 2008-10-05 20:32:26 +00:00
parent 2b5e42850d
commit baf98c4136
7 changed files with 1093 additions and 0 deletions

View File

@ -0,0 +1,21 @@
#lang scheme/base
(require scheme/unit
scheme/runtime-path
(prefix-in x: lang/htdp-intermediate-lambda)
(prefix-in x: htdp/world))
(provide game@)
(define orig-namespace (current-namespace))
(define-runtime-path chat-noir "chat-noir.ss")
(define-unit game@
(import)
(export)
(define ns (make-base-namespace))
(parameterize ([current-namespace ns])
(namespace-attach-module orig-namespace
'(lib "htdp-intermediate-lambda.ss" "lang"))
(namespace-attach-module orig-namespace
'(lib "world.ss" "htdp"))
(dynamic-require chat-noir #f)))

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,2 @@
#lang scheme/base
(provide make-hash hash-set! hash-ref hash-map)

View File

@ -0,0 +1,5 @@
#lang setup/infotab
(define game "chat-noir-unit.ss")
(define game-set "Puzzle Games")
(define compile-omit-files '("chat-noir.ss"))

View File

@ -0,0 +1,59 @@
#lang scribble/doc
@(require "common.ss")
@(require scheme/runtime-path (for-syntax scheme/port scheme/base))
@(define-runtime-path cn "../chat-noir/chat-noir.ss")
@gametitle["Chat Noir" "chat-noir" "Puzzle Game"]
This game is written in the
@link["http://www.htdp.org/"]{How to Design Programs}
Intermediate language. It is a model solution to the final project for
the introductory programming course at the University of Chicago in
the fall of 2008. See the source code:
@schemeblock[#,(tt (path->string (simplify-path cn)))]
The goal of the game is to stop the cat from escaping the board. Each
turn you click on a circle, which prevents the cat from stepping on
that space, and the cat responds by taking a step. If the cat is
completely boxed in and thus unable reach the border, you win. If the
cat does reach the border, you lose.
The game was inspired by this one the one at
@link["http://www.gamedesign.jp/flash/chatnoir/chatnoir.html"]{Game
Design} and has essentailly the same rules.
@(define-syntax (m stx)
(syntax-case stx ()
[(_)
(call-with-input-file (build-path (current-load-relative-directory)
'up
"chat-noir"
"chat-noir.ss")
(lambda (port)
(port-count-lines! port)
#`(schemeblock
#,@
(let loop ()
(let ([p (peeking-input-port port)])
(let ([l (read-line p)])
(cond
[(eof-object? l) '()]
[(regexp-match #rx"^[ \t]*$" l)
(read-line port)
(loop)]
[(regexp-match #rx"^ *;+" l)
=>
(lambda (m)
(let-values ([(line col pos) (port-next-location port)])
(read-line port)
(let-values ([(line2 col2 pos2) (port-next-location port)])
(cons (datum->syntax
#f
`(code:comment ,(regexp-replace* #rx" " l "\u00a0")))
(list "chat-noir.ss" line col pos (- pos2 pos)))
(loop))))]
[else
(cons (read-syntax "chat-noir.ss" port)
(loop))])))))))]))
@m[]

View File

@ -22,4 +22,5 @@
@include-section["jewel.scrbl"]
@include-section["parcheesi.scrbl"]
@include-section["checkers.scrbl"]
@include-section["chat-noir.scrbl"]
@include-section["gcalc.scrbl"]