Java-Gaming.org    
Featured games (79)
games approved by the League of Dukes
Games in Showcase (477)
Games in Android Showcase (106)
games submitted by our members
Games in WIP (533)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [SOLVED] How should I replicating the fill or bucket tool in a 2d array?  (Read 787 times)
0 Members and 1 Guest are viewing this topic.
Offline doppler

Senior Member


Medals: 10
Projects: 5



« Posted 2013-02-20 02:10:21 »

Edit: Found a solution online while researching Flood Filling thanks to actual. It's a simple recursive method that works very well. Here's a link to the javascript example (also doable in Java): http://www.somethinghitme.com/2012/03/07/html5-canvas-flood-fill/

I'm currently working on a level editor for an Android game. My goal is to add cool tools such as:

  • pencil: Add single textures to the grid
  • eraser: remove texture from grid
  • bucket: fill in neighbor textures

I can't seem to find any tutorials on how to fill in an arbitrary geometric area for the bucket tool. I'm not necessarily looking for source code, I just can't seem to figure out how to go about filling in parts of a 2d array. I've considered using path-finding techniques, but I feel there may be a simple solution. Here is an image of what I'm dealing with:


I've created many level editors in the past, but never played around with the bucket tool idea. If you have any thoughts, please post about it; I'm sure other people would like to know how to do this as well. Thanks in advance!

PS - This tool is being written from HTML 5's Canvas (Javascript), not Java. I've worked with both, so syntax isn't really a problem; I'll take any pseudo code.

Practice! Practice! Practice!
Offline actual

JGO Coder


Medals: 23



« Reply #1 - Posted 2013-02-20 02:27:26 »

The term you are looking for is Flood Fill or Boundary Fill.
Offline doppler

Senior Member


Medals: 10
Projects: 5



« Reply #2 - Posted 2013-02-20 03:15:02 »

That's exactly what I was looking for! Thank you for the quick response.

Practice! Practice! Practice!
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

pw (26 views)
2014-07-24 02:59:36

Riven (25 views)
2014-07-23 22:16:32

Riven (19 views)
2014-07-23 22:07:15

Riven (22 views)
2014-07-23 21:56:16

ctomni231 (51 views)
2014-07-18 07:55:21

Zero Volt (46 views)
2014-07-18 00:47:54

danieldean (37 views)
2014-07-18 00:41:23

MustardPeter (40 views)
2014-07-17 00:30:00

Cero (56 views)
2014-07-16 01:42:17

Riven (55 views)
2014-07-14 19:02:53
HotSpot Options
by dleskov
2014-07-08 04:59:08

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 01:58:24

Java and Game Development Tutorials
by SwordsMiner
2014-06-14 01:47:22

How do I start Java Game Development?
by ra4king
2014-05-17 12:13:37

HotSpot Options
by Roquen
2014-05-15 10:59:54

HotSpot Options
by Roquen
2014-05-06 16:03:10

Escape Analysis
by Roquen
2014-04-29 23:16:43

Experimental Toys
by Roquen
2014-04-28 14:24:22
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!