Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Discussion / Flood Fill Function problem need help

Author
Message
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 27th Jan 2009 23:55 Edited at: 27th Jan 2009 23:55
I'm having a bit of problem with my Function, it works for the most part but has bugs. And I'm not sure how to fix it. It should work but somehow it keep doing that.

I get a problem when I click on the X mark on the screen shot. It depends where it's starting, if I click else where the problem might now show up.




Here's the code:
Quadrazar
17
Years of Service
User Offline
Joined: 7th Jan 2009
Location: onboard the Kobayashi Maru
Posted: 28th Jan 2009 01:38 Edited at: 28th Jan 2009 01:41
here's a solution [ partialy in pseudocode ] that might help you.





I don't have basic installed, so I'm not shure if it works in basic. (there are two things I'm not shure of. Can functions return a value? Can functions call themselves? If the answer is yes on both, give this solution a try.

Amiga 500 - 68000 processor / 7 Mhz, 512 Kb RAM, 4-channel PCM synthesizer (stereo)
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 28th Jan 2009 02:00 Edited at: 28th Jan 2009 16:32
Yes to both of them, I'll give this a try.

[edit]

Actually I know of that version, it's the 4 way recrusive method and well it's kinda slow.

[edit]

Ok nvm I got it working correctly now although it's still not as fast.
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 31st Jan 2009 03:51
are you talking about fill like on paint. if so i would be very interested in the completed function or some tips on how to start making one because i don't even know where to start
Ashingda 27
18
Years of Service
User Offline
Joined: 15th Feb 2008
Location:
Posted: 31st Jan 2009 04:47
Yes it's like the fill bucket on paint. I have a fully working function on it, the updated version is posted on the code snippets thread but I can post it here too.

I'm thinking of writing a tutorial on it as I'm starting to understand floodfill methods very well, but that's only if anyone might be interested in it?

Here's my latest FloodFill for DBC, works with both 16bit and 32bit display modes. This is also a working example.


This one is a slower version I used to figure out the algorithm. It displays how the function scans the screen and plot the pixels. At the end if it all it displays how many times it scaned each pixels and how many scans it performed in total.


Ultimately what you would want in a floodfill is to have it scan the least amount of times possible and still performs it's job.

I'm still having a bit of recrusions here and there although it's quite minor it's bothersome. I'll like it to be done with just 1 scan per each pixels.
Libervurto
20
Years of Service
User Offline
Joined: 30th Jun 2006
Location: On Toast
Posted: 12th Feb 2009 23:37
@Caleb
That pathfinding routine I talked you through could be used as a flood fill routine, just drop some colour wherever the player goes.

The Universe has been erased by a mod because it was larger
than 240x80 pixels.
Caleb1994
17
Years of Service
User Offline
Joined: 10th Oct 2008
Location: The Internet you idiot!
Posted: 13th Feb 2009 06:30
oh ya good idea! lol


actually i refined that a while back but the problem i was having was getting the grid set up correctly but in like 5 minutes i just got a grid and collision for a player moving around the grid hahaha and realized that i used the method you tought me without thinking about it hahaha i think i just didn't have enough experience with 2d and arrays and stuff yet

Login to post a reply

Server time is: 2026-07-11 13:53:10
Your offset time is: 2026-07-11 13:53:10