email me at borlaj@portlandschools.org

Loading
notes previous (10/<10) submit the dump links  
 

Frogger

 

You are going to make a very simple version of frogger. See here.

Start with this project and open it up.

 

There are 3 classes in the zip:

  • Bar which is the class for the bars that go back and forth. Look at the notes in that file. You have methods that must finish of that class.
  • BarTester which allows you to test the Bar class. It is just for practice purposes.
  • Frogger - I put in code from one of your moving square (HWJ12) homeworks. It includes a square that you will move around the screen. In this class you will have at least 5 instances of your Bar class and call move, draw, isCollision of each bar.

Due Monday 12/12 by class time.

Rubric 9 points:

  • Code is commented, indented and variables are named appropriately (1.5)
  • Bar Class is correct (5 points)
    • Constructor initalizes a bar with randomX, randomColor, random speed, random direction (.5 each)
    • Ball moves correctly (1)
    • Ball is drawn correctly (1)
    • Collision is detected correctly (1 point)
  • Frogger Class makes game happen (2.5 points)
    • Initializes at least 5 bars (.5 point)
    • Moves and draws them (1 point)
    • Game stops on collision (1 point)

For Block 4, all students need to have reset (1 point) and score (1 point)

 

Hints:

  • Collision - see here
  • After you reset (in the actionperformed), you will need to put requestFocusInWindow() - This brings the focus of the keyboard back to the applet, so you can control the cursor.
  • To add a reset button - look at the gui page
  • For the reset button to appear all the time, go to update and add the line:
    • super.paint(bufferGraphics); immediately after bufferGraphics.fillRect(0,0,500,500)

Advanced people must have this:

 

Have it so if they get to the other side, it will go to the next level (which either has more bars or faster bars [you need to make a way for the bars to increase in speed (maybe a constructor with speed as a parameter)]. It needs to keep track of score. It needs to have a reset button.

Rubric for those advanced people

  • Code is commented, indented and variables are named appropriately (1)
  • Bar Class is correct (3.5 points)
    • Constructor initalizes a bar with randomX, randomColor, random speed, random direction (.5 each)
    • Ball moves correctly (.75)
    • Ball is drawn correctly (.75)
    • Collision is detected correctly (1 point)
  • Frogger Class makes game happen (4.5 points)
    • Initializes at least 5 bars (.5 point)
    • Moves and draws them (1 point)
    • Game stops on collision (1 point)
    • Levels and game gets harder each level (1 point)
    • Score (.5)
    • Reset (.5)

For really advanced, use images of frogs and cars (images in classes here), make a background of roads, make it look good and fun to play - just right amount of challenging.