Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Java Assistance

Name: Student !HXEkJ/9fP6 2010-05-20 19:44

I am in need of assistance and I'm not sure if /prog/ does this sort of thing, but I'm asking anyway.
I'm currently writing my Final Project for my Java course and it is a game, a relatively simple game. The issue I'm having is collision. The point of the game is to keep your square from being hit by circles, and in the early stages of writing it, I had a detection system based on the coordinates of the start of the rectangle, and the start of the circle, plus the width and height of each, using the g2d.fillRect(x,y,w,h) and the g2d.fillOval(x,y,w,h)m however, during the course of editing, this stopped working for whatever reason.
My question basically boils down to this:
Is there a way to using the pixel colors to detect collision, something like,
if(bluePixel touches greenPixel)
collision = true;
If this is not possible, then shit.
If so, please assist me.

Name: Anonymous 2010-05-20 20:46

>>1
Just a reminder, bro - you're talking about programming, everything is possible. Now the question is whether you actually should do it the way you described (answer: no, it's a stupid idea).

There's a lot of literature around the Internet about collision detection, I suggest that you look around and read some. Just a hint: comparing stuff per-pixel is generally a bad idea. You're testing whether two simple geometrical shapes intersect or not - you most definitely don't need to render them first, and if you can't think of a different way to do it then maybe programming isn't for you.

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List