.FLOOD
.The challenge is to write a good,solid floodfill function.
DiagnosticOff
.Cursor coordinates
10->X->Y
.Start the program with the cursor at 10,10
.The arrow keysmove the cursor
.When you pressALPHA, call the flood fill function
.When you press2ND,it draws a pixel at the X,Yposition
ClrDraw
ClrDraw^^r
.Clear exits
Repeat getKey(15)
.This code is unoptimized,and I use a lot of functions, for clarity purposes
Input()
.^All this function does is getinput from the arrow keys
.Now,to get input from 2ND and ALPHA
.Remember-
.2ND=Draw pixel
.ALPHA=Flood fill
.And [DEL] deletes pixels
If getKey(54)
Pxl-On(X,Y)^^r
End
If getKey(56)
Pxl-Off(X,Y)^^r
End
.Now,its your turn to write some code.
.All I need is someone to writethe Flood() function.
If getKey(48)
Flood()
.^That.
.Scroll down tosee what code needs to be written.
End
.Now,for some boring display stuff
.Everything is stored on the back buffer
.The front buffer is for displaying the cursor and other stuff
RecallPic
.Display cursor
Cursr()
DispGraph
Pause 75
.End of main loop
End
Return
.Finally,the flood fill function!
Lbl Flood
.YOUR
.CODE
.HERE
.Remember, dontwrite to the front buffer,usethe back buffer
Return
.Other functions
Lbl Input
If getKey(1) and (Y<63
Y++
End
If getKey(2) and (X>0
X--
End
If getKey(3) and (X<95
X++
End
If getKey(4) and (Y>0
Y--
End
Return
Lbl Cursr
Rect(X,0,1,63
Rect(0,Y,95,1
Pxl-Off(X,Y
Return