Click here to Skip to main content
Click here to Skip to main content

Iron Cube game

By , 2 Dec 2012
 

Please note

This article is an entry in our AppInnovation Contest. Articles in this sub-section are not required to be full articles so care should be taken when voting.

Introduction 

Iron Cube - drive a tank in completely destroyable world! Upgrade your tank, build manually bridges across rivers and obstacles, dig tunnels under enemy vehicles to blow it! 

The game is written in C++ and use in-house game engine Glow3d (http://www.moddb.com/engines/glow and http://glow3d.com/blog/ ).  

Background  

My name is Yakov Sumygin and last several year I spend my free time on developing game engine Glow3D. It's written in C+, cross platform and supports both DirectX and OpenGL (plus OpenGL ES).  Also it uses "Bullet" physics, OpenAL for 3D sound and Recast dynamic navigation meshes for AI.

I decided that  the best way to develop engine is make interesting game on it.  I was amazed by voxel-based games as Minecraft and Infiniminer, amazed particularly by ability to change a game world completely. So I decided  to play with such kind of world generation and with one more my obsession - tanks! 

Key features

  • Destroyable world:
  • Check video:
  • Video: http://www.youtube.com/watch?v=-SZ4KmlC43g&feature=youtu.be 

  • Advanced 3D graphics -  Glow3D engine support Deferred  Shading as lighting technology, so it can draw scenes with relatively large count of dynamic lights and smooth shadows.  Dynamic Day-Night loop, believable  water with reflection and refraction. And fishes!
  •  

  • Video with water and fishes http://www.youtube.com/watch?feature=player_embedded&v=Ubo-iHVTrX8 
  • Game uses "Bullet" physics for believable physics simulation, so large explosions are possible in the game.  Next video just shows big volume extraction, explosion effects will be added later. Video: http://www.youtube.com/watch?v=hwmJXeCAp_4&feature=relmfu
  • Currently only one model of tank is available
  • Ability to build bridges to cross a river or obstacle.   
  • Various tactics are available to destroy enemy forces  - dig tunnel and put explosives directly under bottom of enemy tank, blow big hole to stop enemy vehicle etc
  • Use Ultrabook unique abilities - Touch screen for UI and  Sleep-state aware. Use special power-saving rendering mode when Ultrabook  is not connected to power source.

The code  

Voxel generation 

First version of game uses voxel field generation based on Perlin (Simplex) noise. But I decided to switch it to use prebuilt  heightmaps to have more control. Voxel field is generated in chunks of voxels with size 32x32x32, polygons are generated only on edges of voxels between land and air.  Engine is multicore ready,  so many tasks are executed independently and use all available cores. For example voxel field is built on all available processors same time.  

Code for generating triangle meshes from voxel field (fastly  implemented first thought): 

// check all voxels
for ( size_t y=1;y<m_height-1;++y )
    for ( size_t z=1;z<m_length-1;++z )
        for ( size_t x=1;x<m_width-1;++x )
        {
            voxel_t v = m_buffer[ index(x, y, z) ];
            if ( !e.filter[v] )
                continue; // empty space

            voxel_t neighborhoods[6];
            get_voxel_neighborhoods( x, y, z, v, neighborhoods);

            if ( !e.filter_neighborhood[neighborhoods[SIDE_LEFT]] )
            {
                AddQuad(e,  v, SIDE_LEFT,  
                            
                            int3(x, y, z+1),
                            int3(x, y+1, z+1),
                            int3(x, y+1, z),
                            int3(x, y, z),
                            ambient, global_ambient
                             );
            }
            // do it for every side of voxel ...
        }

It's simple solution, but there is more powerful algorithms for triangle mesh generation   from voxel fields. Check next link http://glow3d.com/blog/2012/08/20/geometry-optimization/.

Enemies 

Enemies are ruled by state machine. I use recast Navigation library and navigation meshes for bot movement.

This is example of AI state for tank movement toward enemy: 

struct tank_move_to_enemy_t: public ai_state_base_t<CTank>
{
tank_move_to_enemy_t(const char* name, int weight, CTank* pThis):
ai_state_base_t(name, weight, pThis), m_enemy(0){}
bool run()
{
// use Recast navigation to calc path to enemy  ... 
m_this->move_toward( m_enemy->position() );
return true;
}
int weight()
{
if ( !ai_state_t::weight() )
return 0;
return m_weight;
}
IEntity* m_enemy;
};

 Every  bot has set of states, every state has weight. During game loop AI simulation, bot calculates current state to execute, for example if bot sees enemy, the move_to_enemy_t state is executed. 

Modification of voxel world 

Voxel chunks are organized  by octree, so when some action with voxel modification happens it allows quickly find affected  chunks and voxels. 

size_t CCubeCluster::process_voxels_in_volume( cluster_entity_info_t& e,  const IVolume& volume,  voxel_t v, glw::u32 update_version)
{
size_t count = 0;
for ( size_t y=0;y<m_height;++y )
for ( size_t z=0;z<m_length;++z )
for ( size_t x=0;x<m_width;++x )
{
voxel_t old_v = m_buffer[ index(x, y, z) ];
if (  old_v == v )
continue;
CBox box; 
voxel_box( int3(x, y, z), box );
if ( volume.collide( box ) )
{
on_voxel_changed( e, int3(x,y,z), v, update_version );
count++;
}
}
return count;
}

IVolume - base class for different types of volumes - sphere, box etc.

The team   

Iakov Sumygin, Dmitry Shipilov 

Screenshots from final version of the game

 

 

 

Video

http://youtu.be/ioBkVfaQF_Q 

What was wrong

  • Certificates from Comodo - I started issuing process 2 weeks before deadline and spent around 2 weeks on communication by e-mail. Finally switched to Symantec at 20 of November, but it was too late. I submitted game after deadline.
  • Wrong prioritization- in so short period of time I should concentrate on simple but interesting gameplay but I wanted to have it all - several modes of game, good and smooth networking (the game is based on my own engine, so I should to write it  by my own hands), nice graphics, proper effects, day-night change etc. At last days I just cut all unnecessary things in gameplay and graphics.
  • Lack of testing - as I finished game one or two days before deadline, I didn't have time to properly test it.

What was good  

  • I finally made a game using my engine! Thanks Intel and Code Project!  
  • I have shinny new ultrabook, which is not on the market yet. It's super powerful and slim and costs me nothing )) ( actually 75 usd for Windows 8 and 100 usd for post but anyway ).
  • Development of this game will be continued and I hope it will raise to something big.
  • Lessons are learned and I know, how to concentrate on proper things to finish something. 
   If you are interested in this project please check my blog glow3d.com/blog  or follow me on twitter.  

 

 

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

yak32
Russian Federation Russian Federation
Member
_________________________________________________________
Iron Cube

Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board.
Search this forum  
    Spacing  Noise  Layout  Per page   
QuestionPlease register PinadminChris Maunder22 Oct '12 - 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Permalink | Advertise | Privacy | Mobile
Web04 | 2.6.130516.1 | Last Updated 2 Dec 2012
Article Copyright 2012 by yak32
Everything else Copyright © CodeProject, 1999-2013
Terms of Use
Layout: fixed | fluid