2d mouse pointer on a 3d map

Blitz3D Forums/Blitz3D Beginners Area/2d mouse pointer on a 3d map

I use this code to move my camera:
if uses some global variables...gwidth/height is the size of screen
mapwidth/height is the size of playing field.

you will probably have to change some of the other constants to make it work for you


Function update_camera()
	If MouseX() > (gwidth - 10) Then TranslateEntity camera,1,0,0 
	If MouseX() < 10 Then TranslateEntity camera,-1,0,0
	If MouseY() > (gheight - 10) Then TranslateEntity camera,0,0,-1
	If MouseY() < 10 Then TranslateEntity camera,0,0,1

;this part just makes sure the camera stays within some bounderies...
	If EntityX#(camera,True) < 0 Then PositionEntity camera,0,EntityY#(camera,True),EntityZ#(camera,True),True
	If EntityX#(camera,True) > mapWidth Then PositionEntity camera,mapWidth,EntityY#(camera,True),EntityZ#(camera,True),True
	If EntityZ#(camera,True) < -15 Then PositionEntity camera,EntityX#(camera,True),EntityY#(camera,True),-15,True
	If EntityZ#(camera,True) > mapHeight-15 Then PositionEntity camera,EntityX#(camera,True),EntityY#(camera,True),mapHeight,True
	
End Function



for the actual cursor, make sure that you draw after renderworld and before the flip:
;do all 3d stuff
updateworld()
renderworld()

drawimage(cursor,mousex(),mousey())
;do other 2d stuff

flip