How to return the sprite slot of a frame? (IMPLEMENTED)

Started by strazer, Wed 28/04/2004 11:01:54

Previous topic - Next topic

strazer

Is it possible to return the sprite slot of a frame in a view?

I've emulated the functionality of the rain plugin, but in order to draw the raindrops in front of the player character I have to hide him (with SetCharacterTransparency(EGO, 100) to retain interactions) and rawdraw his frames onto the background before drawing the rain over him:

// curslot = a whole lot of else-ifs here :(
RawDrawImage(player.x-(GetGameParameter(GP_SPRITEWIDTH, curslot, 0, 0)/2), player.y-GetGameParameter(GP_SPRITEHEIGHT, curslot, 0, 0), curslot);
// draw rain here

It would be a lot easier if I could just do

curslot = GetSpriteSlot(player.view, player.loop, player.frame);

Maybe if GetSpriteSlot returned a negative value for flipped frames, RawDrawImage could draw them flipped as well?
(Edit: AGS v2.71 RC 1: Added GP_ISFRAMEFLIPPED option to GetGameParameter.)

If not a seperate function, how about an addition the GetGameParameter function (GP_SPRITESLOT - Returns sprite slot number of frame DATA3 in loop DATA2 of view DATA1)?
(Edit: AGS v2.61 RC 1: Added GP_FRAMEIMAGE option to GetGameParameter.)

Gilbert

I think it's not possible at the moment (unless I missed something), a workaround is that you plan carefully on the sprite numbers of the characters before assigning them to a view (it's a bit complicated, but you can right-click a sprite and change its slot).

For example:
"Down" view of the character uses slots:
1001,1002,...,1010
"Left" view of character uses slots:
1101,1102,...,1110

blah bla bla

Then you can check the frame and loop of the character to calculate the sprite number:

slot=1000+(player.loop*100)+player.frame;

It may be a bit complicated, but as you're doing some complicated things already, I think it's acceptable.


On the other hand, however, I think it's still worth having the function you mentioned implemented, as it can be handy. (CJ: read ;) )



strazer

Quoteyou can right-click a sprite and change its slot

Cool, I didn't know that.
That will have to do for now, thank you!

Gilbert

Well, it's not explicitly documented to prevent users from messing up their games (like a game crashes because they changed teh sprite slot of a sprite originally assigned to a view, this is similar to deleting a sprite without ever thinking, ironically, this feature is added mainly to compensate for the fatal crashes caused by deleting sprites).

So, shhhh, don't spread out the words and recommend other to use this feature (unless they really know what they're doing). ;)

Pumaman

A new option to GetGameParameter sounds like the best plan here, I'll add it to my list.

SMF spam blocked by CleanTalk