Page 1 of 1

Rotate an image in a sprite

Posted: Tue Dec 13, 2016 12:23 pm
by sore68
Hi~

I want to create a mode that gives direction.(ore compass)
I'm going to draw an arrow on the gui and the ground.

Do sprite have a command to rotate the image at a free angle? or need to register images in all directions?

Re: Rotate an image in a sprite

Posted: Tue Dec 13, 2016 3:47 pm
by Nexela
Create your sprite sheet filled with all of your arrows. Starting from North to East to West to South (and any in-betweens)

Create a car type entity, assign it to your sprite. When creating the entity/sprite set the .orientation to the direction you want. (depending on the number of frames you might need to adjust/compare to a range)
animation portion
for an example see the nixie_tubes mod

Re: Rotate an image in a sprite

Posted: Thu Dec 15, 2016 4:58 pm
by Yoyobuae
Nexela wrote:Create a car type entity, assign it to your sprite.
I was wondering: Is abusing entity types the only way to display custom arrows/graphics like this? Seems awfully wasteful to create an entity just to display an arrow. :?

Re: Rotate an image in a sprite

Posted: Thu Dec 15, 2016 6:03 pm
by DaveMcW
Yoyobuae wrote:Seems awfully wasteful to create an entity just to display an arrow. :?
It's even more wasteful to support every property on every entity. The mod system encourages you to find an entity similar to what you want and hack it.

Re: Rotate an image in a sprite

Posted: Thu Dec 15, 2016 6:49 pm
by Yoyobuae
DaveMcW wrote:
Yoyobuae wrote:Seems awfully wasteful to create an entity just to display an arrow. :?
It's even more wasteful to support every property on every entity. The mod system encourages you to find an entity similar to what you want and hack it.
Problem is that there's so many things tied to entity type. Only way to mix-and-match features from various entity types is to spawn multiple hidden entities. And then the mod needs to manage the lifetimes of those entities. Feels like really weird and hacky way of doing things. I would prefer to have some flags to tell the entity what sort of properties to implement.

Anyway, I was just wondering if there was a better alternative. If there's not then I'll keep using what works.

Re: Rotate an image in a sprite

Posted: Thu Dec 15, 2016 8:55 pm
by daniel34
Yoyobuae wrote:Problem is that there's so many things tied to entity type. Only way to mix-and-match features from various entity types is to spawn multiple hidden entities. And then the mod needs to manage the lifetimes of those entities. Feels like really weird and hacky way of doing things. I would prefer to have some flags to tell the entity what sort of properties to implement.
[1] More flexible API / using flags
Rseding91 wrote:
Factoruser wrote:the entity concept should be changed to a flag-based system - and all entity-types should have prototypes.

I.e. you should be able to easily add e.g. electricity consumption to any new or existing entity without writing an OnTick() subroutine. Flags are something like: consumesElectricity, hasInputInventory, hasFuelInventory, hasStorageInventory, wireConnectable etc. The entity-type prototypes are pre-setting them, and can be overwritten by derived entity prototypes.
You've never written any large piece of performance intensive software have you? There have been multiple suggestions to do this and my response is the same to every one of them:

Until I see *anyone* else implement such a system at the scale that Factorio runs and be successful doing so it's just not even something worth thinking about.
[2] Entity Prototype Composition
Rseding91 wrote:Yeah that's not happening :)

It would require a complete re-write of the game from the ground up to *maybe* work and I have extreme doubts it could be done without a huge impact on performance and the number of bugs introduced/difficulty of debugging a given issue.

Re: Rotate an image in a sprite

Posted: Thu Dec 15, 2016 9:37 pm
by Yoyobuae
Yeah, I imagined there was some kind of reason for it. So I guess using multiple entities will remain the way to go then.

I only hope they keep adding more entity types which are useful for modding, like the electric-energy-interface one.

Re: Rotate an image in a sprite

Posted: Fri Dec 16, 2016 2:17 am
by Mooncat
TBH the first quote made me feel that Rseding doesn't want to be the first one to invent a great system. It is like "I will consider replicating the system if one exists". It doesn't sound right.
But I respect what he has done and I understand he is busy.
Yoyobuae wrote:I only hope they keep adding more entity types which are useful for modding, like the electric-energy-interface one.
Please add an entry in the Modding Interface Requests forum if you have a good idea. ;)

Re: Rotate an image in a sprite

Posted: Mon Dec 19, 2016 9:32 am
by sore68
Oh! Thank you for posts :D

I decided to make eight arrows.
I did not understand the diagonal and curves of the rails...(+Curved rails make eight in two sets.)