Help - Search - Members - Calendar
Full Version: Area Checking
Game Maker Community > Working with Game Maker > Advanced Users Only
Flamer_Shaftglutton
This is an issue I have with design, not coding.

In my game, I have something like this:



The arrow is controlled by the player. The red ball bounces off the edges of the white space, and the goal is to cut away at the white space until a certain percentage is left. You move the arrow to make shapes in the white space to cut out, but I'm not sure how to figure this part out.



Such as in this case. The green is supposed to be cut off, but here's what needs to happen:

1. Determine what constitutes the shape to cut out. Which pixels are in, which are out.
2. Determine which side the ball is on. I can do this if #1 is done.
3. Make the pixels to be cut off transparent. Easy.

However, the difficulty comes from figuring out which pixels to cut out. If I were to somehow cut a square around the ball, I would have to remove all the pixels outside of the square. The fish does not necessarily come back to the point where it started the shape, as in the second diagram.

Coding is not the problem, I am fully capable of coding this if I can just figure out the logic behind this.
ragarnak
QUOTE (Flamer_Shaftglutton @ Nov 7 2009, 05:23 AM) *
if I can just figure out the logic behind this.
What about : Create a "fill" for both areas, and determine which of the two collides with the ball (using two sprites ?). Throw that one away and apply the other one.
QUOTE
The fish does not necessarily come back to the point where it started the shape, as in the second diagram.
Just assume that when the fish hits the blue space head-on and either on its left, right or both are white pixels it has been outside the blue area/has created a shape.
jabelar
I think you might be able to make use of the built in path finding functions. Because if there is a path between the ball and a point then that point is outside the shape. Of course that means you have to somehow tag the blue area as an obstacle (perhaps you could make the whole thing a sprite of an object, or you can run the whole thing on a grid and use grid based motion planning).

Just a thought ...
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2009 Invision Power Services, Inc.