• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

GameMaker [solved - Easy way: use sub-images] Accurately rotating an odd width sprite

T

trentallain

Guest
Is there a way I could use lengthdir or something similar to rotate a sprite like this correctly?:
9658603c-d303-47e1-b90b-717812e6f296.png (its small)

Around the point X:
Code:
OOO
OXOOOOOO
OOO
I'm trying to make the pointer thing on a gauge rotate correctly, but just setting the origin at that point will not work because of the way sprites rotate.
 

TsukaYuriko

☄️
Forum Staff
Moderator
To clarify what the issue is...

Different GM versions use different ways of sprite rotation.
Sprite rotation origins can be either in between four pixels or in the middle of a single pixel.

If it's in between four pixels, by default, even-sized sprites will rotate properly.
If it's in the middle of a single pixel, by default, odd-sized sprites will rotate properly.

The topic author is using odd-sized sprites on a version where the center of rotation is in between four pixels.
 
T

trentallain

Guest
To clarify what the issue is...

Different GM versions use different ways of sprite rotation.
Sprite rotation origins can be either in between four pixels or in the middle of a single pixel.

If it's in between four pixels, by default, even-sized sprites will rotate properly.
If it's in the middle of a single pixel, by default, odd-sized sprites will rotate properly.

The topic author is using odd-sized sprites on a version where the center of rotation is in between four pixels.
Yep that's what I meant (sorry)
Is there a way to work around that so I can rotate it correctly?
 

Slyddar

Member
It's an interesting question, and @TsukaYuriko has explained it perfectly, for those thinking it's not an issue.

I guess if you take note of the origin x/y point you want to rotate around in the create event, which will be the center of the current pixel (x+0.5, y+0.5), you could translate (x,y) to that position by some trigonometry calculations, which would find the the x and y distance that origin x/y point has moved from the original origin, translate that point back to the original origin, and then add (x + 0.5, y + 0.5) to put it at your required rotation point.

Don't really have the time to do the calcs, but I believe that is how it could be done. Happy to hear other thoughts though.
 
T

trentallain

Guest
I guess if you take note of the origin x/y point you want to rotate around in the create event, which will be (x+0.5, y+0.5), you could translate (x,y) to that position by some trigonometry calculations, which would find the the x and y distance that origin x/y point has moved from the original origin, translate that point back to the original origin, and then add (x + 0.5, y + 0.5) to put it at your required rotation point.

Don't really have the time to do the calcs, but I believe that is how it could be done. Happy to hear other thoughts though.
You know what, its probably going to work a lot better if I just use sub images for each position hahaha
 

GMWolf

aka fel666
What? How did YYG manage to get that between pixels /middle of pixels?
Should be floating point and rotate around whatever you want...

Build a vertex buffer. Rotate it in the vertex shader. That way your origin can be exactly where you need it, and you don't have to deal with GMs **** **** ***.

Ah, but then you have to deal with your graphics vendor's *** ******* ** ****.
The way it's gonna rasterize will probably end up weird.
 
Last edited:
Top