Sprite Angles

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
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?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!
Post Reply
Dudweiser
Posts: 60
Joined: Mon Jan 08, 2018 5:54 pm

Sprite Angles

Post 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
User avatar
Caligari87
Admin
Posts: 6234
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Sprite Angles

Post 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-)
Dudweiser
Posts: 60
Joined: Mon Jan 08, 2018 5:54 pm

Re: Sprite Angles

Post 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?
User avatar
Nash
 
 
Posts: 17501
Joined: Mon Oct 27, 2003 12:07 am
Location: Kuala Lumpur, Malaysia
Contact:

Re: Sprite Angles

Post by Nash »

Actors need a +ROLLSPRITE flag, otherwise any rolling functions will have no visual effect.
User avatar
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

Post 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).
Dudweiser
Posts: 60
Joined: Mon Jan 08, 2018 5:54 pm

Re: Sprite Angles

Post 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)
User avatar
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

Post 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
Dudweiser
Posts: 60
Joined: Mon Jan 08, 2018 5:54 pm

Re: Sprite Angles

Post 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?
User avatar
Caligari87
Admin
Posts: 6234
Joined: Thu Feb 26, 2004 3:02 pm
Preferred Pronouns: He/Him
Contact:

Re: Sprite Angles

Post by Caligari87 »

Sprites roll around their offset origin. You need to center the offset.

8-)
Dudweiser
Posts: 60
Joined: Mon Jan 08, 2018 5:54 pm

Re: Sprite Angles

Post 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)
Post Reply

Return to “Resources”