Sprite Angles
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
Consult the Resource/Request Posting Guidelines for more information.
Please don't put requests here! They have their own forum --> here. Thank you!
Before posting your Resource, please make sure you can answer YES to any of the following questions:
- Is the resource ENTIRELY my own work?
- If no to the previous one, do I have permission from the original author?
- If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
Consult the Resource/Request Posting Guidelines for more information.
Please don't put requests here! They have their own forum --> here. Thank you!
Sprite Angles
Does anyone know of a good method for rotating gore sprites 45 degrees without completely ruining the image, or without having to completely redraw it?
Thanks
Thanks
- Caligari87
- Admin
- Posts: 6234
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Sprite Angles
There's some specialized algorithms for it like RotSprite which might be useful. The "by hand" way is to upscale like 10X, then rotate, then downscale and clean up. But both are really just "better than nothing." If you want to rotate sprite/pixel art by something other than 90-degree increments, then probably best to redraw it.
Alternatively, you might be able to use in-game rotation functionality such as A_SetRoll, to draw a sprite on a certain angle without resampling the art.

Alternatively, you might be able to use in-game rotation functionality such as A_SetRoll, to draw a sprite on a certain angle without resampling the art.

Re: Sprite Angles
Thank you for the reply, I tried RotSprite and the outcome was 10x worse than photoshop lol.
Can you tell me how to use A_SetRoll? I currently have this code for a gib.
So how would I translate this using your method?
Can you tell me how to use A_SetRoll? I currently have this code for a gib.
Code: Select all
ACTOR OrbHalf1: Gibs
{
States
{
Spawn:
ORBG ABCDEFGH 5
Loop
Death:
ORBG A 1
ORBG A -1
Stop
}
}
Re: Sprite Angles
Actors need a +ROLLSPRITE flag, otherwise any rolling functions will have no visual effect.
- Pandut
- Posts: 231
- Joined: Tue Mar 23, 2010 4:47 pm
- Preferred Pronouns: No Preference
- Graphics Processor: nVidia with Vulkan support
- Location: existential dread
Re: Sprite Angles
+ROLLSPRITE is a godsend. It's fantastic to use for gore/items being thrown around and also particle effects.
This is what I usually rely on to get a single randomly rotated sprite. Calling it once will only rotate the sprite once, if you want it to keep rotating you'll have to call it multiple times. Using a random equation for the angle whilst calling A_SetRoll multiple times will basically cause the sprite to have a seizure, so be careful with that lol.
If you want the gib to rotate while in the air but go back to it's default angle in its death state, you can use A_ChangeFlag(ROLLSPRITE, FALSE).
Code: Select all
A_SetRoll(roll+random(0,359), SPF_INTERPOLATE)
If you want the gib to rotate while in the air but go back to it's default angle in its death state, you can use A_ChangeFlag(ROLLSPRITE, FALSE).
Re: Sprite Angles
Pandut wrote:+ROLLSPRITE is a godsend. It's fantastic to use for gore/items being thrown around and also particle effects.
This is what I usually rely on to get a single randomly rotated sprite. Calling it once will only rotate the sprite once, if you want it to keep rotating you'll have to call it multiple times. Using a random equation for the angle whilst calling A_SetRoll multiple times will basically cause the sprite to have a seizure, so be careful with that lol.Code: Select all
A_SetRoll(roll+random(0,359), SPF_INTERPOLATE)
If you want the gib to rotate while in the air but go back to it's default angle in its death state, you can use A_ChangeFlag(ROLLSPRITE, FALSE).
Ok this sounds good but I'm not really sure how to use it effectively. Here's a rough idea of the method I have been using but I need 8 different sprites per gib which is not only annoying and time consuming, but the 45 degree angles look like crap unless I re-draw them/edit them.
Spoiler:Can you show an example of how to convert it to your method? (provided it is possible lol)
- Pandut
- Posts: 231
- Joined: Tue Mar 23, 2010 4:47 pm
- Preferred Pronouns: No Preference
- Graphics Processor: nVidia with Vulkan support
- Location: existential dread
Re: Sprite Angles
I'm a pretty amateur coder, so I'd take my example with a grain of salt. If I wanted my gibs to keep spinning at 45 degree intervals, I'd trying something like -
If it doesn't look the best, you can lower the ticks in the spawn state for quicker/smoother transitions between the rotations. An example can only take you so far, the best way to learn is to just spend time messing with it yourself. Also, always consult the Zdoom wiki -- https://zdoom.org/wiki/A_SetRoll
Code: Select all
ACTOR CHFTorso: Gibs
{
+ROLLSPRITE
States
{
Spawn:
CHFT A 5 A_SetRoll(45), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(90), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(135), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(180), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(225), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(270), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(315), SPF_INTERPOLATE)
CHFT A 5 A_SetRoll(360), SPF_INTERPOLATE)
Loop
Death:
TNT1 A 0
TNT1 A 0 A_ChangeFlag(ROLLSPRITE, FALSE)
CHFT A 1
CHFT A -1
Stop
Re: Sprite Angles
Thanks for the reply, I tried your method but the gib seems to rotate in a large swooping action, instead of where it is (on the spot in mid air) like the previous method I wrote before with 8 rotation sprites.
Any idea what I might be doing wrong?
Any idea what I might be doing wrong?
- Caligari87
- Admin
- Posts: 6234
- Joined: Thu Feb 26, 2004 3:02 pm
- Preferred Pronouns: He/Him
- Contact:
Re: Sprite Angles
Sprites roll around their offset origin. You need to center the offset.


Re: Sprite Angles
Thanks you kind sir, problem solvedCaligari87 wrote:Sprites roll around their offset origin. You need to center the offset.

Code: Select all
ACTOR ManEaterLeg1: Gibs
{
-FLOORCLIP
+ROLLSPRITE
+ROLLCENTER
-CLIENTSIDEONLY
+SKYEXPLODE
States
{
Spawn:
TNT1 A 0 A_SpawnItem("Blood",0,0,0,1)
MEGL A 3 A_SetRoll(45, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(90, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(135, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(180, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(225, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(270, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(315, SPF_INTERPOLATE)
MEGL A 3 A_SetRoll(360, SPF_INTERPOLATE)
Loop
Death:
MEGL B -1 A_SetRoll(225, SPF_INTERPOLATE)
Stop
}
}
Is there any reason for this happening? I've tried Setflag False and that didn't seem to work either. (6 gibs are spawned and all seem to die on a different angle)