this is my own implementation of a 2d sprite batch. ie draws a whole batch of sprites in one go. quite need for mobile games.
each sprite can do the basic transforms. rotate, scale, color with alpha
it works with IVideoDrivers implementing draw2DVertexPrimitiveList
590 tris @ 40 fps on the android nexus
1144 tris @ 35 fps on the android ( i did the draw cycle 2x )
i used these classes in my first irrlicht game for android. munchy solitaire (munchyapps.com)
i'm sharing back some of my code to this community
included are:
> the sprite manager class
> and some systems using the sprite manager
- bitmap font class (uses BmFont from angelcode)
- 2d particle system (ported from love2d.org)
with these classes the game is even a bit playable in the emulator
i hope someone finds them useful. comments and tips like optimization would be appreciated
http://www.munchyapps.com/spriteManager.tar.gz
2d sprite batch
looks nice, but I have no clue how to use this classes !!!
it's always a good idea to include a small demo that shows how to use it !!!
especially if the code isn't documented (or at least very spartanic documented)...
also, BmFont.cpp claims that "Util.h" can't be found !!!
are there any dependencies beside Irrlicht ???
it's always a good idea to include a small demo that shows how to use it !!!
especially if the code isn't documented (or at least very spartanic documented)...
also, BmFont.cpp claims that "Util.h" can't be found !!!
are there any dependencies beside Irrlicht ???
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
its not ment to be complete. its just a rough framework by the looks of it. sorta something to learn from and improve upon.
Live long and phosphor!
-- https://github.com/netpipe/Luna Game Engine Status 95%
-- https://github.com/netpipe/Luna Game Engine Status 95%
yup, it's not meant to be complete. but it can be plugged in easily.
here's the code with a demo program.
>> i added the path finder class --- no demo for that here though
http://www.munchyapps.com/spriteManager.tar.gz
here's the code with a demo program.
>> i added the path finder class --- no demo for that here though
http://www.munchyapps.com/spriteManager.tar.gz
Code: Select all
driver->beginScene(true, true, video::SColor(0,0,0,0));
sprites->clear();
// add sprite from tile (0,0) size(8,8)
Sprite *spr = sprites->addSprite(0,0,8,8);
spr->setPosition(20, 20);
spr->setScale(4.0f, 4.0f);
// add more sprites ...
// fonts
fonts->drawText("the quick brown fox\njumped over\n the lazy dog", 0, 0, w, h, BmFont::ALIGN_CENTER | BmFont::ALIGN_MIDDLE);
fonts->drawText("the quick brown fox\njumped over\n the lazy dog", 0, 0, w, h, BmFont::ALIGN_RIGHT | BmFont::ALIGN_TOP);
fonts->drawText("the quick brown fox\njumped over\n the lazy dog", 0, 0, w, h, BmFont::ALIGN_LEFT| BmFont::ALIGN_BOTTOM);
// each character is actually a sprite
// particles
float secs = (float)elapsed / 1000.0f;
ps->update(secs);
ps->draw(0,0,0,0,0,0,0);
if (ps->isEmpty())
ps->start();
// each particle is a sprite as well
// draw all the sprites
sprites->drawAll();
// you can "sprites->clear()" ... and draw another set of sprites
driver->endScene();
-
- Posts: 758
- Joined: Mon Mar 31, 2008 3:32 pm
- Location: Bulgaria
I thought so...m4rvin wrote:yup, it's not meant to be complete. but it can be plugged in easily.
great, thanks !!!m4rvin wrote:here's the code with a demo program.
it's always boring when you get a bunch of code without any information on how to use it !!!
so a small demo that shows (at least) the basics is always a goot idea sp one get interested to try it to use !!!
and it's easier to get deeper into the stuff as you have a starting point !!!
well, good work !!!
I like the particle effect (maybe bc it's the only animated thing in the demo ) !!!
if you don't mind, I'll see if I can add it to my IrrExtensions (when I have a bit of sparetime) !!!
while(!asleep) sheep++;
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
IrrExtensions:
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java