Notes 3

Would like to cover.

Review - Review - Review

Collision Detection in Jean-Eric's program. Good example.

Code toolboxes.

I know I covered way too much information over the past two weeks and I would like to reveiw it.

Java thread still running.

HSV color model

Making nice images.

Using images for menus.

Using images for scoring.

Using images for backgrounds.

How to draw images in java (chapter 5)

// to load an image
dolly = tk.getImage("sheep2.gif");

// set up the media tracker to wait for the image
MediaTracker tracker = new MediaTracker(this);
tracker.addImage(dolly,0);

// wait for the image to load
try
{
tracker.waitForID(0);
}
catch (InterruptedException e)
{
e.printStackTrace();
}

System.out.println("Loaded dolly="+dolly+" wid="+dolly.getWidth(null)+" hei="+dolly.getHeight(null));

-----------------------------------------------------------

// to draw the image
if (dolly!=null)
{
dbg.drawImage(dolly,dollyPos.x,dollyPos.y,this);
}

How to animate menu images.

How to create a three sequence animation.

8 directional images, which to choose from.

Start images facing North, rotate clockwise.

find the angle between North and the current direction (velocity).

Point2D.Double ptN = new Point2D.Double(0,-1); // north
Point2D.Double ptV = new Point2D.Double(0,1); // velocity
double dot = ptN.x*ptV.x + ptN.y*ptV.y;
double magN = Math.sqrt(ptN.x*ptN.x+ptN.y*ptN.y);
double magV = Math.sqrt(ptV.x*ptV.x+ptV.y*ptV.y);

double theta = Math.acos(dot / (magN*magV));

http://members.tripod.com/~Paul_Kirby/vector/Vdotproduct.html

 

 

Questions

When I try to run the worm I get this message:
Note: Obstacles.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
What does it mean and how can I recompile it?

Posible homework assignments.

Create nice images for the twiddle game. Think about the menu art in terms of your own game as you will be able to reuse this menu and just change the underlying game later. This could give you a jump start on the final project. You need the Play Game and Quit Game to have an animated hover image. The twiddle element needs an image and should preferably have three different sequences in the movement.

CPSC370 - Games Development
Chapman University
Instructor: W. Wood Harter
(c) copyright 2006 - W. Wood Harter - All Rights Reserved
Screen shots on banner (c) copyright their resprective owners