# questions about position and size

I am new to game development and I wanted to ask a question.

I am reading the simple game example from here.

1) I want to ask why we define bucket.x = 800 / 2 - 48 / 2 ? How is that? Why not just set bucket.x=400 ( at the middle position).

...

camera.setToOrtho(false, 800, 480);
...
bucket = new Rectangle();
bucket.x = 800 / 2 - 48 / 2;
bucket.y = 20;
bucket.width = 48;
bucket.height = 48;


2) The bucket width and height are seet 1/10 of our screen size.Ok. But what about the real dimensions of bucket object?I mean , the bucket what size must be?32x32 pix?48X48 pix?How we handle that?

3) Also, I am a bit confused about x and y dimensions. x refers to width and y to height as we see the cell phone in portrait mode? So , if we are in landscape mode , y is "x"?

Thanks!

• Sounds like you want a discussion about it, you should ask in chat since you have the rep. May 31 '13 at 14:19

1. If you set bucket.x as 400 you will draw the left edge of the bucket at 400 which will make it displaced to the right. You need to draw the center of the bucket at 400 to effectively center it, hence you subtract its size divided by 2.
3. X will always be the horizontal coordinate and Y the vertical one. Just consider you changed resolutions, for example, from 640x480 to 480,640.