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: Am I on /prog/ or /sci/? 2010-05-20 20:57

>>1
Start by making sure the objects are within each others's bounding regions.

Proving that, construct the equation of the ellipse and then get the vector between the center of the ellipse to the rectangle.
Turn that vector into a y = x line equation.  Also, render the equation for the ellipse into y = x form.
Make the two equations equal to each other - y = y - and solve for an x.  There can be one or more x values depending on how much the shapes can embed themselves in each other before being collision checked.

From x, get (all) y values.  If you have more than one set of x,y pairs, and you need or want one, average them out or re-use the vector between the two shapes's centers.

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