• Advertisement

Archived

This topic is now archived and is closed to further replies.

Orthographic Camera

This topic is 5286 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I am just looking to do an older rpg type camera, siple move the cam up,down,left,or right, from a top down perspective. This code works but sor some reason I cant figure out why when you change camera it doesnt stop and move right away. Ex. if i press Left the cam moves, but when i press right it keeps moving in left direction for so long before it changes. http://xenge.emulation64.net/program.zip if you wanna see what i mean. its only 54b
struct CAMERA
{
	float new_X, new_Y, old_X, old_Y;
};

void CameraMove(int direction)
{
	glMatrixMode(GL_PROJECTION);
	switch(direction)
	{
	case CAM_UP:
		{
			cam.old_Y =  cam.new_Y;
			cam.new_Y -= .5;
		}
		break;
	case CAM_DOWN:
		{
			cam.old_Y =  cam.new_Y;
			cam.new_Y += .5;
		}
		break;
	case CAM_LEFT:
		{
			cam.old_X =  cam.new_X;
			cam.new_X += .5;
		}
		break;
	case CAM_RIGHT:
		{
			cam.old_X =  cam.new_X;
			cam.new_X -= .5;
		}
		break;
	}
	glTranslatef((float)cam.new_X, (float)cam.new_Y, (float)0);
}
	case WM_KEYDOWN:
		{
			if(wParam == VK_UP)
			{
				CameraMove(CAM_UP);
				return 0;
			}
			if(wParam == VK_DOWN)
			{
				CameraMove(CAM_DOWN);
				return 0;
			}
			if(wParam == VK_LEFT)
			{
				CameraMove(CAM_LEFT);
				return 0;
			}
			if(wParam == VK_RIGHT)
			{
				CameraMove(CAM_RIGHT);
				return 0;
			}
		}
		break;

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement