Log inRegister an accountBrowse CSDbHelp & documentationFacts & StatisticsThe forumsAvailable RSS-feeds on CSDbSupport CSDb Commodore 64 Scene Database
You are not logged in - nap
CSDb User Forums


Forums > C64 Coding > how to analyze this playfield...
2008-06-19 22:36
tasche
Account closed

Registered: Apr 2004
Posts: 12
how to analyze this playfield...

just take a look at the following gfx:



as u see its a matrix of some squares. u see a bunch of yellow squares surrounded by a red line.

if i pick ONE of these squares in the bunch, the complete bunch shall be selected automaticly.

now my problem: how to calc this?
anybody out there, who got the right hint?
2008-06-19 23:55
Codey

Registered: Oct 2005
Posts: 79
you can examine the cells adjacent of the one that was clicked. if they're the same color select them also and repeat the process for the new cells. recursively this should work although it's not very time efficient.
2008-06-20 04:57
Oswald

Registered: Apr 2002
Posts: 5094
exactly. but you can skip the recursion. simply attach an attribute to each cell.

fex:

0: dont bother
1: was selected as a neighbour & same color in the prev run
2: neighbours already marked, belongs to selection.


then you do this:

0: do nothing
1: mark "0" neighbours as "1", change own attribute to 2
2: do nothing

if you run out of 1's then you're finished.
2008-06-20 08:40
Radiant

Registered: Sep 2004
Posts: 639
http://en.wikipedia.org/wiki/Flood_fill

The scanline algorithm mentioned there is AFAIK the fastest method of solving this problem, at least for larger areas. For small areas the "normal" stack based solution may be faster.
RefreshSubscribe to this thread:

You need to be logged in to post in the forum.

Search the forum:
Search   for   in  
All times are CET.
Search CSDb
Advanced
Users Online
Alakran_64
TheRyk/MYD!
Mibri/ATL^MSL^PRX
Mike
MWR/Visdom
DanPhillips
Rub_0201
LKP/CFN
megasoftargentina
Kakka/Extend, Damone..
Francois Prijt/Audia..
wil
Laddh
tlr
Guests online: 112
Top Demos
1 Next Level  (9.7)
2 13:37  (9.7)
3 Mojo  (9.7)
4 Coma Light 13  (9.6)
5 Edge of Disgrace  (9.6)
6 What Is The Matrix 2  (9.6)
7 The Demo Coder  (9.6)
8 Uncensored  (9.6)
9 Comaland 100%  (9.6)
10 Wonderland XIV  (9.6)
Top onefile Demos
1 No Listen  (9.6)
2 Layers  (9.6)
3 Cubic Dream  (9.6)
4 Party Elk 2  (9.6)
5 Copper Booze  (9.6)
6 Dawnfall V1.1  (9.5)
7 Rainbow Connection  (9.5)
8 Onscreen 5k  (9.5)
9 Morph  (9.5)
10 Libertongo  (9.5)
Top Groups
1 Performers  (9.3)
2 Booze Design  (9.3)
3 Oxyron  (9.3)
4 Censor Design  (9.3)
5 Triad  (9.3)
Top Logo Graphicians
1 t0m3000  (10)
2 Sander  (9.8)
3 Mermaid  (9.5)
4 Facet  (9.4)
5 Shine  (9.4)

Home - Disclaimer
Copyright © No Name 2001-2024
Page generated in: 0.033 sec.