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;
Orthographic Camera
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement