Collision detection, simple 2d scroller

Hi,

I am writing a very simple 2d scroller/platformer game for my computer science course at college, using Java 1.3. I have movement, sound and jumping all working, and the next challenge is 2d collision detection, in particular detecting when to stop moving the character when they jump onto the platform. The way I though of doing it was having a large (but not too big) jpg background with the platform actually drawn on, and the points plotted out, eg from 100 to 200 on the X, and at a height of 40. Whenever the character jumps, a method is called to check if it has collided with the points, if it has then it stops, if not it continues on.

The rough algorithm I have been using in the method is this:

if((xPos > boundry1startX) && (xPos < boundry1stopX)) && (((yPos+walk1.getHeight(this)) < boundry1startY)

where xPos is the x coord of the character, yPos is the y co-ord of the character, and start/stopX and startY map the boundaries of the platform.

Any help or tutorials would be greatly appreciated, and remember this is a simple game. I know there are better ways than a large image with points mapped, but I just want to get something basic working first.

Cheers.

[1248 byte] By [Chewy2k] at [2007-9-27 20:37:00]
# 1
Edit: brackets were dodgy in my example.if((xPos > boundry1startX) && (xPos < boundry1stopX) && ((yPos+walk1.getHeight(this)) < boundry1startY))is better ;)
Chewy2k at 2007-7-7 1:46:26 > top of Java-index,Other Topics,Java Game Development...
# 2
have a look at http://www.javage.net/cgi-bin/showArt.cgi?index=11
jdcanki at 2007-7-7 1:46:27 > top of Java-index,Other Topics,Java Game Development...
# 3
Ah, that looks like the ticket. I'll give it a shot tonight.
Chewy2k at 2007-7-7 1:46:27 > top of Java-index,Other Topics,Java Game Development...
# 4
Yup, that was it. Using the tute, I changed my code to:if ((adjX+walk1.getWidth(this)>startX) && (startX+xLength>adjX) && (yPos+walk1.getHeight(this)>startY) && (startY+yLength>yPos)) stop = true;and it worked well. Cheers.
Chewy2k at 2007-7-7 1:46:27 > top of Java-index,Other Topics,Java Game Development...