Got it ;)
I added in a TFormVector which, I guess, gives you coords depending on which direction you are facing. I don't totally understand it, but I use it on my 3D Map Editors. You just give it a X,Y,Z and it takes that and gives you the TFormed commands that you can put into TranslateEntity to move you in the right direction no matter which way you are facing.
Like if you want to go forward but not up or down and you are looking at an angle up, moveentity would make you go up.
But using the TFormedVector, you can put in
0,0,1,entity1,0 then,
TranslateEntity entity1,TFormedX(),0,TFormedZ() to make you go forward.
Hard to explain really. I don't quite understand the point of putting in a second entity, but other than that, it's simple once you play with it.
I also did some dirty work and moved the camera moving function above UpdateWorld where it should be and moved the image drawing out of the camera moving function and into DrawMenu function. Which is under the menu control label.
I did a couple other things like, where you made the variables at the start
cameraheight = 5.5
startingcameraheight = 5.5
I changed to
cameraheight = 5.5
startingcameraheight = cameraheight
So you would only have to change the cameraheight and the startingcameraheight would be defaulted to it. Instead of having to change them both manually at the start.
Also inside of the camera moving function, I change a few things to make them simpler, like the part that had the "If mousedown(1) and blablabla = 1 and imagescollide(bla bla bla)" part, I made it simpler so it doesn't need more than one if per... check or whatever.. heh..
Graphics3D 640,480,32,1
SetBuffer BackBuffer()
SeedRnd MilliSecs()
Const fps=30
ArialBold=LoadFont("arial",14,1,0,0)
SetFont ArialBold
AmbientLight 255,255,255
Dither 0
ClearTextureFilters
TextureFilter "alpha",2
period=1000/fps
time=MilliSecs()-period
elapsed%=0
ticks%=0
tween#=0
k%=0
.VARIABLES
.cameravariables
Global cameraposition#=5
Global startingcameraposition#=cameraposition
Global cameraheight#=5.5
Global startingcameraheight#=cameraheight
Global cameradistance#=-7
Global startingcameradistance#=cameradistance
Global cameraturn#=0
Global startingcameraturn#=cameraturn
Global camerapush#=15
Global startingcamerapush#=camerapush
Global AspectRatio#=1.6
.mousevariables
Global mouseposition#=0
Global startingmouseposition#=0
Global horizontaldragamount#=0
Global mouseheight#=0
Global startingmouseheight#=0
Global verticaldragamount#=0
Global mousewheelposition%=0
Global mousewheelminimum%=0
Global mousewheelmaximum%=0
Global mousevisibility%=1
.menuvariables
Global filemenustate%=0
Global menubarstate%=0
Global movemode%=1
Global modechanger%=0
.CREATION
.cameracreation
Global camera=CreateCamera()
CameraClsColor camera,0,0,0
CameraRange camera,.1,1000
.roomcreation
walltexture=LoadTexture("wall.png",8)
floortexture=LoadTexture("floor.png",8)
floor1=CreateCube()
ScaleEntity floor1,10.0/2,.001/2,10.0/2
PositionEntity floor1,-5,0,5
EntityTexture floor1,floortexture
floor2=CreateCube()
ScaleEntity floor2,10.0/2,.001/2,10.0/2
PositionEntity floor2,5,0,5
EntityTexture floor2,floortexture
floor3=CreateCube()
ScaleEntity floor3,10.0/2,.001/2,10.0/2
PositionEntity floor3,-5,0,-5
EntityTexture floor3,floortexture
floor4=CreateCube()
ScaleEntity floor4,10.0/2,.001/2,10.0/2
PositionEntity floor4,5,0,-5
EntityTexture floor4,floortexture
back1=CreateCube()
ScaleEntity back1,10.0/2,7.0/2,.001/2
PositionEntity back1,-5,3.5,10
EntityTexture back1,walltexture
back2=CreateCube()
ScaleEntity back2,10.0/2,7.0/2,.001/2
PositionEntity back2,5,3.5,10
EntityTexture back2,walltexture
side1=CreateCube()
ScaleEntity side1,.001/2,7.0/2,10.0/2
PositionEntity side1,10,3.5,5
EntityTexture side1,walltexture
side2=CreateCube()
ScaleEntity side2,.001/2,7.0/2,10.0/2
PositionEntity side2,10,3.5,-5
EntityTexture side2,walltexture
.menucreation
Global transparenttexture=LoadTexture("transparenttexturealpha.png")
Global menubar=LoadImage("menubar.png")
Global menubararea=LoadImage("menubararea.png")
Global menubarparent=CreateCube(camera)
EntityTexture menubarparent,transparenttexture
ScaleEntity menubarparent,.01,.01,.01
PositionEntity menubarparent,-.0021,-.0232,1.5
Global translucentmenubar=LoadSprite("translucentmenubar.png",1,menubarparent)
SpriteViewMode translucentmenubar,1
ScaleSprite translucentmenubar,.937,.73
Global filebutton=LoadImage("filebutton.png")
Global filebuttonarea=LoadImage("filebuttonarea.png")
Global filemenu=LoadImage("filemenu.png")
Global filemenuarea=LoadImage("filemenuarea.png")
Global filemenucancelarea=LoadImage("filemenucancelarea.png")
Global save=LoadImage("save.png")
Global savearea=LoadImage("savearea.png")
Global Quit=LoadImage("quit.png")
Global quitarea=LoadImage("quitarea.png")
.editorcreation
Global okay=LoadImage("okay.png")
Global okayarea=LoadImage("okayarea.png")
Global point=LoadImage("point.png")
Global pointarea=LoadImage("pointarea.png")
Global raiseandlower=LoadImage("raiseandlower.png")
Global raiseandlowerarea=LoadImage("raiseandlowerarea.png")
Global move=LoadImage("move.png")
Global movearea=LoadImage("movearea.png")
.mousecreation
Global mouse=LoadImage("mouse.png")
Global mouseimage=LoadImage("mouseimage.png")
Global mouseinvisible=LoadImage("mouseinvisible.png")
MoveMouse 320,240
While Not KeyHit(1)
Cls
Repeat
elapsed=MilliSecs()-time
Until elapsed
ticks=elapsed/period
tween#=Float(elapsed Mod period)/Float(period)
For k=1 To ticks
time=time+period
If k=ticks Then CaptureWorld
MoveCamera()
UpdateWorld
Next
RenderWorld tween
DrawMenu()
AspectRatio()
MenubarControl()
WheelLimiter(position,lowestposition,highestposition)
DebugText()
MouseControl()
DebugLog "CameraY = " + EntityY(camera)
Flip
Wend
End
.FUNCTIONS
.MenubarControl
Function MenubarControl()
If ImagesCollide(mouse,mouseposition,mouseheight,0,menubararea,0,0,0)
DrawImage menubar,0,0
EndIf
If ImagesCollide(mouse,mouseposition,mouseheight,0,filebuttonarea,0,0,0)
DrawImage filebutton,0,0
EndIf
If MouseDown(1) And ImagesCollide(mouse,mouseposition,mouseheight,0,filebuttonarea,0,0,0)
filemenustate=1
EndIf
If filemenustate=1
DrawImage filemenu,0,0
EndIf
If MouseDown(1) And ImagesCollide(mouse,mouseposition,mouseheight,0,filemenucancelarea,0,0,0)
filemenustate=0
EndIf
If filemenustate=1 And ImagesCollide(mouse,mouseposition,mouseheight,0,savearea,0,0,0)
DrawImage save,0,0
EndIf
If filemenustate=1 And ImagesCollide(mouse,mouseposition,mouseheight,0,quitarea,0,0,0)
DrawImage Quit,0,0
EndIf
If MouseDown(1) And ImagesCollide(mouse,mouseposition,mouseheight,0,quitarea,0,0,0)
Quit()
EndIf
End Function
Function DrawMenu()
DrawImage okay,0,0
Select movemode
Case 1
DrawImage point,0,0
Case 2
DrawImage raiseandlower,0,0
Case 3
DrawImage move,0,0
End Select
End Function
.Quit
Function Quit()
End
End Function
.MoveCamera
Function MoveCamera()
mousewheelminimum=-3
mousewheelmaximum=-1
If MouseDown(1)
If modechanger=1
If ImagesCollide(mouse,mouseposition,mouseheight,0,pointarea,0,0,0)
movemode=1
ElseIf ImagesCollide(mouse,mouseposition,mouseheight,0,raiseandlowerarea,0,0,0)
movemode=2
ElseIf ImagesCollide(mouse,mouseposition,mouseheight,0,movearea,0,0,0)
movemode=3
EndIf
EndIf
EndIf
; unrelated
PositionEntity camera,cameraposition,cameraheight,cameradistance
RotateEntity camera,camerapush,cameraturn,0
If MouseHit(1)
Select movemode
Case 1
startingmouseposition=mouseposition
startingcameraturn=cameraturn
startingmouseheight=mouseheight
startingcamerapush=camerapush
Case 2
startingmouseheight=mouseheight
startingcameraheight=cameraheight
Case 3
End Select
ResetMouse()
EndIf
Local TemporaryXSpeed#=MouseXSpeed()
Local TemporaryYSpeed#=MouseYSpeed()
TFormVector (-TemporaryXSpeed/20),0,(TemporaryYSpeed/20),camera,0
Local TFormX# = TFormedX()
Local TFormZ# = TFormedZ()
; gias code
If MouseDown(1)
Select movemode
Case 1
horizontaldragamount=(mouseposition-startingmouseposition)
cameraturn=startingcameraturn+horizontaldragamount/7
verticaldragamount=(mouseheight-startingmouseheight)
camerapush=startingcamerapush-verticaldragamount/7
Case 2
verticaldragamount=(mouseheight-startingmouseheight)
cameraheight=startingcameraheight+verticaldragamount/40
Case 3
TranslateEntity camera,TFormX,0,TFormZ
;MoveEntity camera,-TemporaryXSpeed/20,0,TemporaryYSpeed/20
cameraposition=EntityX(camera)
cameraheight=EntityY(camera)
cameradistance=EntityZ(camera)
; gias code
; camera height lock
End Select
ResetMouse()
EndIf
If camerapush>61
camerapush=61
EndIf
If camerapush<-77
camerapush=-77
EndIf
If Not MouseDown(1)
modechanger=1
Else
modechanger=0
EndIf
End Function
.AspectRatio
Function AspectRatio()
CameraZoom camera,AspectRatio
If KeyDown(55)
AspectRatio=AspectRatio+.01
ElseIf KeyDown(181)
AspectRatio=AspectRatio-.01
EndIf
If AspectRatio<0.1
AspectRatio=0.1
EndIf
End Function
.MouseControl
Function MouseControl()
mouseposition=MouseX()
mouseheight=MouseY()
mousewheelposition=WheelLimiter(mousewheelposition+MouseZSpeed(),mousewheelminimum,mousewheelmaximum)
If mousevisibility=1
HandleImage mouseimage,15,15
DrawImage mouseimage,mouseposition,mouseheight
HandleImage mouse,15,15
DrawImage mouse,mouseposition,mouseheight
EndIf
If mousevisibility=0
HandleImage mouseinvisible,15,15
DrawImage mouseinvisible,mouseposition,mouseheight
EndIf
End Function
.WheelLimiter
Function WheelLimiter%(position%,lowestposition%,highestposition%)
If position<lowestposition
position=lowestposition
EndIf
If position>highestposition
position=highestposition
EndIf
Return position
End Function
.ResetMouse
Function ResetMouse()
FlushMouse()
End Function
.DebugText
Function DebugText()
Color 100,100,95
Text 7,379,""
Text 7,393,""
Text 7,407,""
Text 7,421,""
Text 7,435,""
Text 7,449,""
Text 7,463,""
End Function
;