PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

EasyCE extras??

Birdiestyle · 04 Feb 2002, 22:42 UTC
Hey,
Just started messing around with Easy CE 2.0, and was hoping to do a couple things. Dont know if Im missing the boat on things, and they're possible or if someone could help out with them, but....

1. I would like to have all the frames of my animation to be located in one image(TGA) file. And just have the sprite know the location and size of the image inside the surface(file).

2. I would like to compile the TGA files directly into the executable.

3. I would like to have the option of not using TGA files(JPG,PNG...)?? 8)

Anybody have any code sitting around for this stuff, but still using EasyCE, or suggestions...

Awesome library Jacco!!

Birdie
You can store multiple images in a single tga file. Use the sprite constructor to build a bunch of sprites and add them to the animation. If you have a 100x25 bitmap containing 4 25x25 sprites, you can construct them like this:

Code:

PIXEL* buffer = new PIXEL[100*25];
ASprite spr1( buffer, 25, 25, 100 );
ASprite spr2( buffer + 25, 25, 25, 100 );
...
AAnim animation( 4 );
anim.addframe( &spr1; );
anim.addframe( &spr2; );
...


That should do the trick. Note that the sprites that you store in an animation don't need to be equally sized; they don't even have to be stored in the same tga. But that doesn't make things more clear of course. :)

- Jacco.
Birdiestyle · 05 Feb 2002, 15:26 UTC
Cool,
What would the same code look like in 2.0 with the surfaces??

Birdie
Something like this:

Code:

ASurface buffer(100,25);
ASprite spr1( buffer, 25, 25 );
ASprite spr2( buffer, 25, 25 );
etc.


You don't have to specify the pitch anymore, since that is retrieved from the tga.

You could also use the first line to read the tga:

Code:

ASurface buffer("mysprite.tga");


Assuming that this file is a 100x25 tga, this would create the correct surface for you.
Birdiestyle · 05 Feb 2002, 20:45 UTC
Ok, Im an idiot!! Thanks....
Why are you an idiot when I use the old EasyCE 1.x stuff in sample code when I just released EasyCE 2.0? :)
Birdiestyle · 06 Feb 2002, 15:16 UTC
I dunno, it just seemed a little obvious once I saw it.

Hey, here are some little functions that I have added, that might be handy to include all the time.


Code:

void AAnim::InitFrames( int a_Frames )
{
//Used with default constructor

//Dont want to delete existing frames.. Set it right the first time!!
if(m_Frames == 0)
{
m_Sprite = new ASprite*[a_Frames];
for ( int i = 0; i < a_Frames; i++ ) m_Sprite[i] = 0;
}
}


Which I had to use when making an animation a member variable in a class.

and

Code:

ASprite* getcurrentsprite() { return m_Sprite[m_Frame]; }

To get the current sprite of an animation.

Course, now Im back to 1.6 so....

Thanks again,

Birdie