GML [SOLVED] image_angle ruins sprites?

Dr_Nomz

Member
So for the longest time I've always used this code when making Top Down Shooters:
image_angle=point_direction(x,y,mouse_x,mouse_y)

It makes the sprite point towards the mouse, which is pretty important for shooting guns.

However, now GMS seems to be doing this to my sprites:

So instead of having a sprite displayed, it's warped and has a dead pixel floating by the gun that shouldn't be there, and yes I checked the sprite itself, so it's definitely a GML problem.

Anyway to fix this? Because in older versions it wouldn't anti-alias at all, so no errors like this would appear.
 

marasovec

Member
Well then you can use draw_sprite_ext instead of rotating the whole sprite
Code:
var pd = point_direction(x,y,mouse_x,mouse_y);
draw_sprite_ext(sprite, 0, x, y, 1, 1, pd, c_white, 1);
 
Last edited:
What do you mean by warped exactly?

You can try turning off texture interpolation. You can also try filling in empty space with the same colour as your gun (except with zero opacity).
 

Dr_Nomz

Member
Yeah when I tired it marasovec's way it just gave this error...
Variable obj_Shooty.pd(100011, -2147483648) not set before reading it.
at gml_Object_obj_Shooty_DrawEvent_1 (line 1) - draw_sprite_ext(sprite,0,x,y,1,1,pd,c_white,1);

That said, what's texture interpolation? I didn't find any settings like that in the room I have the sprite in, and image angle doesn't have that as far as I know.
 

RangerX

Member
This happens because GMS doesn't pull any tricks on your low res sprite there unless you'd have the interpolation on. (which would add a bicubic cheap anti alias causing more blur than anything else).
To have a smooth rotation you simply need more resolution. The more pixels there is to draw your shape, the more precise it will be!
 

Dr_Nomz

Member
This happens because GMS doesn't pull any tricks on your low res sprite there unless you'd have the interpolation on. (which would add a bicubic cheap anti alias causing more blur than anything else).
To have a smooth rotation you simply need more resolution. The more pixels there is to draw your shape, the more precise it will be!
Thanks for the tip, but I like 💩💩💩💩ty graphics. xD

That said, how do I turn OFF the interpolation? You know, so image angle doesn't anti-alias anything?
 
Yeah when I tired it marasovec's way it just gave this error...
Variable obj_Shooty.pd(100011, -2147483648) not set before reading it.
at gml_Object_obj_Shooty_DrawEvent_1 (line 1) - draw_sprite_ext(sprite,0,x,y,1,1,pd,c_white,1);

That said, what's texture interpolation? I didn't find any settings like that in the room I have the sprite in, and image angle doesn't have that as far as I know.
This won't solve your problem, but try to fix your errors. Reading them really helps haha. It says pd isn't set. Make sure you copied the other line too that goes before it.
 

RangerX

Member
Thanks for the tip, but I like ****ty graphics. xD

That said, how do I turn OFF the interpolation? You know, so image angle doesn't anti-alias anything?
I think you don't understand. Your graphic looking low res and being actually low res is 2 very different things. You need resolution for smooth rotation. The higher the resolution the smaller the pixels. Therefore there's more pixel to represent your image at an angle. More squares of colors put together for your image to be precise. Look at my avatar. Right now its a character that looks like a 24x24 character but the resolution of the image is 96x96. A rotation of that 96x96 image will end up MUCH smoother than a 24x24. Its logic.

I made this image. Obviously resizing the results for convenience:


Can't have both. You have 2 choices:
- True low res graphics that rotate like sh....
- High res graphics (still made to look low res) with smooth rotation.

Pick your poison my friend.
 

Dr_Nomz

Member
Right that DOES make sense, but what doesn't is image_angle adding anti-aliasing to an image that doesn't have or need it, and ending up with pixels that don't belong there. :/

Game Maker USED to not use anti-aliasing with the image_angle code, anyway to sort of have that same effect? (And yeah it would look like your 32x32 there, but that's better than out-of-place pixels.)
 
Top