This is probably one of the more controversial posts in game development communities because of the common nature of the person asking. Let me preface this by saying I'm not going to reskin a racing game and sell it on Steam.
Basically, I'm just looking for a simple Irrlicht project that handles everything as efficiently as possible and demonstrates the basic Irrlicht features. (I don't really like the official demo because the code's too messy; everything seems to be handled in main() )
Thank you for reading.
What are some good open-source Irrlicht games to learn from?
-
- Posts: 18
- Joined: Thu Apr 24, 2014 3:01 am
Re: What are some good open-source Irrlicht games to learn f
Supertuxkart 0.8 is one, but don't look at the later ones, as they've moved to manual GL in places, making it a lot more messy
Re: What are some good open-source Irrlicht games to learn f
Hi FlyingSauce,
I understand why they put everything in main in the tutorials to keep it simple, but there should be a couple of tutorials where mesh loading and nodes are created in separate classes in separate files.
That is what I am trying to learn how to do now. I have managed to do the evenlistener into it's own separate file, and now I working on the others. Well as soon as I have built my 3D scene I am working on heh heh.
I understand why they put everything in main in the tutorials to keep it simple, but there should be a couple of tutorials where mesh loading and nodes are created in separate classes in separate files.
That is what I am trying to learn how to do now. I have managed to do the evenlistener into it's own separate file, and now I working on the others. Well as soon as I have built my 3D scene I am working on heh heh.
Re: What are some good open-source Irrlicht games to learn f
if you have characters in your game, and a player. Hence lets trow in some animals to just wandering around.
Then you can have something like:
Pretty recognizable I guess.
Actually it doesn't matter how you do it as long as you understand what is done where. In my practise I have set up a basic framework in a static lib for tests and starting point for a new project. Then descent from Level to TestLevel which contains a function that is called from the mainloop. The descended class I set as a pointer in the 'mainloop'-class.
This is my base class, a pretty simple thing:
Also to note: Within that IrrlichtClass, is the mainloop called run()
The level gets called withing the .run(), giving you the abillity to create a progress bar or other nice scenery while initializing.
hope this helps
Then you can have something like:
Code: Select all
class Actor{}; // maybe descending from ISceneNode
class Character : public Actor{};
class Player : public Character{};
class Animal : public Actor{};
class Bird: public Animal{};
class Cow: public Animal{};
Code: Select all
class Level
{
// base class
}
class GameLevel : public Level
{
private:
int initCharacters();
int initCharacters( file );
int initAnimals();
public:
int initialize(){ initCharacters(); initAnimals(); }
int load( file ){ /* or get it out of a file */ initCharacters( "cruelties.txt" ); }
}
Code: Select all
// cruelties.txt
[char]
mesh:char1.ms3d
tex:ohlala.png
pos:0,0,0
[char]
idem
// animalfile.txt
etc
Code: Select all
int main()
{
IrrlichtClass engine;
TestLevel level;
engine.setLevel( level );
if( !engine.run() )
return 1;
return 0;
}
Code: Select all
class Level
: public IEventReceiver
{
friend class cScript;
private:
video::SColor m_backgroundColour = video::SColor( 255, 4, 6, 12 );
public:
virtual bool create();
virtual void destroy();
virtual bool load();
virtual bool save();
virtual void update( const f32& deltaTime );
video::SColor getBackgroundColour();
void setBackgroundColour( video::SColor color );
/// I E v e n t R e c e i v e r
/// --------------------------------------------------------------------------------
virtual bool OnEvent( const SEvent& event );
};
Code: Select all
bool IrrlichtClass::run()
{
if( !m_level ) return false;
m_level->initialize();
while( m_device->run() )
{
...
level->update( deltatime );
...
}
}
Code: Select all
void GameLevel::keepItReadableCleanAndNotRepetitive()
{
m_videodriver ->beginScene( true, true, m_backgroundColour );
m_sceneManager ->drawAll();
m_videodriver ->endScene();
}
int GameLevel::initialize()
{
core::array<core::stringc> files;
files.push_back( "player.txt" );
files.push_back( "npc.txt" );
files.push_back( "animal.txt" );
m_progressBarThingy = m_sceneManager->addProgressBarThingy( or something );
m_progressBarThingy->max = 3;
for(u32 i = 0; i < files.size();++i)
{
createCharacter( files[i] );
m_progressBarThingy.value++;
keepItReadableCleanAndNotRepetitive();
}
core::array<core::stringc> buildings;
buildings.push_back( "house.ms3d" );
buildings.push_back( "house.png" );
buildings.push_back( "woodcutter.ms3d" );
buildings.push_back( "woodcutter.png" );
for(u32 i = 0; i < buildings.size(); i += 2)
{
scene::ISceneNode* node;
scene::SMesh* mesh;
mesh = m_sceneManager->getMesh( buildings[i] );
node = m_sceneManager->addMeshSceneNode( mesh );
node->setMaterialType(0, buildings[i+1]);
keepItReadableCleanAndNotRepetitive();
}
initAnimals();
// done so we return to start the actual loop
// don't forget to clean up m_progressBarThingy and other thing you've created here or they keep sticking around
}
int GameLevel::initAnimals()
{
// when loaded, draw them onto the screen and load the next
m_sceneManager->addMeshSceneNode( m_sceneManager->getMesh( "cow.ms3d" ) );
keepItReadableCleanAndNotRepetitive();
m_sceneManager->addMeshSceneNode( m_sceneManager->getMesh( "dear.ms3d" ) );
keepItReadableCleanAndNotRepetitive();
}