Move mode relativity

Blitz3D Forums/Blitz3D Beginners Area/Move mode relativity

http://files.filefront.com/MoveModeRelativity20081014zip/;12065818;/fileinfo.html

I'm having a problem with my move modes only working right when I'm facing one direction. It's easier to see what I mean in the program itself. Hope someone can help.

Not sure what the problem is in your program. I tested it, but noticed nothing strange. That might have something to do with my laptop having no scrollbutton on the touchpad. I'm a bit too tired to really dive into the code, so I posted the code below. Hopefully it helps!
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

;create pivot with camera attached
piv = CreatePivot()
cam = CreateCamera(piv)

;init world/mousexyspeed
makeworld
MouseXSpeed
MouseYSpeed

While Not(KeyHit(1))

	;move pivot sideways
	TurnEntity piv, 0, -MouseXSpeed(), 0

	;move camera up/down
	pt = pt + MouseYSpeed()
	If pt > 90 Then pt = 90
	If pt < -90 Then pt = -90
	RotateEntity cam, pt, 0, 0
	MoveMouse 400, 300

	;render
	RenderWorld
	Flip
	
Wend


End

;####################
Function makeworld()

	Rect 0, 0, 32, 32
	Rect 32, 32, 32, 32
	tex = CreateTexture(64, 64)
	CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex)
	
	cube = CreateCube()
	FlipMesh cube
	ScaleEntity cube, 10, 10, 10
	
	EntityTexture cube, tex
	ScaleTexture tex, 0.1, 0.1
		
End Function


I'll give that a try, thanks. The problem's described a little in the program, but basically it's that if you drag the level toward you when you're facing the direction you start at, it works just fine, but if you then turn the camera say 90 degrees and try to use move again, you can tell it's not relative to the camera, but to the world, and I want it to be relative to whatever direction the camera's facing at any given time. Long story short, when you're in move mode, dragging down should always move the level toward you. By the way, the top icon is to point the camera, the middle is to raise and lower, and the bottom is to move.

Okay, version 2.1, hopefully it is now closer to what you need:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

HidePointer

Dim modename$(3)
mode = 1
modename$(1) = "rotate camera"
modename$(2) = "move camera forward"
modename$(3) = "move camera up/down"

;create camera 
cam = CreateCamera()

;init world/mousexyspeed
makeworld
MouseXSpeed
MouseYSpeed

While Not(KeyHit(1))

	If MouseHit(1) Then
		MouseXSpeed
		MouseYSpeed
	End If
	
	If MouseDown(1) Then
	
		Select mode
		
		Case 1
			;move pivot sideways
			yw = yw - MouseXSpeed()
		
			;move camera up/down
			pt = pt + MouseYSpeed()
			
			If pt > 90 Then pt = 90
			If pt < -90 Then pt = -90
			RotateEntity cam, pt, yw, 0
			
		Case 2
		
			MoveEntity cam, 0, 0, -MouseYSpeed()*0.1
			
		Case 3
		
			MoveEntity cam, 0, -MouseYSpeed()*0.1, 0
			;TranslateEntity cam, 0, -MouseYSpeed()*0.1, 0
		
		End Select
	
	End If
	
	MoveMouse 400, 300

	;render
	RenderWorld
	
	If KeyHit(2) Then mode = 1
	If KeyHit(3) Then mode = 2
	If KeyHit(4) Then mode = 3
	
	Text 0,  0, "press 1/2/3 to change mode"
	Text 0, 20, "mode = " + mode + " (" + modename$(mode) + ")"
	Text 0, 40, "press LMB to move camera"
	Flip
	
Wend


End

;####################
Function makeworld()

	Rect 0, 0, 32, 32
	Rect 32, 32, 32, 32
	tex = CreateTexture(64, 64)
	CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex)
	
	cube = CreateCube()
	FlipMesh cube
	ScaleEntity cube, 10, 10, 10
	
	EntityTexture cube, tex
	ScaleTexture tex, 0.1, 0.1
	
	tex = CreateTexture(64, 64)
	For i = 90 To 1 Step -1
		Color 255-i*4,255-i*4,255-i*4
		Oval 32-i,32-i,i*2,i*2
	Next
	CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex)
	
	EntityTexture cube, tex, 0, 1
	EntityFX cube, 1
	
		
End Function


http://files.filefront.com/MoveModeRelativity20081018zip/;12111519;/fileinfo.html

I tried your code and I think I'm at least partway there. If you don't mind could you please take a look at the new one? You can tell it's closer to what I'm looking for with the camera now moving relative to itself instead of the level, except that it's really hard to see that since it only changes for one frame before snapping back to where it was. It's really frustrating. Anyway I made the icons clickable for you now. I can handle that kind of stuff, but I really wish I was better at the rest. Please help if you can.

That was easy ;) Took me awhile but I got it

.MoveCamera

Function MoveCamera()
mousewheelminimum=-3
mousewheelmaximum=-1
DrawImage okay,0,0
If movemode=1
DrawImage point,0,0
ElseIf movemode=2
DrawImage raiseandlower,0,0
ElseIf movemode=3
DrawImage move,0,0
EndIf
If MouseDown(1) And modechanger=1 And ImagesCollide(mouse,mouseposition,mouseheight,0,pointarea,0,0,0)
movemode=1
ElseIf MouseDown(1) And modechanger=1 And ImagesCollide(mouse,mouseposition,mouseheight,0,raiseandlowerarea,0,0,0)
movemode=2
ElseIf MouseDown(1) And modechanger=1 And ImagesCollide(mouse,mouseposition,mouseheight,0,movearea,0,0,0)
movemode=3
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

;startingmouseposition=mouseposition
;startingcameraposition=cameraposition
;startingmouseheight=mouseheight
;startingcameradistance=cameradistance
; previous code

End Select
ResetMouse()
EndIf

TempX# = MouseXSpeed()
TempZ# = MouseYSpeed()

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

;horizontaldragamount=(mouseposition-startingmouseposition)
;cameraposition=startingcameraposition-horizontaldragamount/30
;verticaldragamount=(mouseheight-startingmouseheight)
;cameradistance=startingcameradistance+verticaldragamount/30
; previous code

MoveEntity camera,-TempX,0,TempZ
				
cameraposition = EntityX(camera)
cameraheight = EntityY(camera)
cameradistance = EntityZ(camera)
; new code

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


I added in the

TempX# = MouseXSpeed()
TempZ# = MouseYSpeed()


and

MoveEntity camera,-TempX,0,TempZ
				
cameraposition = EntityX(camera)
cameraheight = EntityY(camera)
cameradistance = EntityZ(camera)


Is this an issue with MoveEntity / TranslateEntity ?
Or perhaps using Local commands when they should be global or vice versa? Not sure what you're after...

I wish I was. No, what I'm looking for basically is a way for the camera to move more and more each additional drag. When I first posted, it was doing that, but the relativity was all messed up, forward was only forward if you were facing forward. Now that's fixed, the camera moves forward no matter what direction you're facing, but now the part of the code that handles the continuation and recording of changes, cameradistance and startingcameradistance I think they're called, is broken. That's the story so far. Thanks Gia, I'll try your new suggestion sometime in the next few days, I'm kind of sick right now. Looks like you got it though, based on your confidence. Can't wait to try it when I'm feeling better. Contact me if you need any art for your game.

It's perfect! Except...

I tried to lock the camera height, because mode 3 is supposed to be like the camera's moving on a dolly. It sort of works, but it's like the dolly has four flat tires, especially if the camera's pointing down. Not really sure how to fix that. Here's the code:

temporarycameraposition#=MouseXSpeed()
temporarycameradistance#=MouseYSpeed()
; 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
MoveEntity camera,-temporarycameraposition/20,0,temporarycameradistance/20
cameraposition=EntityX(camera)
;cameraheight=EntityY(camera)
cameradistance=EntityZ(camera)
; gias code

cameraheight=cameraheight
; camera height lock

End Select


This should be the last thing I need for this.

I still can't figure this out... maybe someone with really good programming skills will want to help/show off. Everything's exactly the way I want it now, except the dolly for the camera (mode 3) seems to have a very bumpy ride. I know the reason, but I haven't a clue how to fix it. The reason as far as I can tell is that each frame cycle, the code first tells the camera to move forward, and say down a little, depending on how much you're facing down. Then, the height adjuster attempts to return just the height back to it's previous camera rig (mode 2) setting, so you don't actually move down into the floor just because you're facing that direction. Depending on how fast you move, and how much the camera is pointing down, that small vertical adjustment can be very noticable every frame! Mode 1 by the way is, you guessed it, camera point. The three modes together are designed to be just like a camera vehicle on a movie set. Anyway, unrelated. Hope this explaination has been clear enough. If not, just run the program with the above code box amended to it, pick mode 3, and drag toward you. First slow, then fast. I'll post the newer link tomorrow. Hope someone can help, this last fix should finalize the camera placement part of my engine! :) Thanks for all the great help so far, I couldn't have gotten this far without it.

EDIT Okay, here's the new one:
http://files.filefront.com/MoveModeRelativity20081120zip/;12428618;/fileinfo.html

So, you want to move the camera, taking in account it's yaw, and disregarding it's pitch ? If so, a way to do it would be attaching the camera to a pivot, and use the pivot to move the camera. Then the camera can rotate freely without affecting the direction of the pivot.
When the camera is turned, the yaw is applied to the pivot, and the pitch is applied to the camera itself.
I've changed the code I posted earlier to do that:
Graphics3D 800, 600, 0, 2
SetBuffer BackBuffer()

HidePointer

Dim modename$(3)
mode = 1
modename$(1) = "rotate camera"
modename$(2) = "move camera forward"
modename$(3) = "move camera up/down"

;create camera 
campiv = CreatePivot()
cam = CreateCamera(campiv)

;init world/mousexyspeed
makeworld
MouseXSpeed
MouseYSpeed

While Not(KeyHit(1))

	If MouseHit(1) Then
		MouseXSpeed
		MouseYSpeed
	End If
	
	If MouseDown(1) Then
	
		Select mode
		
		Case 1
			;move pivot sideways
			yw = yw - MouseXSpeed()
		
			;move camera up/down
			pt = pt + MouseYSpeed()
			
			If pt > 90 Then pt = 90
			If pt < -90 Then pt = -90
			RotateEntity cam, pt, 0, 0
			RotateEntity campiv, 0, yw, 0
			
		Case 2
		
			MoveEntity campiv, 0, 0, -MouseYSpeed()*0.1
			
		Case 3
		
			MoveEntity campiv, 0, -MouseYSpeed()*0.1, 0
			;TranslateEntity cam, 0, -MouseYSpeed()*0.1, 0
		
		End Select
	
	End If
	
	MoveMouse 400, 300

	;render
	RenderWorld
	
	If KeyHit(2) Then mode = 1
	If KeyHit(3) Then mode = 2
	If KeyHit(4) Then mode = 3
	
	Text 0,  0, "press 1/2/3 to change mode"
	Text 0, 20, "mode = " + mode + " (" + modename$(mode) + ")"
	Text 0, 40, "press LMB to move camera"
	Flip
	
Wend


End

;####################
Function makeworld()

	Rect 0, 0, 32, 32
	Rect 32, 32, 32, 32
	tex = CreateTexture(64, 64)
	CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex)
	
	cube = CreateCube()
	FlipMesh cube
	ScaleEntity cube, 10, 10, 10
	
	EntityTexture cube, tex
	ScaleTexture tex, 0.1, 0.1
	
	tex = CreateTexture(64, 64)
	For i = 90 To 1 Step -1
		Color 255-i*4,255-i*4,255-i*4
		Oval 32-i,32-i,i*2,i*2
	Next
	CopyRect 0, 0, 64, 64, 0, 0, BackBuffer(), TextureBuffer(tex)
	
	EntityTexture cube, tex, 0, 1
	EntityFX cube, 1
	
		
End Function


Great! I'm not quite done yet converting your code over to my engine, but it looks like it's going to be perfect. Thank you so much. I'll post it when it's done. Interesting level creation technique by the way.

It's not working out. Your suggestion moves the camera by arbitrary amounts, not absolute, so I have no way of tracking it and saving the camera's position to file. It also doesn't get along with the rest of my code for some reason. Amazing work though. I think I'll just live with it. It's such a minor bug: Camera goes diagonally toward the floor each frame before returning to the set height. No big. Thanks again to Gia. My camera dolly may have somewhat square wheels, but at least it has the ability to steer now thanks to you!

Hi, I noticed some lichen starting to grow on this topic, and it's still only about 90% solved, so I thought I'd move it up a few pages. I hope that's okay. You don't have to read the above posts, the following is the story so far:

At first the camera would move forwards and backwards just fine - as long as you never turned left or right (why would you need to do that?) If you did, and say turned right to face the wall there, and then tried to move forward, the camera would not move toward the wall, but world coordinates for forward, basically strafing the wall left.

So then Gia came along and fixed everything. Almost. Though the camera now moves toward any wall with ease, it's a pretty bumpy ride getting there if the camera's facing down at all.

I keep thinking the answer'll be something really simple again that won't necessitate an entire rewrite of the camera movement system, like maybe a simple UpdateWorld somewhere, or maybe a sight order change to the function calls?

Remember, the camera must never move toward the floor unless it's in mode 2. The move mode icons represent, in order from bottom to top: a dolly, a raise and lower rig, and a camera aimer, and it can never be more than one at a time! So any code that moves it diagonally downward means it's trying to be both a dolly and a raise and lower rig, and that's not what I need.

Hope someone can help with this getting to be ancient bug! :)

Here's the link again: http://files.filefront.com/MoveModeRelativity20081120zip/;12428618;/fileinfo.html

I'm lookin at it, but first off... the weird thing that gets me is that you use 'Quit' as a variable for a loadimage, and it's also a function name.

Global Quit=LoadImage("quit.png")

Function Quit()
End
End Function


That's probably not causing anything bad to happen, but it sure ain't right.
Same for...

Global AspectRatio#=1.6

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


How you're actually getting a real variable number from that function... I don't know... but that's just freaky to me.

Ok I noticed something. Put this before Flip in your code and run in debug mode

DebugLog "CameraY = " + EntityY(camera)


Since cameraheight
PositionEntity camera,cameraposition,cameraheight,cameradistance

is the only thing moving the camera up and down, it's the part of the problem.

I noticed the camera Y axis only changes if you move forward and backward, never left and right, so that gives somewhat of a clue.

EDIT!:
I somewhat see a (not 'the') problem. You're trying to fight against the relativity.. or whatever. For some reason, while you're moving it, it adds on the speed somewhere, trying to fight it from going diagonally. I might know a way to fix it, it's not like, TOTALLY complex, but it's probably something new to you.

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







;


Great, looks like you did a lot. I'll check this all out tonight. Sometime let me know if you want to be put in my credits too. Even if the above code isn't what I need, the previous suggestion got things about 90% better than they were before :)

That's probably not causing anything bad to happen, but it sure ain't right.

How you're actually getting a real variable number from that function... I don't know... but that's just freaky to me.

Heh heh heh heh heh... because Gia, I just can! Mwa ha ha - No, some things are still pretty messed up, I know. But I'm really happy with how things are going so far overall. It's only my first program afterall!

There's a LOT of things I could change in that program to make it at least "look" like it runs better. I would except for, it's your program so I'm not trying to make it mine lol. You can add me to credits if you want to ;) It won't hurt me :O lol...

Works perfect now, thanks for doing all that work. Email me if you need any art for your games.

OMG!

It's only my first program afterall!



Pretty good for a first program. It took me a lot of first programs (lol) before I could even do the Gorilla game.

Well it's a lot better now. Hey, about what you said in post 19, if you're looking for something to do, you can do that if you want. I'm not going to stop someone who wants to improve my engine for me! :)

The link you already followed goes to my filefront page, which has a bunch of stuff I've made so far. Go to town, if you want.

!!! If I were to change your program... lol... it would change.. like.... a lot. I've learned how to make my own system for buttons, like for my map editor, using types. It's all quad based and I've figured out how to edit textures while the program is running, so like, if I wanted to change a "1" to a "55", I could. Bad thing about the textures is that they HAVE to be to the power of 2.

I've made it so the size of the texture when the button is made, is big enough to hold a string that I attach to it, like "Quit". That in blitz3D is 8(font width) * 4(string width) which would make the texture 32x32. Now if the string was "Quits" then it would make the texture 64x64 just because it's a little bigger than 32. Might be a bit confusing but you have to experiment in order to understand.

Also, I've change how I do variable names.
;E = Entity
;I = Integer
;F = Floating
;S = String
;T = Type Variable Handle or wtver
;TYPE = Type Name
;FUNC = Function

;examples

E_Camera = CreateCamera()
I_Score = 22
F_Velocity# = 71.4
S_Name$ = "CakeMaster"
T_NewButton.TYPE_Button = New TYPE_Button

Type TYPE_Button
   Field E_Point ; Point being the main entity/model/texture/camera
End Type

Function FUNC_Button.TYPE_Button()
   Local a.TYPE_Button = New TYPE_Button
      a\E_Point = FUNC_CreateQuad() ; A custom quad making thing that I use
   Return a
End Function


Edit: Didn't notice that each post shows the post number, that's cool.

I'm not sure if I'd actually work on converting your program to my... "ways"... of doing things, but I might... seriously... I might :O lol

Kind of like how a clean freak likes to clean up stuff, I'm not a clean freak, but more like a "upgrade" freak.... lol... maybe... not sure... D:

Hm... as far as converting my program to types, picture Gary Oldman as Dracula seeing John Harker's crucifix for the first time. But other than that, if you're bored or something, just do what you want. I really respect your skills after fixing both my nightmarish past versions of my move modes.

you have to experiment in order to understand

Very true. I spent days getting my 2.1D image overlays perfect, which equated to hundreds of individual exparaments and quite a bit of caffeine! You gotta want it enough to give it your all. I try to only post when I'm practically dying for the help, like I was with my move modes.

Oh about your menu, I tried changing the resolution and the only the sprites stayed where they should be. Two bad things your doing is, positioning where you want the images, inside the images, instead of in the program, which, well, isn't the best way to do it. Second is, using images ;) I've been trying to change my ways by using "quads" and apply editable textures to them. They're not hard to position.

I gave each button (quad) a string variable for each one (in the button type), and created a function that loops through all the buttons, and does the "Select, Case" thing. The cases are the button string variables. If that button has that string, then, depending on the button, it checks if it's picked using CameraPick, and does it's own little function that I want it to do. Like I added a button for mine, in the top right corner, an "X" button. If you press it, it ends the program, easy. I'll try to put it up on the website (not the source) so you can see it :D

Direct link to the updated game... http://ias.bossyboy.com/forums/download/file.php?id=7 so you can take a look at the map editor.

MWAHAHAHA

I'm gonna go ahead and redo your program :D This'll be interesting. It'll give me something to do while I'm thinking of ideas for the Gorilla game.

No stealing now...

Glad to have motivated you though. I owed you big time for that move mode fix, so I guess now we're settled up :)

Ideas? Try the water levels in The Legend of the Mystical Ninja. Here it is: http://www.youtube.com/watch?v=sLcPDBgrvp4

Graphics, man, you need graphics! And music. There are lots of free media sites.

No one has to worry about me stealing anything... except ideas ;)

I've never heard of The Legend of the Mystical Ninja, but the level you gave the link to reminds me of this one from Donkey Kong Country 3 http://www.youtube.com/watch?v=uD-odJWbeBM&feature=related

And lol @ "Graphics, man, you need graphics! And music." At the moment I don't actually NEED anything. It's mostly just a slap together of all my knowledge and seeing what I can make/mold it in to. I've gotten most of the ideas for the Gorilla game from Super Mario World, Donkey Kong Country games, and Super Smash Brothers Melee and Brawl.

All of the textures I've made myself using paint shop pro, except the skysphere which my computer generated from a panoramic generator program someone posted. I made ALL of the models myself, except of course, the ground pieces, I coded them in the game, but there's no model FILE for them ;) But the 2 Gorillas, Kangaroo, Banana, Orange, and the latest enemy the Tick (and future models) I made myself.

Thanks to the video you showed me, it gave me an idea for more than one type of AI. Right now the only thing the enemies can do is...
1. Targeting system that sees how far away you are, and targets a player if he's close enough. If the player gets to far away, it stops targeting that player.
2. Try to follow you depending on which side you are on.
3. Jump if you are higher than it

But now I can try to add an AI chooser that let's you input a number to determine it's AI. So 1 could be the jumping following AI. AI 2 could be a flying AI that drops junk on top of you because you said bad things about it's momma.

I just realized I can make my OWN music.. so now I have any future musicy stuff covered.. hopefully. Not sure how to get it to loop in-game though. But hey, I can play piano, I have made my own songs, here's proof... http://www.youtube.com/watch?v=WvqJ6F5gdNM

Making songs isn't like.. the MAIN thing I do in life.. but I have made songs. I never write them down because well, it'd take too long. I remember my songs, and I play by ear which means that I can listen to a song and play what I hear. Sometimes I get the song off key but I can still play the song, usually not ALL of the song because I'm only human, I can't remember everything in one go. I have learned one song from a music sheet, "Gary Jules - Mad World", easy song.

The song I made that I show in the video, is a mix of lots of different songs. The VERY FIRST SONG that started me making that song was, "The All American Rejects - It Ends Tonight". I got a glimpse of the beginning of the song with and the song developed from there.

Wow I just typed a finger full (said a mouth full)

:D IT'S ALIIIIVEEE!!!!!!
http://rapidshare.com/files/196858257/MoveModeRelativity2009-2-11.rar

It's not all the way done yet, but it's good enough so far ;) Using quad based buttons and shiz. I haven't removed all of the images yet because I'm still in the process of figuring out what I want to remove. The mouse image I'll keep but I'll have to change it because all of that black space DOES NOT need to be in there. I'd use a quad based mouse cursor but hey, I wouldn't know how to get it to work right, or work with the CameraPick.

The button text at the top left might look a bit wonky but I can't help it. But I did figure out I dont HAVE to have the textures like 32x32 64x64, they can be 32x16 and 16x128 :)

I'm getting this, over and over and at different computers:

http://rs404tl.rapidshare.com/files/196858257/104996/MoveModeRelativity2009-2-11.rar

Any idea why?

What's the problem?

What I said! :) It won't download no matter where I try to download it from. Wanna just send it to me? My email's on my profile.

Oh, how about I'll try uploading it to FileFront then?

[[Here it is]]

Much better. That site I mean, I'll check out your Frankenstein tonight. I mean...I'll check out your adaptation tonight. Hopefully you didn't stitch anything together with arrays or that For/To stuff I hate. Well, I shouldn't say hate. Loathe, that For/To stuff I loathe.

Don't mind me, I'm sick today.

It doesn't look like mine, bud! Ha ha ha ha ha ha ha!

Hey, one thing I like...the sine slowdown. Could you apply that (simply) to one of my older bbs without changing much else? I'd say I could do some art for you in exchange, but you never take me up on that offer, so how bout in exchange for the motivation I already gave ya! ;P

Looking at your code, man... considering yours is about ten thousand times more complex than mine, and it works, and mine's simple and it works, wouldn't you say I could just keep on going in the direction I'm going and end up with a perfectly well liked program that a lot of people use and enjoy, even though if any actual coders saw the source they'd probably laugh? What I mean is, what's wrong with coding like a five year old as long as the program works?

Not sure about what sine slowdown your talking about, I don't usually slow anything down on-purpose. I'd let you do art for me it's just, I wouldn't know what I'd need atm.

To me, my code is much much simpler. The way you've set up the button clicking is half ok, but the images are set up totally wrong, even though it works, it's just not proper. As long as it works, you should be fine, just don't be surprised if someone can't help you if you're having a problem... lol.

No, sine... you know, sine and cosine? When you move anything now, it returns to the final position gradually. Maybe I'm using the wrong term, I'm not a math genius. But whatever it is, it was used everywhere in Metal Gear Solid to make all movements start and end more smoothly.

What are you, so good you used it without thinking about it?

Anyway the reason I start all my images at 0,0 is because I have so many to do. If I had to crop every single one in photoshop, then line every one up by number in the code, it would take way longer than just setting them all at 0 and knowing they'll end up in the right place no matter what. So some are bigger than they need to be, pngs are small, and my engine loads up fast enough for me.

See ya later :)

Oh, and see if you can put that slowdown thing in my older code now that you know what I'm talking about. "I'm going to need you to go ahead and come in on Sunday too..." Sorry, I didn't mean to say it like that! But if you could that'd be really helpful.

Um... I don't use any sine, tangent, cosine shiz when it comes to moving. Its just plain physics stuff.

X_Velocity = X_Velocity + X_Acceleration

X_Velocity = X_Velocity * X_Friction

X_Acceleration = 0


It does that with each axis.

So where would you work that into my code at the end of post 17? That was when you got it to the point were I thought it was best, but past that point I can't understand anything. Just put a codebox of that code with what you did with the friction or whatever.

By the way, could you send me another link for your gorilla game? I have some art ideas for it :)

I'll show you an example for the basic movement part and you can stick it in there yourself so you, hopefully, can understand it more.

Graphics3D 800,600,0,2
SetBuffer BackBuffer()

Global Light = CreateLight()
	
	
Global Camera = CreateCamera()
	PositionEntity Camera,0,5,-4
	RotateEntity Camera,EntityY(Camera)*10,0,0
	
CreatePlane()


Global Pivot = CreatePivot()
Global cube = CreateCube(Pivot)
	EntityColor cube,0,255,0

ScaleEntity CreateCylinder(6),.5,2,.5

;The closer the friction is to 1, the less the object being effect will slow down

Global X_Velo#,X_Accel#,X_Frict#=.965
Global Y_Velo#,Y_Accel#,Y_Frict#=.965
Global Z_Velo#,Z_Accel#,Z_Frict#=.965
Global Speed#

While Not KeyDown(1)
	
	;All the acceleration changes MUST be done BEFORE the MovePlayer function is called
	;or else nothing will change until the next loop
	
	If KeyDown(200) Z_Accel = .01 ;Forward
	If KeyDown(208) Z_Accel = -.01 ;Backward
	
	If KeyDown(203) X_Accel = -.01 ;Left
	If KeyDown(205) X_Accel = .01 ;Right
	
	
	;In order for the TForming to really be useful, you'd have to turn and then you'll see the effect
	If KeyDown(17) ;Forward
		TFormVector 0,0,.01,Pivot,0
		
		X_Accel = X_Accel + TFormedX()
		Z_Accel = Z_Accel + TFormedZ()
	EndIf
	
	If KeyDown(31) ;Backward
		TFormVector 0,0,-.01,Pivot,0
		
		X_Accel = X_Accel + TFormedX()
		Z_Accel = Z_Accel + TFormedZ()
	EndIf
	
	If KeyDown(30) ;Left
		TFormVector -.01,0,0,Pivot,0
		
		X_Accel = X_Accel + TFormedX()
		Z_Accel = Z_Accel + TFormedZ()
	EndIf
	
	If KeyDown(32) ;Right
		TFormVector .01,0,0,Pivot,0
		
		X_Accel = X_Accel + TFormedX()
		Z_Accel = Z_Accel + TFormedZ()
	EndIf
	
	;Turning code
	If KeyDown(16) TurnEntity Pivot,0,2,0 ;Turn Left
	If KeyDown(18) TurnEntity Pivot,0,-2,0 ;Turn Right
	
	MovePlayer()
	
	UpdateWorld
	RenderWorld
	
	Text 0,0,"X Velocity = " + X_Velo
	Text 0,20,"Y Velocity = " + Y_Velo
	Text 0,40,"Z Velocity = " + Z_Velo
	
	Text 0,80,"Total speed = " + Speed
	
	Text 0,120,"Keys:"
	Text 0,140,"WASD, QE, Arrow Keys"
	
	Flip
	
Wend
End

Function MovePlayer()
	X_Velo = X_Velo + X_Accel
	Y_Velo = Y_Velo + Y_Accel
	Z_Velo = Z_Velo + Z_Accel
	
	TranslateEntity Pivot,X_Velo,Y_Velo,Z_Velo ;This is the entity being effected
	;I guess you could have more than object effected by the same velocity if you wanted to
	
	X_Velo = X_Velo * X_Frict
	Y_Velo = Y_Velo * Y_Frict
	Z_Velo = Z_Velo * Z_Frict
		
	Speed = Sqr( (X_Velo*X_Velo) + (Y_Velo*Y_Velo) + (Z_Velo*Z_Velo) )
	
	X_Accel = 0
	Y_Accel = 0
	Z_Accel = 0
End Function


http://files.filefront.com/GorillaV6rar/;13283643;/fileinfo.html





LOL holy sh** that's awesome :D Hehe, maybe I'll mess around with my image just to one up you (nicely though).

Edit: Hmmmm I don't know how YOU did it. What I'm messing around with doesn't look near as good as yours.

I'm not even going to show it lol, it's that bad.