Yeah, that's basically how we're going to handle it. I didn't even realize the player was being snapped to a grid in the video, since motion looked so smooth.Light-Dark wrote:Basically it's doing a bounding box collision detection between the player and the specified tile, if the player is colliding with the lower tile it shifts the depth value down in lua, however if the player is colliding with the upper tile it shifts the depth value up. To keep from creating unnecessary issues I have the players x and y 'snapped' to multiples of 32x32 so the player won't be colliding with both at the same time. This system serves as a place holder for the moment.
Chrono Trigger's engine calls these "z-transitional" tiles.
You have the right basic idea (obviously, or it wouldn't be working as well as it is now). The order of operations is:Light-Dark wrote:And this is how camera zooming/rotating is currently handled:void GameSystem::Camera_Transform(const float scale,const float rotation) { UniformScaleVal = scale; camera.w = SCREEN_WIDTH * (1/scale); camera.h = SCREEN_HEIGHT * (1/scale); glScalef(scale,scale,1); glTranslatef(camera.w/2,camera.h/2,0); glRotatef(rotation,0,0,1); glTranslatef(-camera.w/2,-camera.h/2,0); }
1) translate to the center of the screen, so that every transform is now relative to this point.
2) apply the camera's uniform zoom/scale
3) apply the camera's rotation
4) translate back to the camera's world-space coordinates
Actual algorithm used in ES:
Code: Select all
void CameraSystem::PushTransform(void) {
gyMatPush();
gyMatTranslate(_scrWidth/2.0f, _scrHeight/2.0f, 0.0f);
gyMatScale(transform._scale.x, transform._scale.y, 1.0f);
gyMatRotateZ(transform._orientZ);
gyMatTranslate(-transform._pos.x, -transform._pos.y, 0.0f);
}