Jibble

There is a new version of the forums ready for testing. Please post here if you're willing to help test! We could also use the help of coders!

Author Topic: MODULE: DistortChar v1.0: Scale/other distortions on all frames of a character  (Read 3521 times)

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Following on from the discussion in this thread 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
Download

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
Thanks module man!!!  ;)
Copinstar © Oficial Site

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?

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
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.)

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    • monkey0506 worked on one or more games that won an AGS Award!
    •  
    • monkey0506 worked on one or more games that was nominated for an AGS Award!
It'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:

Code: [Select]
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.

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Oh! The manual says that you can't make dynamic arrays of managed types...

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    • monkey0506 worked on one or more games that won an AGS Award!
    •  
    • monkey0506 worked on one or more games that was nominated for an AGS Award!
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
Quote
Also, 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?

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
Hmmm, my brain must not have been working when I read it.  :=

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
Does that mean you can create objects dynamicly???
Copinstar © Oficial Site

SSH

  • Flying round the world at the speed of haggis
    • I can help with scripting
    • SSH worked on one or more games that won an AGS Award!
    •  
    • SSH worked on one or more games that was nominated for an AGS Award!
No, but you can create pointers to objects dynamically.

Joe

  • Anywhere you think I am, I am
    • I can help with scripting
    • I can help with translating
    • I can help with web design
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?
Copinstar © Oficial Site

monkey0506

  • SEND PIZZA.
    • Best Innovation Award Winner 2017, for his work to help AGS games reach the widest possible audience - through popular distribution platforms (Steam, Galaxy) as well as other operating systems (Android, Linux)
    • monkey0506 worked on one or more games that won an AGS Award!
    •  
    • monkey0506 worked on one or more games that was nominated for an AGS Award!
Well Joe, this 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...