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