Page 1 of 1

Sprite Angles

Posted: Tue Feb 08, 2022 1:10 pm
by Dudweiser
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

Re: Sprite Angles

Posted: Tue Feb 08, 2022 1:58 pm
by Caligari87
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.

8-)

Re: Sprite Angles

Posted: Tue Feb 08, 2022 2:12 pm
by Dudweiser
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.

Code: Select all

ACTOR OrbHalf1: Gibs
{
  
    States
    {
	Spawn:
        
		ORBG ABCDEFGH 5
		Loop

   	Death:
        
	    ORBG A 1
       ORBG A -1

        Stop
	}
}
So how would I translate this using your method?

Re: Sprite Angles

Posted: Tue Feb 08, 2022 2:17 pm
by Nash
Actors need a +ROLLSPRITE flag, otherwise any rolling functions will have no visual effect.

Re: Sprite Angles

Posted: Thu Feb 10, 2022 5:24 pm
by Pandut
+ROLLSPRITE is a godsend. It's fantastic to use for gore/items being thrown around and also particle effects.

Code: Select all

A_SetRoll(roll+random(0,359), SPF_INTERPOLATE)
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).

Re: Sprite Angles

Posted: Sat Feb 12, 2022 7:21 pm
by Dudweiser
Pandut wrote:+ROLLSPRITE is a godsend. It's fantastic to use for gore/items being thrown around and also particle effects.

Code: Select all

A_SetRoll(roll+random(0,359), SPF_INTERPOLATE)
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).

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)

Re: Sprite Angles

Posted: Fri Feb 18, 2022 5:09 pm
by Pandut
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 -

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
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

Re: Sprite Angles

Posted: Tue Mar 01, 2022 5:30 pm
by Dudweiser
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?

Re: Sprite Angles

Posted: Tue Mar 01, 2022 11:14 pm
by Caligari87
Sprites roll around their offset origin. You need to center the offset.

8-)

Re: Sprite Angles

Posted: Wed Mar 02, 2022 4:09 pm
by Dudweiser
Caligari87 wrote:Sprites roll around their offset origin. You need to center the offset.

8-)
Thanks you kind sir, problem solved :), however I ran into another problem:

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
	}
}
I need this sprite to rotate when it dies, as the default sprite looks dumb on the ground. The problem I am having is the gibs all have different angles on the ground, some work, some are the complete wrong direction. The sprite on the ground is a multiple of 45 so i can't just create a new one easily.

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)