[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[NOISE] Curly braces [was Re: Curl]

> Don't keep us in suspense; which scheme variant? [has explicit close

I used a language called "GameKit" that some of us at MIT designed for
writing simple video games.  The goal was to make something that people
who had never coded before would have a chance of understanding.  It is
designed for game programming, with primitives like finite state
machines and collision detection built right into the language.  This
made it possible to write a space-invaders clone in about 200 lines
(including loading screens and animations), which is about the
attention span of a first time casual programmer.

Below is a sample of the Player class from the space invaders game. 
You can see the explicit un-curls.  Note that the language gravitated
away from its functional roots to a purely imperative style... but
interestingly, one in which pointers are not first class.  When an
object is created, the programmer loses control over it until an event
handler is triggered.  Only inside an event handler are pointers to
objects available.  This is pure object oriented programming, and is
reasonably well suited to games because they are simulations.  I can't
imagine trying to program anything other than physical simulation or AI
with it, however.

    ;; The Player class.  Player is the object controlled
    ;; by the user.
      NORMAL{  ; What to do normally
        ; If the Left arrow key is pressed, then move
        ; the player graphic left by ten grid points.
        If Keyboard.left = "true" {
          MoveLeft Me 10

        ; If the Right arrow key is pressed, then move
        ; the player graphic right by ten grid points.
        If Keyboard.right = "true" {
          MoveRight Me 10

        ; To keep too many missiles from getting fired at once, we
        ; will force the player to fire only 1 every 20 frames
        If counter$missile-delay = 0{
          ; If the space bar is pressed, fire a missile
          If Keyboard.space = "true" {
            Create Missile "Missile" "Missile" 90 3 Me.x Me.y 0
            set counter$missile-delay 12
          ;; Count down to missile firing
          change counter$missile-delay -1

      COLLISION{  ; What to do if I hit a sprite
        If It.class = Alien {
          destroy It                ; Destroy whatever got hit
          Change Counter$armor -10  ; Take 10 away from the player's

      MAPCHANGE{  ; What to do if the map type underneath me changes
        ; Green squares are used on the map to mark the edges of
        ; where the player can move.  If the player moved onto
        ; a green square, move them back.
        If Me.green = "true" {
          Unmove Me

Morgan McGuire  

Do You Yahoo!?
Yahoo! GeoCities - quick and easy web site hosting, just $8.95/month.