It looks like you're new here. If you want to get involved, click one of these buttons!
orxOBJECT* tile;
for (orxU32 i = 0; i < 6; i++) {
tile = orxObject_CreateFromConfig("TileObject");
// -- assign position
orxVECTOR tilePos = {-240+i*80, -240+i*80, 0};
orxObject_SetPosition(tile, &tilePos);
}
;
DISPLAY
;
[Display]
ScreenWidth = 480
ScreenHeight = 800
[Viewport]
Camera = Camera
[Camera]
FrustumWidth = @Display.ScreenWidth
FrustumHeight = @Display.ScreenHeight
FrustumFar = 1.0
FrustumNear = 0.0
Position = (0.0, 0.0, -1.0)
;
OBJECTS
;
[TileObject]
Graphic = TileGraphic
;
GRAPHICS
;
[TileGraphic]
Texture = tutorial-tiles.png
TextureSize = (80,80,0)
TextureOrigin = (0,0,0)
Comments
int i = 2;
float x = -240+80*i;
x -> -80
unsigned int i = 2;
float x = -240+80*i;
x -> INT_MAX
somehow this has never bothered me before, heh
Snippets for orxObject's Functions
A small note though: the world coordinates are *not* directly correlated to screen position, it all depends on the viewport/camera couple that renders that portion of the world and where it's display on the target surface.
In your example, your camera points to x,y = 0,0.
As your associated viewport covers the whole display surface, that will then map the (0,0) world coordinate to the middle of the screen.
However if your camera were in (240, 400), the (0,0) of the world would then be rendered in the top left corner of your screen.
Of course, in addition to position, one has to account for the camera zoom and rotation as well.
There are functions in the orxRender API to convert coordinates between screen and world spaces. They'll also let you know if the input coordinates maps outside the destination (for ex, if the world coordinates you pass to orxRender_GetScreenPosition() isn't actually on screen).