I finished and it is 90% all my own code. Thats why it doesn't seem to work or it works really weird. I am posting it here to see if someone on this board... who I would gladly buy a round for... can figure out the error of my ways.
When you click your mouse it puts a 0 at that row and location...
Then it makes a new colored bit and pops it in the location
Then it checks for 3 in a row of the same color
If there are 3 in a row of the same color it ZEROs them and pops a new set of colors in those locations...
Simple really
So why does it not work!
EDIT:: I went back to a 2D array... the speed is MUCH improved bu still slooooowwwww on mousepick and the incorrect coords are returned... Row and col must be from 0 to 9 bot 10!!!
-Rook
; PLONK a simple 3 in a row game of color ; Ralph Dunn Graphics3D 800,600,16,2 SetBuffer BackBuffer() SeedRnd MilliSecs() player=CreatePivot() camera=CreateCamera(player) light=CreateLight() RotateEntity light,45,45,0 AmbientLight 48,48,48 ; was 32,32,32 EntityType camera,1 PositionEntity camera,0,90,8 RotateEntity camera,90,0,0 Dim board(9,9) Dim plunk(1) Dim boardx(9) Dim boardz(9) boardx(0)=-45 boardx(1)=-35 boardx(2)=-25 boardx(3)=-15 boardx(4)=-5 boardx(5)=5 boardx(6)=15 boardx(7)=25 boardx(8)=35 boardx(9)=45 boardz(0)=45 boardz(1)=35 boardz(2)=25 boardz(3)=15 boardz(4)=5 boardz(5)=-5 boardz(6)=-15 boardz(7)=-25 boardz(8)=-35 boardz(9)=-45 Global xx Global zz Global row Global col Global punk ; ####################################### Load Mesh Objects gameboard=LoadMesh("board.b3d") UpdateNormals gameboard ScaleEntity gameboard,5.5,5.5,5.5 EntityShininess gameboard,1 Global empty=LoadMesh("square.b3d") EntityPickMode empty,2 HideEntity empty ;Global bomb=LoadMesh("bomb.b3d") ;EntityShininess bomb,1 ;HideEntity bomb Global clearpiece=LoadMesh("piece3.b3d"); was piece EntityShininess clearpiece,1 HideEntity clearpiece Global redpiece=LoadMesh("piece3.b3d") EntityColor redpiece,192,0,0 EntityShininess redpiece,1 HideEntity redpiece Global blupiece=CopyMesh(redpiece) EntityColor blupiece,0,0,255 EntityShininess blupiece,1 HideEntity blupiece Global yellopiece=CopyMesh(redpiece) EntityColor yellopiece,180,180,0 EntityShininess yellopiece,1 HideEntity yellopiece Global violetpiece=CopyMesh(redpiece) EntityColor violetpiece,138,1,255 EntityShininess violetpiece,1 HideEntity violetpiece Global redvioletpiece=CopyMesh(redpiece) EntityColor redvioletpiece,180,1,180 EntityShininess redvioletpiece,1 HideEntity redvioletpiece Global orangepiece=CopyMesh(redpiece) EntityColor orangepiece,255,153,51 EntityShininess orangepiece,1 HideEntity orangepiece Global bluvioletpiece=CopyMesh(redpiece) EntityColor bluvioletpiece,51,0,103 EntityShininess bluvioletpiece,1 HideEntity bluvioletpiece Global greenpiece=CopyMesh(redpiece) EntityColor greenpiece,0,102,0 EntityShininess greenpiece,1 HideEntity greenpiece Global redorangepiece=CopyMesh(redpiece) EntityColor redorangepiece,255,51,1 EntityShininess redorangepiece,1 HideEntity redorangepiece Global yellogreenpiece=CopyMesh(redpiece) EntityColor yellogreenpiece,51,255,102 EntityShininess yellogreenpiece,1 HideEntity yellogreenpiece Global blugreenpiece=CopyMesh(redpiece) EntityColor blugreenpiece,0,102,102 EntityShininess blugreenpiece,1 HideEntity blugreenpiece Global yelloorangepiece=CopyMesh(redpiece) EntityColor yelloorangepiece,255,153,1 EntityShininess yelloorangepiece,1 HideEntity yelloorangepiece ; ###################################### Plunk Tiles For xx=0 To 9 For zz=0 To 9 e=CopyEntity (empty) PositionEntity e,boardx(xx),1,boardz(zz) Next Next ; ############################################## Start of Game Loop ShowPointer setup_row() put_row() While Not KeyDown(1) x=MouseX() y=MouseY() e=CameraPick(camera,x,y) If e<>entity If entity Then EntityColor entity,255,255,255 entity=e EndIf If KeyHit(29)=True Then PositionEntity camera,0,83,-29 ; 0,53,-69 RotateEntity camera,75,0,0 ; was 35 EndIf If KeyHit(50)>=1 Then musicflag=1-musicflag If KeyHit(56)=True Then PositionEntity camera,0,90,8 RotateEntity camera,90,0,0 EndIf If MouseHit(1) = True Then hat=CameraPick(camera,x,y) If hat=0 Then Goto outme Select empty Case empty xx=EntityX(entity) zz=EntityZ(entity) Default pp=0 End Select .outme get_rowcol() EndIf If entity EntityColor entity,54,80,252 ; 73,253,146 lime 254,216,38 gold 254,80,232 magenta 54,80,252 EndIf check_three() check_zero() ClearWorld(entities) put_row() UpdateWorld RenderWorld Text 0,10,"X: "+xx Text 0,20,"Z: "+zz Text 0,30,"ROW: "+row Text 0,40,"COL: "+col Flip Wend End Function setup_row() For t=0 To 9 For tt=0 To 9 w=Rand(11)+1 board(t,tt)=w Next Next End Function Function put_row() ; this is going to be BIG For row = 0 To 9 For col=0 To 9 q=board(row,col) Select q Case 1 red=CopyEntity (redpiece) PositionEntity red,boardx(row),4,boardz(col) Case 2 blue=CopyEntity (blupiece) PositionEntity blue,boardx(row),4,boardz(col) Case 3 violet=CopyEntity (violetpiece) PositionEntity violet,boardx(row),4,boardz(col) Case 4 yellow=CopyEntity (yellopiece) PositionEntity yellow,boardx(row),4,boardz(col) Case 5 redviolet=CopyEntity (redvioletpiece) PositionEntity redviolet,boardx(row),4,boardz(col) Case 6 orange=CopyEntity (orangepiece) PositionEntity orange,boardx(row),4,boardz(col) Case 7 bluviolet=CopyEntity (bluvioletpiece) PositionEntity bluviolet,boardx(row),4,boardz(col) Case 8 green=CopyEntity (greenpiece) PositionEntity green,boardx(row),4,boardz(col) Case 9 redorange=CopyEntity (redorangepiece) PositionEntity redorange,boardx(row),4,boardz(col) Case 10 yellogreen=CopyEntity (yellogreenpiece) PositionEntity yellogreen,boardx(row),4,boardz(col) Case 11 blugreen=CopyEntity (blugreenpiece) PositionEntity blugreen,boardx(row),4,boardz(col) Case 12 yelloorange=CopyEntity (yelloorangepiece) PositionEntity yelloorange,boardx(row),4,boardz(col) End Select Next Next End Function Function get_rowcol() For r=0 To 9 For c=0 To 9 g=zz gg=xx h=boardz(c) i=boardx(r) If h=g Then col=c If i=gg Then row=r Next Next board(row,col)=0 End Function Function check_three() ; start at row 0 For flirt=0 To 9 For fart=0 To 7 a=board(flirt,fart) b=board(flirt,fart+1) c=board(flirt,fart+2) If a=b And b=c Then board(flirt,fart)=0 board(flirt,fart+1)=0 board(flirt,fart+2)=0 ; maybe some points and a sound EndIf Next Next End Function Function check_zero() For gaggle = 0 To 9 For giggle=0 To 9 a=board(gaggle,giggle) If a = 0 Then kolor=Rand(11)+1 board(gaggle,giggle)=kolor EndIf Next Next End FunctionI think it is commented pretty well. All it tries to do is set up 10 rows and put colored bits on them.
When you click your mouse it puts a 0 at that row and location...
Then it makes a new colored bit and pops it in the location
Then it checks for 3 in a row of the same color
If there are 3 in a row of the same color it ZEROs them and pops a new set of colors in those locations...
Simple really
So why does it not work!
EDIT:: I went back to a 2D array... the speed is MUCH improved bu still slooooowwwww on mousepick and the incorrect coords are returned... Row and col must be from 0 to 9 bot 10!!!
-Rook