Jump to content


Photo

Area Within A Space


  • Please log in to reply
12 replies to this topic

#1 King Killa

King Killa

    <-- ?Which Way? -->

  • New Member
  • 572 posts

Posted 23 August 2009 - 08:26 AM

I haven't really used Game Maker in a while so I'm kind of rusty, but the other day I had a cool idea I thought I'd make a quick game out of. One thing I need to know though..

How can I tell how big the area is in a space between objects? I need to be able to measure it, say, in pixels so that this number is added to the score.

For example..

Posted Image

How can I tell how much space is in the red area?

I will be using GM 7 PRO, however have not done anything yet.

Edited by King Killa, 24 August 2009 - 10:43 AM.

  • 0

#2 cephei

cephei

    GMC Member

  • GMC Member
  • 801 posts

Posted 23 August 2009 - 09:32 AM

i believe you want to do something similar to flood fill . you should google for that:

floodfill site:gmc.yoyogames.com

=)

Edit: duh. spelling mistakes xD

Edited by cephei, 23 August 2009 - 09:33 AM.

  • 0

#3 King Killa

King Killa

    <-- ?Which Way? -->

  • New Member
  • 572 posts

Posted 23 August 2009 - 09:41 AM

I had no idea at all it would be anything complicated :) Pretty ignorant of me.

How can I derive the amount of space is actually within the floodfilled area?

I see a 'direct approach' example of using the floodfill which I have downloaded. Is there anyway I can modify that to tell me how much space is in there?
  • 0

#4 cephei

cephei

    GMC Member

  • GMC Member
  • 801 posts

Posted 23 August 2009 - 09:45 AM

I had no idea at all it would be anything complicated :) Pretty ignorant of me.

How can I derive the amount of space is actually within the floodfilled area?

I see a 'direct approach' example of using the floodfill which I have downloaded. Is there anyway I can modify that to tell me how much space is in there?


Since i dont know what you are using there i cannot tell for sure. Maybe you can replace draw_pixel() with counter = counter + 1; and draw line with counter = counter + (x1-x2) ...
  • 0

#5 King Killa

King Killa

    <-- ?Which Way? -->

  • New Member
  • 572 posts

Posted 23 August 2009 - 09:55 AM

So what you're saying basically is that I can just replace the function that draws the floodfill with a function that adds to the score; while keeping all defined functions and variables the same?

Sounds like it could work to me, one problem though: how would it stop adding to the score? Considering it wouldn't actually be drawing anything on the screen, there wouldn't be a moment when the object thinks that the process has stopped, would there?
  • 0

#6 cephei

cephei

    GMC Member

  • GMC Member
  • 801 posts

Posted 23 August 2009 - 09:57 AM

I'm not sure what you mean. The floodfill will only happen in the room, not going to infinite outer space. Also you have to run floodfill only after the drawing has taken place, not continously. (Flood Fill may freeze the game for a few secs!)
  • 0

#7 King Killa

King Killa

    <-- ?Which Way? -->

  • New Member
  • 572 posts

Posted 23 August 2009 - 10:03 AM

What I mean is, I don't want to actually fill anything. I want to add 1 point to the score for the area within 10 or so objects. So if I am going to change the actual drawing function to something that adds one point, how will it know when to stop?
  • 0

#8 DZiW

DZiW

    GMC Member

  • GMC Member
  • 727 posts

Posted 23 August 2009 - 10:35 AM

want to add 1 point to the score for the area within 10 or so objects

Objects? Then count objects instead.

IMO the case goes wrong right from the problem definition- you try post-process (count) irregular shapes from the screen. As people already mentioned- it would be better to use simultaneous counting when you're drawing it.
  • 0

#9 King Killa

King Killa

    <-- ?Which Way? -->

  • New Member
  • 572 posts

Posted 23 August 2009 - 10:43 AM

The thing is, I don't want to actually draw anything.

Also, counting the objects doesn't work because it's the space inside which matters. The number of objects is irrelevant.
  • 0

#10 cephei

cephei

    GMC Member

  • GMC Member
  • 801 posts

Posted 23 August 2009 - 02:57 PM

maybe you should tell us how those forms are done, i mean does the player draw lines and then it should calculate the space in it?
  • 0

#11 DZiW

DZiW

    GMC Member

  • GMC Member
  • 727 posts

Posted 23 August 2009 - 05:01 PM

It would be nice of you if you use '' OBJECT '' when appropriate.

Anyway, you could
1) use floodfilling just to count the elements (in this case- red pixels) == rather slow;
2) or, even better- count elements while drawing, if possible
3) consider a red shape as axb rectangle and count only non-red (S= a x b - N)
  • 0

#12 Pandaboy

Pandaboy

    GMC Member

  • GMC Member
  • 518 posts

Posted 23 August 2009 - 05:47 PM

I made an example. pm me your email-adress and I will send it :whistle:



edit:

I probably need to explain what this does ;). It is quite simple, and you decide if it is invisible or not.
it just creates a "score calculating pixel" that multiplies itself in empty areas and each adds 1 to the score.
it also deletes itself right after it is done, so the FPS doesn't slow down.

It finishes calculating in a second.

Edited by Pandaboy, 23 August 2009 - 05:50 PM.

  • 0

#13 King Killa

King Killa

    <-- ?Which Way? -->

  • New Member
  • 572 posts

Posted 24 August 2009 - 10:37 AM

I made an example. pm me your email-adress and I will send it :whistle:



edit:

I probably need to explain what this does ;). It is quite simple, and you decide if it is invisible or not.
it just creates a "score calculating pixel" that multiplies itself in empty areas and each adds 1 to the score.
it also deletes itself right after it is done, so the FPS doesn't slow down.

It finishes calculating in a second.

Holy heck. That's exactly the sort of thing I was looking for. Is the example commented?

If not, I can find out out what everything means if I don't understand it.

Thanks so much!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users