Latest Uploads Mutant Mon ... (Blitz3D)steve_ancell Mutant Mon ... r package.steve_ancellimage-13-0 ... -01-38.jpgJayenkai Mutant Monty Remakesteve_ancellhai.jpgCodersRuleSillyAddition.pngJayenkai

### Atomino

UserMessage
Posted : Sunday, 24 October 2010, 11:11 | Permalink | Mark Here
Jayenkai

WW Entries : 103
 FFS, Spinal, this is far too complex for the shoutbox! People, use the forum!! Right, IIRC, Atomino was about little atoms, each one had a preset number of pegs, and you needed to attach an atom to each peg without any leftover pegs. ...or, something, been a long long time! *checks a Youtube vid to be sure* It's REALLY easy to do this, and you're overthinking things with your idea for a flood fill. ArrayS!! First array is Atom(x,y), where 0 = nothing, 1=blue, 2=red, etc. Pop a red on the grid, Atom(x,y)=2 Next, a Peg(x,y) array. Peg is a binary number, where 1=A Peg Up is here, 2= A Peg Right is here, 4=A Peg Down is here, 8 = A Peg Left is here, and OR combinations are the various combinations thereof. eg.. Array(5,5)=2;Peg(5,5)=6 display red atom, draw a right facing peg, and a down facing peg. So, you've got your red atom at, say 5,5 No pegs yet. We place a second red atom at 5,6 Peg(5,6-1) isn't yet using all 2 pegs, (bin\$(peg(x,y)), count the 1's) so allow a connection here.. Peg(5,6-1)=Peg(5,6-1)+4, and Peg(5,6)=Peg(5,6)+0 Whereas is Peg(5,6-1) has no pegs left, you wouldn't add a connection. Do it whenever you place a new atom, and it'll keep track whilst you go. If you erase an atom, be sure to clear it's pegs! You might also want to flick through all the atoms once every few frames, to be sure there are no connections that could be made.-----
Posted : Wednesday, 27 October 2010, 13:51 | Permalink | Mark Here
spinal

 You're correct, that part is not too hard, it was the next part that I was thinking of. Detecting if a bunch of atoms have been joined completely with each other... which I'm lost with. bmp image - http://socoder.net/uploads/124/atoms.rar Graphics 320,200,0,2 AppTitle "Atomino - Blitz" atom_sprites = LoadAnimImage("atoms.bmp",24,24,0,9) electron_sprites = CreateImage(24,24,128) For t# = 0 To 127 x = 10.5 + 10.5 * Sin(t# * 2.8125) y = 10.5 + 10.5 * Cos(t# * 2.8125) SetBuffer ImageBuffer(electron_sprites,127-t#) DrawBlock atom_sprites,x,y,8 Next SetBuffer BackBuffer() Dim atom(20,12) ; which atom is where (1-4) Dim peg(20,12) ; which sides are connected Global space = 24 Global PUP = 1, PLEFT = 2, PDOWN = 4, PRIGTH = 8 Global nextAtom = 1 While Not KeyHit(1) mx = MouseX() my = MouseY() Cls Color 192,192,192 Rect 63,15,194,170,0 DrawBlock atom_sprites,0,0,nextAtom-1 If mx>63 And mx<253 And my>15 And my<183 Then cx = (MX-64)/space cy = (MY-16)/space DrawBlock atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) If MouseHit(1) And atom(cx,cy)=0 Then atom(cx,cy)=nextAtom ; or whatever atom number nextAtom = Rnd(1,4) If cy>0 And atom(cx,cy) > peg(cx,cy) Then ; check UP a\$=Bin\$(peg(cx ,cy-1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy-1) peg(cx,cy-1)=peg(cx,cy-1) Or PDOWN peg(cx,cy)=peg(cx,cy) Or PUP End If End If ; cy>0 If cx>0 And atom(cx,cy) > peg(cx,cy) Then ; check LEFT a\$=Bin\$(peg(cx-1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx-1,cy) peg(cx-1,cy)=peg(cx-1,cy) Or PRIGTH peg(cx,cy)=peg(cx,cy) Or PLEFT End If End If ; cx>0 If cy<6 And atom(cx,cy) > peg(cx,cy) Then ; check DOWN a\$=Bin\$(peg(cx ,cy+1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy+1) peg(cx,cy+1)=peg(cx,cy+1) Or PUP peg(cx,cy)=peg(cx,cy) Or PDOWN End If End If ; cy<6 If cx<7 And atom(cx,cy) > peg(cx,cy) Then ; check RIGHT a\$=Bin\$(peg(cx+1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx+1,cy) peg(cx+1,cy)=peg(cx+1,cy) Or PLEFT peg(cx,cy)=peg(cx,cy) Or PRIGTH End If End If ; cx>0 End If ; mousedown End If For y=0 To 6 For x = 0 To 7 If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then For t = 1 To atom(x,y)-total DrawImage electron_sprites, 64+x*space,16+y*space, (electron_frame + 128/(atom(x,y)-total)*t)And 127 Next End If DrawImage atom_sprites, 64+x*space,16+y*space,atom(x,y)-1 If peg(x,y) And PUP Then DrawImage atom_sprites, 64+x*space,16+y*space,4 If peg(x,y) And PLEFT Then DrawImage atom_sprites, 64+x*space,16+y*space,5 If peg(x,y) And PDOWN Then DrawImage atom_sprites, 64+x*space,16+y*space,6 If peg(x,y) And PRIGTH Then DrawImage atom_sprites, 64+x*space,16+y*space,7 End If Next Next Flip electron_frame = electron_frame + 3 ; adjust for animation speed electron_frame = electron_frame And 127 Wend End --> ----- 3DS - 1762-2660-3218
Posted : Wednesday, 27 October 2010, 14:07 | Permalink | Mark Here
Jayenkai

WW Entries : 103
 Aaah, then that bits a Forward/Backward/Up/down check. Done this one plenty, too, it's not too tricky..(ish) HasAll(x,y) first to flag 'em on. for x=0 to wide for y=0 to high HasAll(x,y)=1 if Atom doesn't have all pegs, and atom>0 then HasAll(x,y)=0 next next Next to combine ajoined. for y=high to 0 step -1 for x=wide to 0 step -1 if y>0 and atom is here then if "peg up" is on and HasAll(x,y-1)=0 and there's an atom there, then HasAll(x,y)=0 and below and left and right next next then again to double check for x=0 to wide ; note the order's the other way around for y=0 to high if y>0 and atom is here then if "peg up" is on and HasAll(x,y-1)=0 and there's an atom there, then HasAll(x,y)=0 and below and left and right next next And once more for good luck... for y=high to 0 step -1 for x=0 to wide if y>0 and atom is here then if "peg up" is on and HasAll(x,y-1)=0 and there's an atom there, then HasAll(x,y)=0 and below and left and right next next Then flick through, and if a whole bunch have HasAll, then they should be removable.. That should do it.. Maybe.. Worth a triple/quadruple check, maybe, just to be on the safe side -----
Posted : Saturday, 30 October 2010, 07:07 | Permalink | Mark Here
spinal

 Not really working its removing single 'full' atoms even when ajoining ones are not full... Graphics 320,480,0,2 AppTitle "Atomino - Blitz" atom_sprites = LoadAnimImage("atoms.bmp",24,24,0,9) electron_sprites = CreateImage(24,24,128) For t# = 0 To 127 x = 10.5 + 10.5 * Sin(t# * 2.8125) y = 10.5 + 10.5 * Cos(t# * 2.8125) SetBuffer ImageBuffer(electron_sprites,127-t#) DrawBlock atom_sprites,x,y,8 Next SetBuffer BackBuffer() Dim atom(6,7) ; which atom is where (1-4) Dim peg(6,7) ; which sides are connected Dim hasAll(6,7) Global space = 24 Global PUP = 1, PLEFT = 2, PDOWN = 4, PRIGTH = 8 Global nextAtom = 1 While Not KeyHit(1) mx = MouseX() my = MouseY() Cls Color 192,192,192 Rect 63,15,194,170,0 DrawBlock atom_sprites,0,0,nextAtom-1 If mx>63 And mx<253 And my>15 And my<183 Then cx = (MX-64)/space cy = (MY-16)/space DrawBlock atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) If MouseHit(1) And atom(cx,cy)=0 Then atom(cx,cy)=nextAtom ; or whatever atom number nextAtom = Rnd(1,4) If cy>0 And atom(cx,cy) > peg(cx,cy) Then ; check UP a\$=Bin\$(peg(cx ,cy-1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy-1) peg(cx,cy-1)=peg(cx,cy-1) Or PDOWN peg(cx,cy)=peg(cx,cy) Or PUP End If End If ; cy>0 If cx>0 And atom(cx,cy) > peg(cx,cy) Then ; check LEFT a\$=Bin\$(peg(cx-1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx-1,cy) peg(cx-1,cy)=peg(cx-1,cy) Or PRIGTH peg(cx,cy)=peg(cx,cy) Or PLEFT End If End If ; cx>0 If cy<6 And atom(cx,cy) > peg(cx,cy) Then ; check DOWN a\$=Bin\$(peg(cx ,cy+1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy+1) peg(cx,cy+1)=peg(cx,cy+1) Or PUP peg(cx,cy)=peg(cx,cy) Or PDOWN End If End If ; cy<6 If cx<7 And atom(cx,cy) > peg(cx,cy) Then ; check RIGHT a\$=Bin\$(peg(cx+1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx+1,cy) peg(cx+1,cy)=peg(cx+1,cy) Or PLEFT peg(cx,cy)=peg(cx,cy) Or PRIGTH End If End If ; cx>0 ; check and remove 'full' sets For y= 0 To 6 For x = 0 To 7 hasAll(x,y) = 1 a\$=Bin\$(peg(x ,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(x,y) ; impossible if atom(x,y)=0, so need to check for that? hasAll(x,y)=0 End If Next Next For y= 6 To 0 Step -1 For x = 7 To 0 Step -1 If y > 0 And peg(x,y) And PUP And hasAll(x,y-1)=0 And atom(x,y-1)>0 Then hasAll(x,y)=0 If y < 6 And peg(x,y) And PDOWN And hasAll(x,y+1)=0 And atom(x,y+1)>0 Then hasAll(x,y)=0 If x > 0 And peg(x,y) And PLEFT And hasAll(x-1,y)=0 And atom(x-1,y)>0 Then hasAll(x,y)=0 If x < 7 And peg(x,y) And PRIGHT And hasAll(x+1,y)=0 And atom(x+1,y)>0 Then hasAll(x,y)=0 Next Next For y= 0 To 6 For x = 0 To 7 If y > 0 And peg(x,y) And PUP And hasAll(x,y-1)=0 And atom(x,y-1)>0 Then hasAll(x,y)=0 If y < 6 And peg(x,y) And PDOWN And hasAll(x,y+1)=0 And atom(x,y+1)>0 Then hasAll(x,y)=0 If x > 0 And peg(x,y) And PLEFT And hasAll(x-1,y)=0 And atom(x-1,y)>0 Then hasAll(x,y)=0 If x < 7 And peg(x,y) And PRIGHT And hasAll(x+1,y)=0 And atom(x+1,y)>0 Then hasAll(x,y)=0 Next Next For y= 6 To 0 Step -1 For x = 0 To 7 If y > 0 And peg(x,y) And PUP And hasAll(x,y-1)=0 And atom(x,y-1)>0 Then hasAll(x,y)=0 If y < 6 And peg(x,y) And PDOWN And hasAll(x,y+1)=0 And atom(x,y+1)>0 Then hasAll(x,y)=0 If x > 0 And peg(x,y) And PLEFT And hasAll(x-1,y)=0 And atom(x-1,y)>0 Then hasAll(x,y)=0 If x < 7 And peg(x,y) And PRIGHT And hasAll(x+1,y)=0 And atom(x+1,y)>0 Then hasAll(x,y)=0 Next Next For y= 0 To 6 For x = 0 To 7 If hasAll(x,y)=1 Then hasAll(x,y)=0 atom(x,y)=0 peg(x,y)=0 End If Next Next End If ; mousedown End If For y=0 To 6 For x = 0 To 7 If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then For t = 1 To atom(x,y)-total DrawImage electron_sprites, 64+x*space,16+y*space, (electron_frame + 128/(atom(x,y)-total)*t)And 127 Next End If DrawImage atom_sprites, 64+x*space,16+y*space,atom(x,y)-1 If peg(x,y) And PUP Then DrawImage atom_sprites, 64+x*space,16+y*space,4 If peg(x,y) And PLEFT Then DrawImage atom_sprites, 64+x*space,16+y*space,5 If peg(x,y) And PDOWN Then DrawImage atom_sprites, 64+x*space,16+y*space,6 If peg(x,y) And PRIGTH Then DrawImage atom_sprites, 64+x*space,16+y*space,7 End If Text x*space,y*space + 200,atom(x,y) Next Next Flip electron_frame = electron_frame + 3 electron_frame = electron_frame And 127 Wend End --> ----- 3DS - 1762-2660-3218
Posted : Saturday, 30 October 2010, 09:03 | Permalink | Mark Here
spinal

 In my head, the following solution should work, recursively checking each atom from the click point, then if the result is that all atoms are completely joined, clear then... Graphics 320,200,0,2 AppTitle "Atomino - Blitz" atom_sprites = LoadAnimImage("atoms.bmp",24,24,0,9) electron_sprites = CreateImage(24,24,128) For t# = 0 To 127 x = 10.5 + 10.5 * Sin(t# * 2.8125) y = 10.5 + 10.5 * Cos(t# * 2.8125) SetBuffer ImageBuffer(electron_sprites,127-t#) DrawBlock atom_sprites,x,y,8 Next SetBuffer BackBuffer() Dim atom(20,12) ; which atom is where (1-4) Dim peg(20,12) ; which sides are connected Global space = 24 Global PUP = 1, PLEFT = 2, PDOWN = 4, PRIGTH = 8 Global nextAtom = 1 While Not KeyHit(1) mx = MouseX() my = MouseY() Cls Color 192,192,192 Rect 63,15,194,170,0 DrawBlock atom_sprites,0,0,nextAtom-1 If mx>63 And mx<253 And my>15 And my<183 Then cx = (MX-64)/space cy = (MY-16)/space DrawBlock atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) If MouseHit(1) And atom(cx,cy)=0 Then atom(cx,cy)=nextAtom ; or whatever atom number nextAtom = Rnd(1,4) If cy>0 And atom(cx,cy) > peg(cx,cy) Then ; check UP a\$=Bin\$(peg(cx ,cy-1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy-1) peg(cx,cy-1)=peg(cx,cy-1) Or PDOWN peg(cx,cy)=peg(cx,cy) Or PUP End If End If ; cy>0 If cx>0 And atom(cx,cy) > peg(cx,cy) Then ; check LEFT a\$=Bin\$(peg(cx-1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx-1,cy) peg(cx-1,cy)=peg(cx-1,cy) Or PRIGTH peg(cx,cy)=peg(cx,cy) Or PLEFT End If End If ; cx>0 If cy<6 And atom(cx,cy) > peg(cx,cy) Then ; check DOWN a\$=Bin\$(peg(cx ,cy+1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy+1) peg(cx,cy+1)=peg(cx,cy+1) Or PUP peg(cx,cy)=peg(cx,cy) Or PDOWN End If End If ; cy<6 If cx<7 And atom(cx,cy) > peg(cx,cy) Then ; check RIGHT a\$=Bin\$(peg(cx+1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx+1,cy) peg(cx+1,cy)=peg(cx+1,cy) Or PLEFT peg(cx,cy)=peg(cx,cy) Or PRIGTH End If End If ; cx>0 If checkpoint(cx,cy, 0) = 1 Then checkpoint(cx,cy,1) End If ; mousedown End If For y=0 To 6 For x = 0 To 7 If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then For t = 1 To atom(x,y)-total DrawImage electron_sprites, 64+x*space,16+y*space, (electron_frame + 128/(atom(x,y)-total)*t)And 127 Next End If DrawImage atom_sprites, 64+x*space,16+y*space,atom(x,y)-1 If peg(x,y) And PUP Then DrawImage atom_sprites, 64+x*space,16+y*space,4 If peg(x,y) And PLEFT Then DrawImage atom_sprites, 64+x*space,16+y*space,5 If peg(x,y) And PDOWN Then DrawImage atom_sprites, 64+x*space,16+y*space,6 If peg(x,y) And PRIGTH Then DrawImage atom_sprites, 64+x*space,16+y*space,7 End If Next Next Flip electron_frame = electron_frame + 3 ; adjust for animation speed electron_frame = electron_frame And 127 Wend End Function checkpoint(x,y,clean) number = 1 ; 1 = not joined If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then ;If atom Not completely joined, Return fail number = 0 Else If number = 1 And peg(x,y) And PUP Then number = checkpoint(x,y-1,clean) If number = 1 And peg(x,y) And PDOWN Then number = checkpoint(x,y+1,clean) If number = 1 And peg(x,y) And PLEFT Then number = checkpoint(x-1,y,clean) If number = 1 And peg(x,y) And PRIGHT Then number = checkpoint(x+1,y,clean) End If End If If clean = 1 Then atom(x,y) = 0 Return number End Function --> But it's failing and as this is the first time I have ever attempted recursion for any reason, I have no idea where I going wrong ----- 3DS - 1762-2660-3218
Posted : Saturday, 30 October 2010, 15:43 | Permalink | Mark Here
spinal

 made a little (very little) progress, it seems to be correctly checking the full molecules, but then doing nothing about them Graphics 320,200,0,2 AppTitle "Atomino - Blitz" atom_sprites = LoadAnimImage("atoms.bmp",24,24,0,9) electron_sprites = CreateImage(24,24,128) For t# = 0 To 127 x = 10.5 + 10.5 * Sin(t# * 2.8125) y = 10.5 + 10.5 * Cos(t# * 2.8125) SetBuffer ImageBuffer(electron_sprites,127-t#) DrawBlock atom_sprites,x,y,8 Next SetBuffer BackBuffer() Dim atom(20,12) ; which atom is where (1-4) Dim peg(20,12) ; which sides are connected Dim checked(6,7) Global space = 24 Global PUP = 1, PLEFT = 2, PDOWN = 4, PRIGTH = 8 Global nextAtom = 1 While Not KeyHit(1) mx = MouseX() my = MouseY() Cls Color 192,192,192 Rect 63,15,194,170,0 DrawBlock atom_sprites,0,0,nextAtom-1 If mx>63 And mx<253 And my>15 And my<183 Then cx = (MX-64)/space cy = (MY-16)/space DrawBlock atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) If MouseHit(1) And atom(cx,cy)=0 Then atom(cx,cy)=nextAtom ; or whatever atom number nextAtom = Rnd(1,4) If cy>0 And atom(cx,cy) > peg(cx,cy) Then ; check UP a\$=Bin\$(peg(cx ,cy-1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy-1) peg(cx,cy-1)=peg(cx,cy-1) Or PDOWN peg(cx,cy)=peg(cx,cy) Or PUP End If End If ; cy>0 If cx>0 And atom(cx,cy) > peg(cx,cy) Then ; check LEFT a\$=Bin\$(peg(cx-1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx-1,cy) peg(cx-1,cy)=peg(cx-1,cy) Or PRIGTH peg(cx,cy)=peg(cx,cy) Or PLEFT End If End If ; cx>0 If cy<6 And atom(cx,cy) > peg(cx,cy) Then ; check DOWN a\$=Bin\$(peg(cx ,cy+1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy+1) peg(cx,cy+1)=peg(cx,cy+1) Or PUP peg(cx,cy)=peg(cx,cy) Or PDOWN End If End If ; cy<6 If cx<7 And atom(cx,cy) > peg(cx,cy) Then ; check RIGHT a\$=Bin\$(peg(cx+1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx+1,cy) peg(cx+1,cy)=peg(cx+1,cy) Or PLEFT peg(cx,cy)=peg(cx,cy) Or PRIGTH End If End If ; cx>0 For y = 0 To 6 For x = 0 To 7 checked(x,y)=0 Next Next If checkpoint(cx,cy, 0) = 0 Then checkpoint(cx,cy,1) End If ; mousedown End If For y=0 To 6 For x = 0 To 7 If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then For t = 1 To atom(x,y)-total DrawImage electron_sprites, 64+x*space,16+y*space, (electron_frame + 128/(atom(x,y)-total)*t)And 127 Next End If DrawImage atom_sprites, 64+x*space,16+y*space,atom(x,y)-1 If peg(x,y) And PUP Then DrawImage atom_sprites, 64+x*space,16+y*space,4 If peg(x,y) And PLEFT Then DrawImage atom_sprites, 64+x*space,16+y*space,5 If peg(x,y) And PDOWN Then DrawImage atom_sprites, 64+x*space,16+y*space,6 If peg(x,y) And PRIGTH Then DrawImage atom_sprites, 64+x*space,16+y*space,7 End If Next Next Flip electron_frame = electron_frame + 3 ; adjust for animation speed electron_frame = electron_frame And 127 Wend End Function checkpoint(x,y,clean) number = 0 ; 0 = all connections made Color 255,255,255 Rect 64+x*space,16+y*space,24,24,0 Flip proceed=1 If atom(x,y)>0 Then ; find how many sides are connected a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next ; if less sides than atom number, then forget everything If atom(x,y)-total > 0 Then proceed = 0 End If If checked(x,y)=1 Then proceed = 0 number=1 If proceed = 1 checked(x,y)=1 ; if completely connected, then check each connected side If (peg(x,y) And PUP) Then number = checkpoint(x,y-1,clean) If (peg(x,y) And PDOWN) Then number = checkpoint(x,y+1,clean) If (peg(x,y) And PLEFT) Then number = checkpoint(x-1,y,clean) If (peg(x,y) And PRIGHT) Then number = checkpoint(x+1,y,clean) End If If clean = 1 Then atom(x,y) = 0 Return number End Function --> ----- 3DS - 1762-2660-3218
Posted : Sunday, 31 October 2010, 08:10 | Permalink | Mark Here
Jayenkai

WW Entries : 103
 Blimey, that's chaotic. If you can follow my additions, here ya go! Graphics 640,400,0,2 Graphics 320,200,0,3 AppTitle "Atomino - Blitz" atom_sprites = LoadAnimImage("atoms.bmp",24,24,0,9) electron_sprites = CreateImage(24,24,128) For t# = 0 To 127 x = 10.5 + 10.5 * Sin(t# * 2.8125) y = 10.5 + 10.5 * Cos(t# * 2.8125) SetBuffer ImageBuffer(electron_sprites,127-t#) DrawBlock atom_sprites,x,y,8 Next SetBuffer BackBuffer() Dim atom(20,12) ; which atom is where (1-4) Dim peg(20,12) ; which sides are connected Dim checked(7,8) Global space = 24 Global PUP = 1, PLEFT = 2, PDOWN = 4, PRIGTH = 8 Global nextAtom = 1 Global TotallyClean ;********************************************** Dim Sparkly(20,12) While Not KeyHit(1) mx = MouseX() my = MouseY() Cls Color 192,192,192 Rect 63,15,194,170,0 DrawBlock atom_sprites,0,0,nextAtom-1 If mx>63 And mx<253 And my>15 And my<183 Then cx = (MX-64)/space cy = (MY-16)/space DrawBlock atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) If MouseHit(1) And atom(cx,cy)=0 Then atom(cx,cy)=nextAtom ; or whatever atom number nextAtom = Rnd(1,2) If cy>0 And atom(cx,cy) > peg(cx,cy) Then ; check UP a\$=Bin\$(peg(cx ,cy-1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy-1) peg(cx,cy-1)=peg(cx,cy-1) Or PDOWN peg(cx,cy)=peg(cx,cy) Or PUP End If End If ; cy>0 If cx>0 And atom(cx,cy) > peg(cx,cy) Then ; check LEFT a\$=Bin\$(peg(cx-1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx-1,cy) peg(cx-1,cy)=peg(cx-1,cy) Or PRIGTH peg(cx,cy)=peg(cx,cy) Or PLEFT End If End If ; cx>0 If cy<6 And atom(cx,cy) > peg(cx,cy) Then ; check DOWN a\$=Bin\$(peg(cx ,cy+1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy+1) peg(cx,cy+1)=peg(cx,cy+1) Or PUP peg(cx,cy)=peg(cx,cy) Or PDOWN End If End If ; cy<6 If cx<7 And atom(cx,cy) > peg(cx,cy) Then ; check RIGHT a\$=Bin\$(peg(cx+1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx+1,cy) peg(cx+1,cy)=peg(cx+1,cy) Or PLEFT peg(cx,cy)=peg(cx,cy) Or PRIGTH End If End If ; cx>0 For y = 0 To 6 For x = 0 To 7 checked(x,y)=0 Next Next ;If checkpoint(cx,cy, 0) = 0 Then checkpoint(cx,cy,1) Checkpoint(cx,cy,1,1) ; ********************************************************* If TotallyClean=1 For fx=0 To 7 For fy=0 To 6 If Sparkly(fx,fy)=1 Then atom(fx,fy)=0:peg(fx,fy)=0 Next Next EndIf End If ; mousedown End If For y=0 To 6 For x = 0 To 7 If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then For t = 1 To atom(x,y)-total DrawImage electron_sprites, 64+x*space,16+y*space, (electron_frame + 128/(atom(x,y)-total)*t)And 127 Next End If DrawImage atom_sprites, 64+x*space,16+y*space,atom(x,y)-1 If peg(x,y) And PUP Then DrawImage atom_sprites, 64+x*space,16+y*space,4 If peg(x,y) And PLEFT Then DrawImage atom_sprites, 64+x*space,16+y*space,5 If peg(x,y) And PDOWN Then DrawImage atom_sprites, 64+x*space,16+y*space,6 If peg(x,y) And PRIGTH Then DrawImage atom_sprites, 64+x*space,16+y*space,7 End If Next Next Flip electron_frame = electron_frame + 1 ; adjust for animation speed electron_frame = electron_frame And 127 Wend End Function checkpoint(x,y,clean,startpoint=0) ; ********************************** If startpoint=1 TotallyClean=1 For fx=0 To 7 For fy=0 To 6 Sparkly(fx,fy)=0 Next Next EndIf Sparkly(x,y)=1 number = 0 ; 0 = all connections made Color 255,255,255 Rect 64+x*space,16+y*space,24,24,0 Flip proceed=1 If atom(x,y)>0 Then ; find how many sides are connected a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next ; if less sides than atom number, then forget everything If atom(x,y)-total > 0 Then proceed = 0: TotallyClean=0 End If If checked(x,y)=1 Then proceed = 0 number=1 If proceed = 1 checked(x,y)=1 ; if completely connected, then check each connected side If (peg(x,y) And PUP) Then number = checkpoint(x,y-1,clean) If (peg(x,y) And PDOWN) Then number = checkpoint(x,y+1,clean) If (peg(x,y) And PLEFT) Then number = checkpoint(x-1,y,clean) If (peg(x,y) And PRIGTH) Then number = checkpoint(x+1,y,clean) End If ; If clean = 1 Then atom(x,y) = 0 Return number End Function --> -----
Posted : Sunday, 31 October 2010, 08:14 | Permalink | Mark Here
Jayenkai

WW Entries : 103
 You'll also want to check your "if Atom>Peg" thing, because Peg isn't a number 1-4, it's a binary number.. and there's a handful of other quirks in there, too. Quick test, blue atom left, blue atom right, red atom inbetween = red atom only connects to the left, not the right..-----
Posted : Sunday, 31 October 2010, 09:05 | Permalink | Mark Here
spinal

 I'm not 100% sure... sparkly(x,y) is recording which atoms are getting checked and then im lost how is it different from checked(x,y)? atom>peg fix -- you're right, it works much better now Graphics 640,400,0,2 Graphics 320,200,0,3 AppTitle "Atomino - Blitz" background = CreateImage( 320,200) SetBuffer ImageBuffer(background) Color 192,192,192 Rect 63,15,194,170,0 ;background = LoadImage("background.bmp") atom_sprites = LoadAnimImage("atoms.bmp",24,24,0,9) electron_sprites = CreateImage(24,24,128) For t# = 0 To 127 x = 10.5 + 10.5 * Sin(t# * 2.8125) y = 10.5 + 10.5 * Cos(t# * 2.8125) SetBuffer ImageBuffer(electron_sprites,127-t#) DrawBlock atom_sprites,x,y,8 Next SetBuffer BackBuffer() Dim atom(7,8) ; which atom is where (1-4) Dim peg(7,8) ; which sides are connected Dim checked(7,8) Global space = 24 Global PUP = 1, PLEFT = 2, PDOWN = 4, PRIGTH = 8 Global nextAtom = 1 Global TotallyClean ;********************************************** Dim Sparkly(7,8) While Not KeyHit(1) mx = MouseX() my = MouseY() ;Cls ;Color 192,192,192 ;Rect 63,15,194,170,0 DrawBlock background,0,0 DrawImage atom_sprites,280,140,nextAtom-1 ;DrawBlock atom_sprites,0,0,nextAtom-1 If mx>63 And mx<253 And my>15 And my<183 Then cx = (MX-64)/space cy = (MY-16)/space DrawBlock atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) If MouseHit(1) And atom(cx,cy)=0 Then atom(cx,cy)=nextAtom ; or whatever atom number nextAtom = Rnd(1,2) a\$=Bin\$(peg(cx ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If cy>0 And atom(cx,cy) > total Then ; check UP a\$=Bin\$(peg(cx ,cy-1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy-1) peg(cx,cy-1)=peg(cx,cy-1) Or PDOWN peg(cx,cy)=peg(cx,cy) Or PUP End If End If ; cy>0 a\$=Bin\$(peg(cx ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If cx>0 And atom(cx,cy) > total Then ; check LEFT a\$=Bin\$(peg(cx-1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx-1,cy) peg(cx-1,cy)=peg(cx-1,cy) Or PRIGTH peg(cx,cy)=peg(cx,cy) Or PLEFT End If End If ; cx>0 a\$=Bin\$(peg(cx ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If cy<6 And atom(cx,cy) > total Then ; check DOWN a\$=Bin\$(peg(cx ,cy+1)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx,cy+1) peg(cx,cy+1)=peg(cx,cy+1) Or PUP peg(cx,cy)=peg(cx,cy) Or PDOWN End If End If ; cy<6 a\$=Bin\$(peg(cx ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If cx<7 And atom(cx,cy) > total Then ; check RIGHT a\$=Bin\$(peg(cx+1 ,cy)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If total < atom(cx+1,cy) peg(cx+1,cy)=peg(cx+1,cy) Or PLEFT peg(cx,cy)=peg(cx,cy) Or PRIGTH End If End If ; cx>0 For y = 0 To 6 For x = 0 To 7 checked(x,y)=0 Next Next ;If checkpoint(cx,cy, 0) = 0 Then checkpoint(cx,cy,1) Checkpoint(cx,cy,1,1) ; ********************************************************* If TotallyClean=1 For fx=0 To 7 For fy=0 To 6 If Sparkly(fx,fy)=1 Then atom(fx,fy)=0:peg(fx,fy)=0 Next Next EndIf End If ; mousedown End If For y=0 To 6 For x = 0 To 7 If atom(x,y)>0 Then a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next If atom(x,y)-total > 0 Then For t = 1 To atom(x,y)-total DrawImage electron_sprites, 64+x*space,16+y*space, (electron_frame + 128/(atom(x,y)-total)*t)And 127 Next End If DrawImage atom_sprites, 64+x*space,16+y*space,atom(x,y)-1 If peg(x,y) And PUP Then DrawImage atom_sprites, 64+x*space,16+y*space,4 If peg(x,y) And PLEFT Then DrawImage atom_sprites, 64+x*space,16+y*space,5 If peg(x,y) And PDOWN Then DrawImage atom_sprites, 64+x*space,16+y*space,6 If peg(x,y) And PRIGTH Then DrawImage atom_sprites, 64+x*space,16+y*space,7 End If Next Next If mx>63 And mx<253 And my>15 And my<183 Then DrawImage atom_sprites,64+Floor(cx)*space,16+Floor(cy)*space,nextAtom-1 ; draw current atom at mouse position (cursor) End If Flip electron_frame = electron_frame + 3 ; adjust for animation speed electron_frame = electron_frame And 127 Wend End Function checkpoint(x,y,clean,startpoint=0) ; ********************************** If startpoint=1 TotallyClean=1 For fx=0 To 7 For fy=0 To 6 Sparkly(fx,fy)=0 Next Next EndIf Sparkly(x,y)=1 number = 0 ; 0 = all connections made Color 255,255,255 Rect 64+x*space,16+y*space,24,24,0 Flip proceed=1 If atom(x,y)>0 Then ; find how many sides are connected a\$=Bin\$(peg(x,y)) total=0 For temp = 1 To Len(a\$) If Mid\$(a\$,temp,1)=1 Then total = total+1 Next ; if less sides than atom number, then forget everything If atom(x,y)-total > 0 Then proceed = 0: TotallyClean=0 End If If checked(x,y)=1 Then proceed = 0 number=1 If proceed = 1 checked(x,y)=1 ; if completely connected, then check each connected side If (peg(x,y) And PUP) Then number = checkpoint(x,y-1,clean) If (peg(x,y) And PDOWN) Then number = checkpoint(x,y+1,clean) If (peg(x,y) And PLEFT) Then number = checkpoint(x-1,y,clean) If (peg(x,y) And PRIGTH) Then number = checkpoint(x+1,y,clean) End If ; If clean = 1 Then atom(x,y) = 0 Return number End Function --> ----- 3DS - 1762-2660-3218
Posted : Sunday, 31 October 2010, 09:14 | Permalink | Mark Here
Jayenkai

WW Entries : 103
 It probably was the same, I just wasn't quite sure what it was you were doing, so threw my own equivalent version in there, instead -----
Posted : Sunday, 31 October 2010, 09:16 | Permalink | Mark Here
spinal

 Anyway, your way works and mine doesn't... either way, thanx, I wouldn't have figured it out by myself.----- 3DS - 1762-2660-3218
 Latest PostsMutant Monty update. Hotshot Tue 16:08 Android Dev Test Doohickey Jayenkai Tue 09:58 Aminal Xing Knew Leef Jayenkai Tue 04:25 Spark dna Mon 17:24 HoboTile steve_ancell Sun 10:07 Hoover steve_ancell Sat 21:53 Scrabble Rabble Jayenkai Fri 08:13 Not Fit for Purpose Jayenkai Thu 20:29 Happy Birthday, Krakatomato steve_ancell Thu 18:03 How Deep is Your Code? Hotshot Thu 14:35 More

 Latest Items Blog : Snow WorklogCower Mon 12:23 Dev-Diary : Mutant Monty: Amstrad CPC to Windows conversionsteve_ancell Sat 19:12 Showcase : MLG : Microscopic Lifeform Genociderockford Wed 09:24 News : Newsletter #176Jayenkai Sat 04:49 News : Newsletter #175Dabz Tue 09:38 Blog : Snow: More Material JunkCower Sat 23:17 Techy : AppleTVJayenkai Thu 09:40 Blog : Graphvizsteve_ancell Sat 14:17 Pets : Top-Down Shadow HackJayenkai Tue 05:52 Snippet : JNKrunch v1.0Jayenkai Sat 07:20 News : Newsletter #173waroffice Fri 04:47 Blog : Material LoadingCower Fri 02:08 Pets : I Done Won A Thingshroom_monk Sun 11:31 Pets : Repurposing A LexerCower Mon 22:06 Bah : Feeling a Little Angryspinal Mon 11:26More

Who's Online
Jayenkai
Tue, at 16:32
Hotshot
Tue, at 16:32
CodersRule
Tue, at 16:24
dna
Tue, at 16:15
therevillsgames
Tue, at 16:01
steve_ancell
Tue, at 15:46
shroom_monk
Tue, at 15:29
HoboBen
Tue, at 15:17
rockford
Tue, at 14:20
spinal
Tue, at 13:55