Example

Array Flood fill

4

Dan 2021-03-28 15:15 (Edited)

This is like the Paint Brush's flood fill tool, but it is done on an array.

Usage:
Click on the Squares to fill up the colors.

Press the keys 1-9 to fill up the selected color.
Press space to switch between Flood fill and Drawing mode.

Update: shortened the code by about 25+ lines.

Have fun !

Array-FloodFill.nx | Open in app
2021-03-28 15:15

was8bit 2021-03-28 15:59

There are a few ways you can simplifiy your code... for example...

Change
CALL CHANGECOLOR(MX,MY)
to
CALL CHANGECOLOR(A_ARRAY(MX,MY))

Then change
SUB CHANGECOLOR(MX,MY)
To
SUB CHANGECOLOR(C)

Then in your if statements, do

IF C=0 THEN
PAL 1
CL=1
ELSE IF C =1 THEN
PAL 1
CL=2
ELSE IF C=2
..
..
END IF


was8bit 2021-03-28 16:05

... well actually i found
CELL MX,MY,CL

Which means you need to pass MX,MY.... unless you made them GLOBAL...


SP4CEBAR 2021-05-28 09:34

I once made one of these on TI-84 for minesweeper


Dan 2021-05-28 20:10

@was8bit, it is a bit of late reply (totally forgot that someone replied to this)

I needed a visual representation of the array fill function (something that displays that the filling is working correctly), therefore i did not cared to optimize the display code.

Although, it flickers a bit ...

But there is a way to make the code even shorter.

@Sp4cebar thats great.
i haven't tried to make a minesweeperclone yet :/

I would use flowers,bee's or something else instead of mines ...


was8bit 2021-05-29 05:14

I understand the need to visualize what is actually going on ....


Log in to reply.