MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!

Started by Khris, Wed 05/12/2007 18:55:25

Previous topic - Next topic

Khris

Dynamic Sprite Rotation Module v0.1 by KhrisMUC

Tested with and coded for AGS3.0 RC1 - Can be used freely. No credit required.

DOWNLOAD
(includes the following documentation and example room script)


- DynamicSprite* DynS.CreateFromExistingSprite(int slot, optional bool preserveAlphaChannel)

Replacement for the built-in function, used to create a new dynamic sprite.
Returns the created dynamic sprite just like the standard function.
*Must* be used to create the sprite in order to rotate it using the new function.
To use e.g. DynamicSprite.CreateFromBackground() instead of an available slot, call DynS.CreateFromExistingSprite() afterwards using the first sprite's graphic as slot parameter.
Note that in this case the first sprite has to be kept in memory! You have to rotate a second sprite!



- DynamicSprite* DynS.Rotate(DynamicSprite*dys, int offset)

Returns the rotated dynamic sprite. dys is the current sprite, offset the angle to rotate it by.
Note that you must set the original sprite!
Example:
 my_sprite=DynS.Rotate(my_sprite, 10);    // rotates my_sprite by 10 degrees


- int DynamicSprite.XO(), int DynamicSprite.YO()

When drawing the (rotated) sprite, add these to the coordinates to prevent the sprite from moving about.
Example:
 ds.DrawImage(100+my_sprite.XO(), 100+my_sprite.YO(), my_sprite.Graphic);


- int DynamicSprite.XC(), int DynamicSprite.YC()

Same as above but centers the (rotated) sprite at the given coordinates.

Note that XC, YC, XO, YO work for all dynamic sprites, not just rotated ones.

Daniel Eakins

The link is dead  :( Do you (or someone else) still have this module?
We all have our time machines, don't we?

Dualnames

Worked on Strangeland, Primordia, Hob's Barrow, The Cat Lady, Mage's Initiation, Until I Have You, Downfall, Hunie Pop, and every game in the Wadjet Eye Games catalogue (porting)

Daniel Eakins

We all have our time machines, don't we?

monkey0506

If you're using AGS 3.0 there's not really much reason that I'm aware of not to upgrade at least to 3.1.2 if not 3.2.1. The new-style audio does remove the ability to play raw MP3 files from the HDD, so that could be a reason to avoid 3.2.1 (if you really wanted to use that feature), but I'm not aware of any limitations between 3.0 and 3.1.2 that would remove functionality like that.

Snarky

Since the thread is from 2007, I assume we should take "3.0 only" to mean "3.0 and newer."

But AGS has built-in sprite rotation capabilities already, no? What's the benefit of using this plugin? If you could set the rotation as a float I could see the advantage (a 1-degree rotation is often too coarse, I find).

Daniel Eakins

I actually have several test games or abandoned projects that I keep around to do coding experiments on, and some are for AGS 3.0 and one is for AGS 3.2.1 (because of when I started them). There's no real reason I don't just use AGS 3.2.1 only; it's just that I have several experimental scripts and unfinished personal modules scattered among these projects and I haven't merged them all into a single (probably 3.2.1) project yet.

Anyway, I'm under the impression that this script makes multiple rotations less "lossy" on the sprite than rotating an already-rotated sprite the normal way, based on this thread: http://www.adventuregamestudio.co.uk/yabb/index.php?topic=33115.0
We all have our time machines, don't we?

monkey0506

Huh, for some reason I thought I remembered Khris saying that it wasn't necessary as of 3.0.1, but I didn't see anything in the changelog that seemed relevant, unless I just totally overlooked it. Ignore me then if that's not the case.

Khris

To clarify, like Daniel said, this module stores the original sprite and thus rotating a rotated sprite doesn't accumulate messy pixels.
It still uses the built-in DynamicSprite.Rotate but keeps track of the current angle and always rotates the original sprite.

I've updated the download link, thanks Dualnames.

SMF spam blocked by CleanTalk