Author Topic: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!  (Read 1582 times)  Share 

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
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.
« Last Edit: 09 Dec 2011, 00:47 by Khris »
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"

Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #1 on: 29 Nov 2011, 23:08 »
The link is dead  :( Do you (or someone else) still have this module?
We all have our time machines, don't we?

Dualnames

  • Local Moderator
  • Dualnames worked on a game that was nominated for an AGS Award!
Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #2 on: 30 Nov 2011, 11:14 »
When all else fails, Dualnames is the best.

http://www.mediafire.com/?ad86unpfqw0j66k

Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #3 on: 30 Nov 2011, 17:10 »
Thanks!
We all have our time machines, don't we?

monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #4 on: 30 Nov 2011, 18:04 »
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.
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

Snarky

  • Global Moderator
  • Mittens Baronet
  • Private Insultant
    • I can help with proof reading
    •  
    • I can help with translating
    •  
Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #5 on: 01 Dec 2011, 11:09 »
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).

Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #6 on: 01 Dec 2011, 12:08 »
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.bigbluecup.com/yabb/index.php?topic=33115.0
We all have our time machines, don't we?

monkey_05_06

  • AGS Project Admins
  • Has left the building.
Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #7 on: 02 Dec 2011, 01:54 »
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.
Let's be honest. Most people suck at coding. I suck at coding, but at least my code is readable. To Hell with anyone too lazy to maintain consistent formatting in their code. I could deal with bad interfaces and structure if I could even read your horrible code. And that's putting it nicely. -monkey

Khris

  • Evil Dark Emperor Death-Kill
    • Lifetime Achievement Award Winner
    •  
    • I can help with play testing
    •  
    • I can help with scripting
    •  
    • I can help with translating
    •  
Re: MODULE: DynamicSprite Rotation v0.1 - AGS 3.0 only!
« Reply #8 on: 09 Dec 2011, 00:44 »
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.
http://whathaveyoutried.com/

The other day on yahoo answers:
"Can you print colored images with black ink? If so tell me how please Thanx Kimberly"