I have a normal game window which is 640*480, and everything is fine, but when I try to maximize the window, the objects translate to different positions on the screen, for example If I have a circle which is drawn at the center in the normal window, when I try to maximize it, it shifts away from the center of the screen. How do I adjust it so it draws at the center in both normal window and maximized window ?
|
|
Is this is a 2D game, you need to position your objects based on ratios or percentages. For example instead of putting your object at If it's a 3D game, your camera class should expand the view port from the center out. Meaning, keep the camera in the same position, with the same target vector. |
|||
|
|
This may not be the most efficient method, but it's certainly easy. If you can make canvases/surfaces/framebuffers/whatever you call them, then you can just code the game for a specific resolution (may as well stick with 640x480), draw everything gameplay-related to the canvas, and then draw the canvas scaled based on the window width and/or height. For a game that is usually 640x480:
|
|||
|
|