Absolute rotation and movement ?

Blitz3D Forums/Blitz3D Beginners Area/Absolute rotation and movement ?

StOrM3(Posted 2004) [#1]
Hello,

I need some help, I got my random model placement and dropping routine to assign the correct locations and stuff, now I have the player in the game as well, but what I am having a problem with is rotating the player on keypresses, I want the player to rotate 90 degree increments like 0, 90, 180, 270 based on the cursor key pressed. Like if they press up rotate to 0, left rotate to position 90, down to 180 and right to 270. I tried it myself, but something is wrong when you press up or down I get Right, and Right and Left arrows are giving me Left facing. ?? No up or Down is working. I am using rotateentity entity, 0, and 0,90,180,270 here for rotation, 0 am I doing this right, I know there is a bug in the logic somewhere, or I don't understand blitzes rotation function. I use the arrow keys to rotate the model, then when the user presses space it moves in the direction it is facing.

Someone please help me, so example code on how to do this would be great. Thanks

I appreciate any and all help you guys could provide, NOTE the initial player direction is being set to 0 on setup.


Ross C(Posted 2004) [#2]
You tried turnentity? I'm not too sure what your meaning..


StOrM3(Posted 2004) [#3]
use turnentity instead of rotateentity ? I'll try that.


StOrM3(Posted 2004) [#4]
turnentity didn't work either, it almost is working, but now it turns the entity the amount specified like 90 degrees each time you press left, I don't want this, I want it to face left at 90 degrees no matter how many times you press left. A code example showing how to ensure the rotation is 90 degree increments would be great.

Thanks


Ross C(Posted 2004) [#5]
You mean like this?

Graphics3D 800,600
SetBuffer BackBuffer()


camera=CreateCamera()
PositionEntity camera,0,10,0
RotateEntity camera,90,0,0


cube=CreateCube()
cone=CreateCone()
EntityParent cone,cube
TurnEntity cone,90,0,0
ScaleEntity cone,1,3,1


While Not KeyHit(1)




	If KeyHit(203) Then RotateEntity cube,0,90,0
	If KeyHit(205) Then RotateEntity cube,0,270,0
	If KeyHit(200) Then RotateEntity cube,0,0,0
	If KeyHit(208) Then RotateEntity cube,0,180,0	
	
	UpdateWorld
	RenderWorld
	Flip
Wend
End



(tu) sinu(Posted 2004) [#6]
post your code, your doing something wrong.


jhocking(Posted 2004) [#7]
It sounds like you want RotateEntity with the optional global flag set to True. Something like RotateEntity cube,0,90,0,True

Unless I'm misunderstanding you (which is rather likely actually.)


StOrM3(Posted 2004) [#8]
okay, here is the type of movement I want to achieve, have you ever seen the online game cubis ? where you use the mouse to move different colored blocks areound the screen ? This is what I want for my puzzle type game, I got the keyboard version working, turning right etc.. had to use if statements inside each direction 1-4, to verify where we currently facing before moving then moving the correct amount to face the dir you wanted to face. Now I tried playing it using the keyboard, and I think the controls would be better with the mouse like cubis to rotate around the items in the center of the screen, if anyone could post some example code of this type of movement controlled by the mouse, at 50 pixel increments like top right and bottom and top of the items which are in the center of the screen at 50 pixel increment rows etc.. I want the bubble controlled by the player to rotate around the items outside the rows, using the mouse etc.. and move to the items in that row when you hit the mouse button. I will post my code when I get home, I am at work today, so you can see what I have so far.

Thanks for all the help!

Ken


Shambler(Posted 2004) [#9]
It came to a full stop there for me since I've never seen the cubis game lol

Smurfing the net for it now...


Andy_A(Posted 2004) [#10]
It sounds like you want something like this:
;Lt = 180 degrees
;Rt = 0 degrees
;Up = 270
;Dn = 90

currentDir = (whatever)
inc = 90   ;(use appropriate increment for your game)
If KeyHit(Left) Then
    Repeat
        currentDir = (currentDir + inc) Mod 360
    Until currentDir = 180  ;will always point left
    ;Rotate entity to currentDir
End If


Do the same for the other key directions.