COSC 3550 - Computer Games
Assignment #2
Animation and Interaction

Due Date: Monday, February 3, 2020

GOAL: You should produce a JavaFX program which involves both animation and user input. That is, there should be some part of the display which is moving or changing based on an animation loop (such as the ball in Pong) and some part which depends on user input (such as the paddles in Pong). You could have the user input directly control some shape on the screen, or you could have the user input do something like change colors or speeds of shapes in the animation. Your program should draw on a single Canvas (like all the examples in class) rather than use a complicated scene graph.

The hardest part of this assignment will be to keep it simple! We'll be talking about how to organize complicated games with lots of scenery and moving pieces - don't try to do that now. Think in terms of two or three simple shapes moving around on the screen.

For instance, here's one suggestion. Write a simple shooting gallery game. Your mouse would control a gun which moves up and down along the left side of the display window. Clicking the mouse button fires a bullet horizontally across the screen. The bullet continues across the screen until it hits a target or reaches the right-hand side of the screen. The target appears at random locations on the screen, stays there a while, and then disappears (and appears somewhere else). If a target is hit by a bullet, the target disappears and the player receives one point. Then the target reappears somewhere else. Your program (showing a round bullet moving toward a square target from the trapezoidal gun) might look something like:

METHOD: You should use boiler-plate code for [Animation and events with initialization] (like Fly or Pong) as discussed in class. The input will require setting up event handlers for the mouse or keyboard as needed.

The details of how to update each step in your animation will depend on the effects you are trying to achieve. You could use a Finite State Machine to control frame changes, or movement could be based on simulated Physics. For an explanation of how to simulate falling under gravity and bouncing, see the pages on Movement and Bouncing and Gravity.

HAND-IN: You should submit a copy of your .java file before 11:59PM on Monday using D2L. Be sure that your program includes comments saying who wrote it. Also, either your code or a separate file should explain what the program does and how to work it (what input is expected).