3d question regarding interfaces

Blitz3D Forums/Blitz3D Beginners Area/3d question regarding interfaces

gellyware(Posted 2003) [#1]
Is there a way in blitz3d to make something pickable with the mouse? Say I make a tic tac toe game for instance.... Is there a way to click the square with your mouse button and the square knows it was clicked on?


skn3(Posted 2003) [#2]
http://www.blitzbasic.com/codearcs/codearcs.php?code=329


gellyware(Posted 2003) [#3]
is that with the blitz gui or is that blitz3d?


Todd(Posted 2003) [#4]
If you're doing this in 3d then all you need to do is set all of your entities you to be able to pick by using EntityPickMode() and then use CameraPick() to find out which was picked. Here's an example if you didnt get that:

Graphics3D 640,480,0,2
SetBuffer BackBuffer()

Camera=CreateCamera()
PositionEntity Camera,0,0,-6

Cube1=CreateCube()
EntityColor Cube1,255,0,0
EntityPickMode Cube1,2
PositionEntity Cube1,-3,0,0

Cube2=CreateCube()
EntityColor Cube2,0,255,0
EntityPickMode Cube2,2
PositionEntity Cube2,0,0,0

Cube3=CreateCube()
EntityColor Cube3,0,0,255
EntityPickMode Cube3,2
PositionEntity Cube3,3,0,0

Light=CreateLight()
TurnEntity Light,30,50,0

While Not KeyDown(1)
Cls

	If MouseHit(1)
		Select CameraPick(Camera,MouseX(),MouseY())
		Case Cube1
			EntityColor Cube1,255,255,255
			EntityColor Cube2,0,255,0
			EntityColor Cube3,0,0,255
		Case Cube2
			EntityColor Cube2,255,255,255
			EntityColor Cube1,255,0,0
			EntityColor Cube3,0,0,255		
		Case Cube3
			EntityColor Cube3,255,255,255
			EntityColor Cube1,255,0,0
			EntityColor Cube2,0,255,0		
		Default
			EntityColor Cube3,0,0,255
			EntityColor Cube1,255,0,0
			EntityColor Cube2,0,255,0		
		End Select
	EndIf

UpdateWorld
RenderWorld

Flip
Wend


Or if you're doing it in 2d, then all you need to do is use the RectsOverlap() command to see if the mouse is overlapping your object.


gellyware(Posted 2003) [#5]
Exactly what I was looking for. Thank you!