: I don't really understand how to position the objects in C++... or i
: got it until my teacher said something and messed everything up.
: so, when you're putting an image in the middle of the screen, is it:
: object_info.x= screen->w/2;
: object_info.y= screen->h/2;
: and i also don't get how to access the top, right side, bottom, and
: left side of the rectangle (of the image)...
: thanks
:
Useually the program would store the rectangle and render it
to that location.
As for position an image on center:
x = (screen_width/2) - (x_pos + obj_width/2)
y = (screen_height/2) - (y_pos + obj_height/2)
Graphically (Using the formula for x):
<< decrement
+----------+----------+--screen
^ | |
- | |---|-----------object
| |---| |
| ^-| << Here we have to subtract half of the objects
+ | | width from the center
v +----------+----------+
| | |
0 screen_width/2 screen_width
The same concept applies for the y formula.
Hope this helps;