Skip to main content
deleted 54 characters in body
Source Link

You need to have every object positioned relative to the world, not instead of the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically,Typically the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of approximately (0,24) in the [picture][1].

As for actually drawing the objects the camera can "see", you nowmust draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviouslyObviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera'simplement a view culling system. [1]: https://i.sstatic.net/GF4lH.png

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of approximately (0,24) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

You need to have every object positioned relative to the world instead of the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Typically the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of approximately (0,24) in the [picture][1].

As for actually drawing the objects the camera can "see", you must draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Obviously some objects are not actually visible to the camera, so you may want to implement a view culling system. [1]: https://i.sstatic.net/GF4lH.png

added 14 characters in body
Source Link

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of approximately (0,1624) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of (0,16) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of approximately (0,24) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

Grammar
Source Link

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the camerascamera's coordinates will position it from the upper left corner. This means the camera would have a world position of (0,16) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the cameras coordinates will position it from the upper left corner. This means the camera would have a world position of (0,16) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

You need to have every object positioned relative to the world, not the screen. Your camera should also have its own world coordinates so it can be drawn at a relative position in the world. It may also be convenient to have your camera follow an object, so wherever the object is, the camera just uses its coordinates. Now typically, the camera's coordinates will position it from the upper left corner. This means the camera would have a world position of (0,16) in the [picture][1].

As for actually drawing the objects the camera can "see", you now draw all objects relative to the camera's world coordinates. To compute an object's screen position relative to the camera, simply do:

int screenX, screenY; //screen position of the object being drawn

screenX = object.x-camera.x;
screenY = object.y-camera.y;

Now obviously some objects are not actually visible to the camera, so you may want to check if the screen position for any object to be drawn is within the camera's view. [1]: https://i.sstatic.net/GF4lH.png

Source Link
Loading