2D Rotation and Movement

Blitz3D Forums/Blitz3D Beginners Area/2D Rotation and Movement

Crazy4Code(Posted 2005) [#1]
I have some questions about scroll-type movement and rotation. First, when you rotate, how do you get it to move in the new "front" direction? And also, I need the player to be able to move any direction, and I need the player to stay in the middle of the screen. Would I move the rest of the world instead of the player, because if I moved the player, wouldn't it just go off the screen? or is there a way for the screen to follow the player?


Hujiklo(Posted 2005) [#2]
Parent your camera to the player..or better still to an invisible pivot which the player is parented to which never rotates(only rotate the player)
An entity always moves in its new direction after a rotation...translate command ignores such rotations.


Crazy4Code(Posted 2005) [#3]
I'm talking about 2D though.


Hujiklo(Posted 2005) [#4]
So you're not using any polygon entities at all? Blitz3D?


Crazy4Code(Posted 2005) [#5]
I'm using Blitz3D, but I'm making a 2D game. Or is it possible to use some 3D things like cameras to help?


Hujiklo(Posted 2005) [#6]
Do everything you can using 3d entities and simply limit their movement to 2 axis. Blitz3d's commands are better and will give you more possiblities this way - you can tweak the camera to kill any perspective if you wish, though a little 3d perspective in a 2d game can work really well...and to top it all off you can use anything from the code-archives that might be handy with next to no modification where entities are concerned.

I'm doing exactly the above for a 2d platformer.


Crazy4Code(Posted 2005) [#7]
So your saying, make a 2D game with 3D models, or are you talking about sprites?


Hujiklo(Posted 2005) [#8]
Use models...and use sprites for fx and screen displays if they are needed.

But first up - what kind of 2D game are we talking about here?


Crazy4Code(Posted 2005) [#9]
I'm not sure yet. I have so many ideas, but they all require rotation, so that's why I asked my question. But, just for my knowledge, let's say that I wanted to use only 2D images. How would I turn and move?


Ross C(Posted 2005) [#10]
It also depends how difficult you want to make things. Rotation, scaling and alpha effects are far easier using 3D, but collision stuff, such as pixel perfect collisions are alot harder to do. Plus drawing a spaceship image is alot easier than building a spaceship model if your not a 3d modeller.

To make your ship move in the angle you rotate it, in 2d, you need to record the angle you've rotated the ship to, say


angle = 20

x = x + cos(angle)
y = y + sin(angle)



if you want to increase the speed at which it moves, then


speed# = 2.0
angle = 20

x = x + (cos(angle) * speed)
y = y + (sin(angle) * speed)



Just remember you'll want to have you ship images pre-rotated and held in an array, because blitz 2d rotateimage command is slow and not really for real time use.


Crazy4Code(Posted 2005) [#11]
That's exactly what I was thinking of :)