0

I have also compiled some notes on Dr Scheme, in an attempt to get my little brother to do something besides play Runescape. I know these are incomplete, but here they are just the same:
http://download.plt-shceme.org/doc/208/hmtl/mred/index.htm

Notes on Mr. Ed relevant to my work: (Section One)

Create a Frame:

(define frame (instantiate frame% (“Example)))

frame: anything, this is variable X
Anything with % cannot be replaced with something else unless otherwise noted.
In this case, that means frame% must be copied exactly. “Example can be replaced with up to 200 characters of text.

Create a Message:

(define msg (instantiate message% (“example frame)))

msg: anything, this is variable Y
“example is the message itself, and frame is variable X.

Create a Button with reaction:

(instantiate button% () (label “click me)(parent frame)

label is the buttons label, and frame is variable X.

(callback (lambda (button event)(send msg set-label “button click))))

The above line of code must be copied exactly, except msg is variable Y, set-label can be a different command, and msg can be replaced with something like variable X followed by the show command. (send frame show #t) will make the frame visible to the user. A callback must be immediately after the button it was made for.

Full Simple Program:

(define frame (instantiate frame% (“Example)))
(define msg (instantiate message% (“example frame)))
(instantiate button% () (label “click me)(parent frame)
(callback (lambda (button event)(send msg set-label “button click))))

This will cause a window to appear on screen. It will be titled example, have the word example inside it, and if you click the click me button, the word example will become the wrods button click.


Scheme Notes: (Section Two)

Multiple Button Events:

A callback can have multiple effects on a program by adding send commands: Example:

(define frame (instantiate frame% (“Example)))
(define msg (instantiate message% (“example frame)))
(instantiate button% () (label “click me)(parent frame)
(callback (lambda (button event)(send msg set-label “button click))))

If you change the fourth line of code to this:

(callback (lambda (button event)(send msg set-label “button click) (send frame show #f))))

Then after displaying the message, the window will disappear. Problem is, you will not be able to read the message.

I will update these whenever I create a new section, or end a section that cuts out in the middle.

1
Contributor
2
Replies
5
Views
12 Years
Discussion Span
Last Post by mister-fett
0

I cant find the edit button on this forum, (is there even an edit buton in this part of the forum so I can fix this?) So I am posting the following excecutable that uses the above code. You do have to click unzip it with winzip, then double click it, and its crappy, but it is an example. Later, maybe tomorrow or something, I will make a longer text game and post it, and maybe next month it will have pictures. Depends on how fast I can learn Mr. Ed.

0

(Aha! You cant edit a post afer a certain amount of time! wait... that sucks... :cry: :cry: )
I am working on an actual text adventure game now, which I will move to a freewebs site and proboards forum soon, but for now, I am looking for people who know or want to know scheme and are interested in an open source project. This will be a text adventure game, with possible graphics and sound. I am working on a plot and all that lovely monkey doo, but for now, here is what I have:

(define start (instantiate frame% ("Welcome to the land of land")(x 150)(y 150)(height 300)(width 500)))
(define line1 (instantiate message% ("You find yourself in a room. In this room are a wand and a sword." start)))
(define line2 (instantiate message% ("Obvious exits are North and South. Areas of the room may be hidden." start)))
(instantiate button% () (label "Pick up sword")(parent start)
  (callback (lambda (button event) (send sword show #t)(send start show #f))))
(instantiate button% () (label "Pick up wand")(parent start)
  (callback (lambda (button event) (send wand show #t)(send start show #f))))
(instantiate button% () (label "Search the room") (parent start)
  (callback (lambda (button event) (send gos1 show #t)(send start show #f))))
(send start show #t)
(define sword (instantiate frame% ("You have the sword in hand...")(x 150)(y 150)(height 300)(width 500)))
(define sl1 (instantiate message% ("The sword is heavy, but you know you can wield it in combat." sword)))
(define sl2 (instantiate message% ("Which exit will you take?" sword)))
(define wand (instantiate frame% ("You have the wand in hand...") (x 150)(y 150)(height 300)(width 500)))
(define wn1 (instantiate message% ("You fell great power as you pick up the wand..." wand)))
(define wn2 (instantiate message% ("But the moment is ruined as you fart loudly." wand)))
(define gos1 (instantiate frame% ("Darn but your stupid...")(x 150)(y 150)(height 300)(width 500)))
(define gos1m1 (instantiate message% ("You search the room, setting off several traps. You dead!" gos1)))

I attached the zip to this post. Anyhoo, this is just the first three rooms, and this code will probably be taken out or written more efficiently later, its just a demo for a demo for a demo.

:mrgreen:

PM or email me if you want in, or want me to send you some meager tutorials I made for Dr Scheme. I will post a link when I move the project to a freewebs/proboards type site.

P.S. This is written inn the GUI part of Dr Scheme, Mr. Ed.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.