3D Tic-Tac-Toe
BlitzMax Forums/BlitzMax Tutorials/3D Tic-Tac-Toe
| ||
I'm making a version of 3D tic-tac-toe and I want to be able to select where to place the next move useing the left mouse click. I already have the easy things done, 3d array to keep track of which player owns what spots and a 3d array of cubes also. I also have it so when you right click and move the mouse the camera will rotate around the cube of cubes. Any help on how I can finish this or make it any easier will be much appreciated. Graphics3D 800,600,0,2 SetBuffer = BackBuffer() Dim spot(2,2,2) Dim player(2,2,2) pivot = CreatePivot() camera = CreateCamera() light = CreateLight() PositionEntity camera,0,0,-10 Xtex = LoadTexture("X.bmp") Otex = LoadTexture("O.bmp") Blank = LoadTexture("Blank.bmp") For x = 0 To 2 For y = 0 To 2 For z = 0 To 2 spot(x,y,z) = CreateCube(pivot) PositionEntity spot(x,y,z), x*2-2, y*2-2, z*2-2 EntityTexture spot(x,y,z), Blank player(x,y,z) = 0 Next Next Next While (Not KeyDown(1)) Cls If MouseDown(2) rx = MouseX() / 2 ry = MouseY() / 2 EndIf RotateEntity pivot,rx,ry,0 RenderWorld Flip Wend End |
| ||
How would you select the central cube? Ryan |
| ||
Here you have something to start with:Graphics3D 800,600,0,2 SetBuffer = BackBuffer() Dim spot(2,2,2) Dim player(2,2,2) pivot = CreatePivot() camera = CreateCamera() light = CreateLight() PositionEntity camera,0,0,-20 ;Xtex = LoadTexture("X.bmp") ;Otex = LoadTexture("O.bmp") ;Blank = LoadTexture("Blank.bmp") blank=CreateTexture(256,256,9) SetBuffer TextureBuffer(blank) Color 200,200,200 Rect 0,0,256,256,1 Color 0,0,0 Line 0,0,255,0 Line 0,1,255,1 Line 0,0,0,255 Line 1,0,1,255 Line 2,0,2,255 Line 2,0,2,255 SetBuffer BackBuffer() cube = CreateCube() For x = 0 To 2 For y = 0 To 2 For z = 0 To 2 spot(x,y,z) = CopyEntity (cube, pivot) PositionEntity spot(x,y,z), x*2-2, y*2-2, z*2-2 EntityTexture spot(x,y,z), blank EntityPickMode spot ( x,y,z ), 3 player(x,y,z) = 0 Next Next Next While (Not KeyDown(1)) Cls If MouseDown(2) rx = MouseX() / 2 ry = MouseY() / 2 EndIf RotateEntity pivot,rx,ry,0 If MouseHit(1) selected_cube = CameraPick ( camera, MouseX(), MouseY()) If selected_cube EntityColor selected_cube, 255,0,0 EndIf EndIf RenderWorld Flip Wend End -------------------------------------------------------------------- http://www.moonworx.de |