The rooms for the final have been determined. 

I will post them soon along with the info who goes where. 

1. Let's practice with ISL big-bang first

http://www.cs.indiana.edu/classes/c211-dgerman/sum2014/hwFive.html

http://www.clker.com/cliparts/5/a/8/7/12375609571200265874pitr_Rocket_icon.svg

(require 2htdp/image)

(define spaceship (circle 30 "solid" "red"))

(define (place-spaceship-at y)
  (place-image spaceship 150 y (empty-scene 400 400)))

(place-spaceship-at 300)

Rendering works, now let's add some events. 

(require 2htdp/image)
(require 2htdp/universe)

(define spaceship (circle 30 "solid" "red"))

(define (place-spaceship-at y)
  (place-image spaceship 150 y (empty-scene 400 400)))

; (place-spaceship-at 300)

(define (main initial) 
  (big-bang initial 
            (on-tick sub1)
            (to-draw place-spaceship-at)
            (stop-when zero?)
            (on-key (lambda (world key) 0))))

I claim action listener and key listener. Timer included. 

(require 2htdp/image)
(require 2htdp/universe)

(define spaceship (circle 30 "solid" "red"))

(define-struct world (x y vx vy)) ; new state 

(define (render world)
  (place-image
   (text (string-append "(" (number->string (world-x world)) ", " 
                            (number->string (world-y world)) ")") 24 "olive")
         100 100 
         (place-image spaceship (world-x world) (world-y world) (empty-scene 400 400))))

(define (update world) 
  (make-world (+ (world-x world) (world-vx world))
              (+ (world-y world) (world-vy world))
              (world-vx world)
              (world-vy world)))

(define (main initial) 
  (big-bang initial 
            (on-tick update)
            (to-draw render)
            (stop-when never)
            (on-key (lambda (world key) 
                      (cond ((equal? key "up") (make-world (world-x world) 
                                                           (world-y world)
                                                           (world-vx world)
                                                           (sub1 (world-vy world)))) 
                            ((equal? key "down") (make-world (world-x world) 
                                                           (world-y world)
                                                           (world-vx world)
                                                           (add1 (world-vy world))))
                            ((equal? key "left") (make-world (world-x world) 
                                                           (world-y world)
                                                           (sub1 (world-vx world))
                                                           (world-vy world)))
                            ((equal? key "right") (make-world (world-x world) 
                                                           (world-y world)
                                                           (add1 (world-vx world))
                                                           (world-vy world)))
                            (else world)))))) 

(define (never world) false)

(define initial (make-world 200 200 1 1))

This is the end of remembering. 

Try the code above with (main initial)

2. How do we do this in Java? 

(a) Define a meaningful BigBang class

(b) Use it to implement the above

Attendance: Wenhao W, Alex N, Nick R, Kaundinya P, Daniel D, Patrick G, James D, 
Yongchao Hu, Abigail F, Mingming L, Alan R, Carlie B, Yaxin T, Xiaohang L, Jarod E, 
Tyler R, Isaac F, Ethan L, Rob B, Shayan K, Peyton R, Jonah W, Steven R, Hongjian J,
Austin C, Robert W, Tyler D, Likang X, Clint S, Lucas K, Kevin Jiawei Z, Qin N, 
Jeremy D, Nick H, Sam Maginot, Tim M, Liyuan H, Caige W. and Jinjin Fan (*). 

So we implement (a) as follows:

import java.awt.*; 
import java.awt.event.*; 
import javax.swing.*;

class BigBang extends JComponent implements KeyListener, ActionListener {
  Timer timer;
  World world;
  BigBang(World world) {
    this(1000, world); 
  }
  BigBang(int delay, World world) {
    this.world = world;
    this.timer = new Timer(delay, this);
  }
  public void start() {
    timer.start();  
  }
  public void keyPressed(KeyEvent e) { 
    System.out.println("Ouch"); 
  }
  public void keyReleased(KeyEvent e) { }
  public void keyTyped(KeyEvent e) { }
  public void actionPerformed(ActionEvent e) { 
    world.update(); 
  }
  public void paintComponent(Graphics g) {
    world.draw(g); 
  }
}

Notice this relies on 

import java.awt.*; 

class World {
  public void update() { 
    System.out.println("Time passes."); 
  } 
  public void draw(Graphics g) {
     
  }
}

Finally, the actual game looks as follows:

import javax.swing.*; 

class Game extends BigBang {
  Game(World world) {
    super(world); 
  }
  public static void main(String[] args) {
    Game a = new Game(new World()); 
    JFrame f = new JFrame("First attempt");
    f.setVisible(true);
    f.setSize(400, 400);
    f.getContentPane().add( a );
    f.addKeyListener( a ); 
    a.start(); 
  }
}

--