Animated rotation of the camera 90 degree wise

Started by phlux, August 09, 2013, 04:31:50 PM

Previous topic - Next topic

phlux

Hi again.

I'm still on my prototype of my dungeon crawler thing demo. However I'm not quite sure how to implement 90 degree wise camera rotation.
I'm using the advanced example from the wiki as a source base. The example uses ticks for animation. My idea was that the camera needs some defined amount of ticks to finish a 90° rotation. So if a keypress to rotate the camera is detected I would use the animate() function from the example to rotate the camera until an amound of ticks is reached. Say a rotation would take 100 ticks for 90 degrees, so I would rotate the camera 0.9 degree each tick.

Is this the correct approach or is there a better way to accomplish this kind of camera movement?

I've seen that there is already some functions like checkCameraCollision() in the World class for basic cam movement (forward/backward). How are these implemented? Also are these suited for non rotational movement in a dungeon crawler?

Thanks again,
Chris

Gatobot

yes , the approach your using for camera rotation is ok, this will give a smooth animation everytime you turn,  you should use grid based movement instead of checking for collisions with the camera, i think its better for this kind of games.

EgonOlsen

Quote from: Gatobot on August 09, 2013, 05:52:12 PM
you should use grid based movement instead of checking for collisions with the camera, i think its better for this kind of games.
I second this. It's much easier and more feasible for this kind of game.

phlux

Quote from: EgonOlsen on August 10, 2013, 09:29:33 AM
Quote from: Gatobot on August 09, 2013, 05:52:12 PM
you should use grid based movement instead of checking for collisions with the camera, i think its better for this kind of games.
I second this. It's much easier and more feasible for this kind of game.

Okay so i'm on the correct way for the rotation. What method should I use for directional movement? When I move from tile to tile I need to move two units (as plates have a width of two and you stand in the middle). Shall I use moveCamera with a vector and a speed which equals the current tick count or shall I use setPosition with a vector with a small increased amount in a direction (the same tick/unit ratio like for the rotation)?

EgonOlsen

That's totally up to you. Use whatever fits your needs.

phlux