2D game with sprites?
-
- Posts: 105
- Joined: Mon Jun 02, 2014 2:32 am
- Location: Washington, D.C.
- Contact:
2D game with sprites?
Howdy!
Been a while since I've posted, but I'm looking into building a game and want to use Irrlicht for a 2D/3D hybrid level design I have in mind. I've looked over the tutorials on the website, but I feel the 2D tutorial is a little terse. I wanted to know if there were some threads here I could look at, or if the greater Irrlicht community could provide some insight, on working with sprites/spritesheets and creating a scene that contains both 2D and 3D elements?
Thank you for your help!
Been a while since I've posted, but I'm looking into building a game and want to use Irrlicht for a 2D/3D hybrid level design I have in mind. I've looked over the tutorials on the website, but I feel the 2D tutorial is a little terse. I wanted to know if there were some threads here I could look at, or if the greater Irrlicht community could provide some insight, on working with sprites/spritesheets and creating a scene that contains both 2D and 3D elements?
Thank you for your help!
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Re: 2D game with sprites?
I had some success implementing an orthographic camera aligned with the IV quadrant at the top-left corner of the screen. There's a few pitfalls, but I managed to create a whole lot of lot of classes derived from the irrlicht classes to work with 2D elements.
Of course, given the orthographic nature of the camera, 3D objects all seems flat as they don't have any perspective. I didn't have any problem with that, as I wasn't going to have 3D-looking objects in my scenes (I developped those classes to ease the transition between a 2D only engine to Irrlicht, as most developers here only have experience in 2D).
I tried to get my boss to release what I did under an open source licence. He can definitely see the benefits, but so far, I wasn't instructed to do so.
What kind of look are you looking to get? A 2D look with 3D flat-looking effects? Or more like a 3D look with a few 2D elements?
Of course, given the orthographic nature of the camera, 3D objects all seems flat as they don't have any perspective. I didn't have any problem with that, as I wasn't going to have 3D-looking objects in my scenes (I developped those classes to ease the transition between a 2D only engine to Irrlicht, as most developers here only have experience in 2D).
I tried to get my boss to release what I did under an open source licence. He can definitely see the benefits, but so far, I wasn't instructed to do so.
What kind of look are you looking to get? A 2D look with 3D flat-looking effects? Or more like a 3D look with a few 2D elements?
-
- Posts: 105
- Joined: Mon Jun 02, 2014 2:32 am
- Location: Washington, D.C.
- Contact:
Re: 2D game with sprites?
@MartinVee
I was trying to have 2D sprites running across 3D platforms with a camera aligned to the X and Y axis only. I'm wondering if I need to map the sprites as textures onto planes for this to work best?
Again, I'm looking for something that can point me in the right direction.
Thanks!
I was trying to have 2D sprites running across 3D platforms with a camera aligned to the X and Y axis only. I'm wondering if I need to map the sprites as textures onto planes for this to work best?
Again, I'm looking for something that can point me in the right direction.
Thanks!
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Re: 2D game with sprites?
maybe try implementing a top down orthogonal camera with your 2D sprites since this shows depth for your 3D models while maintaining or aligned to a fixed X and Y position.
Re: 2D game with sprites?
Most primitive solution - use IVideoDriver::draw2DImage. You could also use IImage from the GUI which kinda wraps this.
There is IGUISpriteBank which has some support for putting a bunch of sprites together into one spritebank (as seperate textures or as rectangles one one big texture) and has some support to play them as animation.
Those all work - but disadvantage is that you have no support for rotation. And can't do any kind of 3d effects.
To get that you have to map them on planes. And be aware of troubles with z-fighting when you do _not_ use a orthocam (see http://irrlicht.sourceforge.net/forum/v ... =1&t=51598 - and yes, it's still something I want to change, but right now not working on that problem as I'm deep in shader stuff last weeks).
So kinda depends on what exactly you will need.
There is IGUISpriteBank which has some support for putting a bunch of sprites together into one spritebank (as seperate textures or as rectangles one one big texture) and has some support to play them as animation.
Those all work - but disadvantage is that you have no support for rotation. And can't do any kind of 3d effects.
To get that you have to map them on planes. And be aware of troubles with z-fighting when you do _not_ use a orthocam (see http://irrlicht.sourceforge.net/forum/v ... =1&t=51598 - and yes, it's still something I want to change, but right now not working on that problem as I'm deep in shader stuff last weeks).
So kinda depends on what exactly you will need.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
Re: 2D game with sprites?
My suggestion would be to use polygons and map into them the sprites, then, just rotate, scale and translate the polygon always aligned to the camera, is not hard, and the engine makes the draw calls for you, besides, as you'd be using a 3D background, the integration is easier. Pro-tip, it is posible to enable/disable filtering besides other nice effects the simple 2D drawing doesn't provide on its own. (additive blending, alpha blending, vertex coloring, shaders...)
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Posts: 105
- Joined: Mon Jun 02, 2014 2:32 am
- Location: Washington, D.C.
- Contact:
Re: 2D game with sprites?
@Mel @CuteAlien
Wow! Thanks for the input!
Mel, based on your suggestion, does that mean I'm going to be using the "IMesh" classes to create a custom polygon? I'd appreciate a little more detail there, if you don't mind.
Thank you!
Wow! Thanks for the input!
Mel, based on your suggestion, does that mean I'm going to be using the "IMesh" classes to create a custom polygon? I'd appreciate a little more detail there, if you don't mind.
Thank you!
My blog: http://fsgdp.wordpress.com "The Free Software Game Development Pipeline"
Re: 2D game with sprites?
Thats exactly what I would recommend in lieu of the billboard class.
Look at tutorial #3 or #4
Look at tutorial #3 or #4
Re: 2D game with sprites?
You could do that indeed, Irrlicht still supports as well the direct rendering of vertex/index lists, so everything can be even more flexible in that matter, but for the sake of future compatibility is better to use meshes, yes.
Meshes are simply a vertex list and an index list. Irrlichts renders lists of triangles, so you have to arrange your vertices and indices in a fashion that create quads. Examples 3 and 4, put you in motion, as has been already suggested.
Meshes are simply a vertex list and an index list. Irrlichts renders lists of triangles, so you have to arrange your vertices and indices in a fashion that create quads. Examples 3 and 4, put you in motion, as has been already suggested.
"There is nothing truly useless, it always serves as a bad example". Arthur A. Schmitt
-
- Competition winner
- Posts: 688
- Joined: Mon Sep 10, 2012 8:51 am
Re: 2D game with sprites?
FYI: You don't actually need to implement IMesh. You need to implement ISceneNode and use the methods IVideoDriver::setMaterial() and IVideoDriver::drawVertexPrimitiveList() to render it.
Personally, I don't like rendering using the 3D mechanisms because it always looks blurry, even without mipmaps. The reason for this is that you need to get the distance perfect to that the image pixels scale 1-to-1 with your screen, which is tricky. Rendering with orthographic view helps, but taste is taste I guess.
Personally, I don't like rendering using the 3D mechanisms because it always looks blurry, even without mipmaps. The reason for this is that you need to get the distance perfect to that the image pixels scale 1-to-1 with your screen, which is tricky. Rendering with orthographic view helps, but taste is taste I guess.