# Help understanding center origin of even h/w of sprite

Get help using Construct 2

### » Tue Jun 09, 2015 11:23 pm

Hello,

I was checking out the tutorial below and got hung up on the even vs odd pixels.

https://www.scirra.com/tutorials/1377/h ... onstruct-2

In the video it was mentioned to use a sprite with even width and height instead of odd because the center would be off by a pixel. I don't see how you get a center with even sides. Trying to visual this I i was checking out what C2 does. The origin appears to be in the Top Left of the pixel chosen as the origin. I guess this would actually make it the center visually since it intersects the 4 center pixels. I was under the assumption rotation occurs around the pixel itself.

Image:

Thanks for any clarity!
B
12
S
2
Posts: 22
Reputation: 648

### » Wed Jun 10, 2015 9:09 am

you can set the origin points with half measures also now! so if your picture is 17x17 your center coordinates should be X 8.5 y 8.5 ! you can calculate the center with the calculator by taking the width height of your sprite, and divide it by 2! then input the result for X Y in the origin point thing! hope it helped! not sure if i was on point! dident really understood ur question!
B
85
S
26
G
75
Posts: 1,438
Reputation: 47,776

### » Wed Jun 10, 2015 12:37 pm

gamecorpstudio wrote:you can set the origin points with half measures also now! so if your picture is 17x17 your center coordinates should be X 8.5 y 8.5 ! you can calculate the center with the calculator by taking the width height of your sprite, and divide it by 2! then input the result for X Y in the origin point thing! hope it helped! not sure if i was on point! dident really understood ur question!

Thanks gamecorpstudio.

Hmm, maybe I should ask the author of the tutorial to clarify why to use divisible by 2 width and height. I didn't try .5 pixels hehe. I should just accept that it works lol. Just wish I knew why or how.

In the tutorial the author used a 256x256 sprite and set the origin at (0,128) because of how he wants it to rotate. So, 256/2 = 128. I get that. But visually that pixel isn't in the middle. You would have to have an odd number to get a whole pixel in the middle. For example: A 3x3 sprite would look like this where [x] is the center:
x x x
x[x]x
x x x
B
12
S
2
Posts: 22
Reputation: 648

### » Wed Jun 10, 2015 12:50 pm

Yeah, you are absolutely right, but why would you want a pixel in the middle?

The center of your 3*3 sprite would be 1.5 , 1.5
If you would use 2 , 2 the center would be off, because it would be on the bottom-right of the middle sprite..

The origin is a coordinate, not a pixel..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

### » Wed Jun 10, 2015 1:46 pm

Oh man after reading your comment @LittleStain and thinking about it for a while... it makes sense! Pixels can be subdivided. Thus, there are values in between. So, top left of a sprite is (0,0) which I was assuming is a single pixel (I was looking at the whole square). That pixel covers the values 1> x >= 0. What you said about 2,2 being the bottom right of the middle seems more clear now. I was so stuck with the idea of physical pixels like on a monitor and that something cant be smaller than the physical pixel. I am not sure If I explained myself well, but I think I understand it more.

Thanks!
B
12
S
2
Posts: 22
Reputation: 648

### » Wed Jun 10, 2015 2:59 pm

Don't be confuse between the distance unit "pixel" (which is a number for the computer, and like real distances, is not bound to integers) and the entity "pixel" (which is a small dot to render the screen that can be colorised), nothing smaller than a pixel will be rendered precisely sure, but your computer should do interpolations to colorise the area clearly enough (a 5x5 square can be placed at exactly a 5x5 space pixels, but it may also be slightly off, the program will then decide what to do for that, does it draw it at integer positions only, or does it renders it with smoothing on the edges, or even other things).

The logic of your game can have half pixels, the drawing part have to compensate, it won't throw a "wtf subpixel what are you doing dude??! U crazy!" Error, it will just renders it in a certain way.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200

### » Wed Jun 10, 2015 3:19 pm

@Aphrodite HAHA! That was a great comment. All the comments have helped to better understand what is happening. I appreciate it!
B
12
S
2
Posts: 22
Reputation: 648

### » Wed Jun 10, 2015 3:22 pm

This however may be untrue for some displaying methods that requires integer pixels only like older game consoles, I cannot say for sure.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
54
S
23
G
18
Posts: 2,123
Reputation: 17,200