Adventure Game Studio

AGS Support => Modules, Plugins & Tools => Topic started by: SSH on Fri 06/03/2009 12:01:42

Title: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: SSH on Fri 06/03/2009 12:01:42
Following on from the discussion in this thread (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=37075) I've created a module that you can use to scale all the sprites for a character, or to apply various other "distortions" to the sprites instead.

Needs: AGS 3.1.2 (but might work with earlier ones from 3.0 on, try it and see!)

Documentation (http://ssh.me.uk/moddoc/DistortChar)
Download (http://ssh.me.uk/modules/DistortChar.zip)
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: Joe on Fri 06/03/2009 12:21:47
Thanks module man!!!  ;)
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: GarageGothic on Fri 06/03/2009 12:33:05
Interesting approach to store and re-use the DynamicSprites once rendered. I employ a lot of similar effects in my scripts but always generate them on a loop by loop basis, which of course impairs the framerate if overused (though often necessary for dynamic shadows and lightmap tinting). Have you run any tests on how the module affects memory overhead and savegame size?
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: SSH on Fri 06/03/2009 12:41:40
Nope!

It's a shame that you can't generate dynamic arrays of Dynamic Sprite pointers, as that's what I'd prefer (or what might be best was if all sprite numbers inside AGS were actually pointers so you could set the pointer to the dynamic sprite so that it would still have a global reference and not need to worry about it getting garbage-collected.)
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: monkey0506 on Sat 07/03/2009 09:20:11
Quote from: SSH on Fri 06/03/2009 12:41:40It's a shame that you can't generate dynamic arrays of Dynamic Sprite pointers, as that's what I'd prefer

Yes you can. In fact if it makes you more comfortable you can even write your own alloc/free functions:

DynamicSprite *Sprites[];
int SpriteCount = 0;

void spr_free() {
  SpriteCount = 0;
  Sprites = null;
}

void spr_alloc(int count) {
  if ((count <= 0) || (count > 1000000)) {
    spr_free();
    return;
  }
  SpriteCount = count;
  Sprites = new DynamicSprite[count];
}


Just tested that and it runs perfectly.
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: SSH on Sat 07/03/2009 09:31:51
Oh! The manual says that you can't make dynamic arrays of managed types...
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: monkey0506 on Sat 07/03/2009 10:02:31
That's rather silly considering it's only the basic data and the managed types you can make dynamic arrays of...hmmm...

Contents>Scripting>Dynamic Arrays
QuoteAlso, at present you can create arrays of basic types (int, char, etc) and of built-in types (String, Character, etc) but not of custom structs.

Where does it say you can't use managed types?
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: SSH on Sat 07/03/2009 12:55:57
Hmmm, my brain must not have been working when I read it.  :=
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: Joe on Sat 07/03/2009 13:01:31
Does that mean you can create objects dynamicly???
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: SSH on Sat 07/03/2009 16:55:20
No, but you can create pointers to objects dynamically.
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: Joe on Sun 08/03/2009 13:14:58
Really don't know what can I do with a pointer, either what pointer means...

I've heard that word many times when I received programming lessons, but never understood it, so what's it?
Title: Re: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character
Post by: monkey0506 on Sun 08/03/2009 16:36:18
Well Joe, this (http://www.americangirlscouts.org/agswiki/AGS_Pointers_for_Dummies) is the best way I have of explaining that.

And SSH, I just wanted to let you know how stoked I am to hear that I'm not the only one who goes into cerebral arrest writing these modules sometimes...