Turn based strategy game like TW-Series

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
gloin92
Posts: 11
Joined: Fri Jan 24, 2014 5:06 pm

Turn based strategy game like TW-Series

Post by gloin92 »

Hey guys,

I am new to Irrlicht. I am an average programmer and have programmed only 2D games yet (Tower Defense Game in Java, Space Shooter in C++).

I am planning on programming a turn based stategy game like the campaign map in the Total War series. If you don't know them here is a screenshot: http://blogs.suburbanchicagonews.com/ga ... mpaign.jpg. What I basically need is a map where I can place cities, move armies etc. Important aspects would be the map/terrain, pathfinding for armies considering the terrain, GUI for management, diplomacy, politics etc. and AI.

Programming is just my hobby and I have very limited time which is why I would like to know how you would approach this problem. I would be satisfied with a point into the right direction.

Thanks in advance.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Turn based strategy game like TW-Series

Post by CuteAlien »

Get rich and then sponsor a team of programmers in your spare-time? It's pretty hard competing with teams that have a handful of coders (+ artists, a game designer and a sound guy) all working full-time when you are doing it as a hobby.

Good game design is always about leaving things out and concentrating on the stuff that is important for an idea. That's even more true for hobby games where you won't have much time implementing stuff. So putting everything in (diplomacy, ai, cool terrain...) is the wrong direction.

So you can make a game about diplomacy for example - might be strongly text-based and with little need for 3d and animation. Or you might consider a game for tactical army management. Might work with very abstract graphics and need no diplomacy at all. In strategy games you might have to think early about how many units you might want to use - and then do a rough calculation how much time you plan to spend on each (say you figure out how to create 1 model per weekend - which is very fast - how many units will you when be willing to have?).

Another alternative is to look around open source/free software games and involve yourself in those. Then you start with a working code base, have already graphics available and you can even work with other people interested in the same game type. Check wikipedia for a list of open source games and take a look if you might want to involve yourself in one of them: http://en.wikipedia.org/wiki/List_of_op ... ideo_games

If you still want to write it from scratch - consider priorities. If you want it mostly to look cool - maybe start with programming a nice terrain-engine. If you mainly care about strategy - start with a simple flat board (but make each field a struct so you can add more stuff to it later on). Then work on a gui for the basic commands. For path finding use any library supporting A* (google around, there are lots of those).
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
gloin92
Posts: 11
Joined: Fri Jan 24, 2014 5:06 pm

Re: Turn based strategy game like TW-Series

Post by gloin92 »

Thanks for your reply. Yes, I have thought it through and I do want to keep it really simple. I am a student (not IT-related) so there will be periods where I have much time and periods where I have none. I know about my chances getting such a project done.

I am not worried about diplomacy, AI, GUI etc. as I am confident I can do that on my own. It just needs time. I was just concerned about the basic mechanics regarding the campaign map (terrain, unit movement). But maybe it was just a silly question as it may be answered after I worked with the engine some time.

I am planning on working with placeholders. If I can get it done I will probably pay someone for 3d-models. And I don't really need many. One would suffice theoratically as they only symbolize real armies on the map.

Thanks again for your reply. I will start working with the engine as soon as the exam period is over.
gloin92
Posts: 11
Joined: Fri Jan 24, 2014 5:06 pm

Re: Turn based strategy game like TW-Series

Post by gloin92 »

1. I messed around a little bit with the tutorials and tried to create terrain with some water. My problem is that the terrain and the water don't seem to have the same default position and rotation. I can fix that manually but it still seems strange to me.

2. Do you think creating a terrain with a heightmap is the best solution for such a game?

Screenshots:

https://lh4.googleusercontent.com/RCW9W ... 24-h768-no
https://lh6.googleusercontent.com/v8H-m ... w1024-h768


Terrain:

Code: Select all

 
scene::ITerrainSceneNode* terrain = smgr->addTerrainSceneNode(
        "media/world.bmp", 0, -1,                 
        core::vector3df(0.f, 0.f, 0.f),     
        core::vector3df(0.f, 0.f, 0.f),     
        core::vector3df(50.f, 5.0f, 50.f),  
        video::SColor ( 255, 255, 255, 255 ),  
        1, scene::ETPS_17, 2);
 
    terrain->setMaterialFlag(video::EMF_LIGHTING, false); 
    terrain->setMaterialTexture(0, driver->getTexture("media/world2.bmp"));
    terrain->setMaterialTexture(1, driver->getTexture("media/detailmap3.jpg"));    
    terrain->setMaterialType(video::EMT_DETAIL_MAP); 
    terrain->scaleTexture(1.0f, 20.0f);
 
Water:

Code: Select all

 
IAnimatedMesh* mesh = smgr->getMesh(0); 
    mesh = smgr->addHillPlaneMesh( "water",
    core::dimension2d<f32>(1025,1025),
    core::dimension2d<u32>(1,1), 0, 0,
    core::dimension2d<f32>(0,0),
    core::dimension2d<f32>(1,1));
 
    ISceneNode* water = smgr->addWaterSurfaceSceneNode(mesh->getMesh(0), 1.f, 500.0f, 3.f);
    //water->setPosition(core::vector3df(50*512, 100.f, 50*512));
    //water->setRotation(core::vector3df(0.f, 180.f, 0.f));
    water->setScale(core::vector3df(50.f, 5.0f, 50.f));
    water->setMaterialFlag(video::EMF_LIGHTING, false);
    water->setMaterialTexture(0, driver->getTexture("media/world2.bmp"));
    water->setMaterialTexture(1, driver->getTexture("media/water.jpg"));        
    water->setMaterialType(video::EMT_REFLECTION_2_LAYER);  
 
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Turn based strategy game like TW-Series

Post by CuteAlien »

Usually heightmap is a good idea. Mainly because it makes AI easier. Thought it's also possible to just make a complete map in modeling tool - more work on AI but gives you more freedom on design. I doubt the terrainscenenode is sufficent for this kind of game. You will likely want to control small texture-blocks and not just set 1 texture for the whole map. So you will probably work with a custom scenenode. I think there had been an implementation for a terrain like that posted in the forum in the past, but I have no link right now and also would have to search for it. Maybe someone else can remember that and has the link?
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
gloin92
Posts: 11
Joined: Fri Jan 24, 2014 5:06 pm

Re: Turn based strategy game like TW-Series

Post by gloin92 »

I could make the map in a modelling tool and then make aheightmap out of it. Wouldn't that give me the same degree of freedom on design? Also what difference is there in the AI, why would it be more work?

Creating the map turned out to be a lesser problem. I made a heightmap out of a real map which I now also use as texture. The heightmap can be easily made into a model and vice versa.

https://lh3.googleusercontent.com/-gj2a ... -06-47.png#

But I still have no plan on how to mark borders and regions.

Sorry for all the questions.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Turn based strategy game like TW-Series

Post by CuteAlien »

Well... heightmap's are just pretty simple to handle for AI code. I mean it's just quads - while a modeling tool can give you any kind of polygon-soup with holes and concave obstacles and whatever the model and think of. That makes the math a lot easier.

And ... well - you can mark borders and regions however you want to handle them in code. Think of something - that's the job of a coder :-) Possible solutions are: give them a special height value (-127 for example), or (probably better) - you use a second value for the field-type. Or maybe you hardcode the borders or sizes.
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
gloin92
Posts: 11
Joined: Fri Jan 24, 2014 5:06 pm

Re: Turn based strategy game like TW-Series

Post by gloin92 »

I think I have a very good solution for regions/borders concerning the coding. I will just have an image with the size of the map and make the color of the pixels determin the region, e.g., the value of the alpha channel could function as the region ID (0 -> none, 1 -> region 1, ..., 255 -> region 255). I don't know yet how to realize it with Irrlicht but I am sure it is possible.

What I meant is how to display them graphically. I want to be able to switch between physical and political map and of course display the borders in the right colors depending the owner (own, friendly, neutral, hostile). The former I could solve by switching between two textures but I would have to create the political map texture every time a region changes the owner. I would rather like to somehow draw region colors directly onto the terrain.
gloin92
Posts: 11
Joined: Fri Jan 24, 2014 5:06 pm

Re: Turn based strategy game like TW-Series

Post by gloin92 »

Ok, I managed to color regions: https://lh3.googleusercontent.com/-2ZBA ... -04-05.png

But I think my solution is very bad. I created another terrain scene node with a rendered target texture as texture on which I draw the political map. There must be a better solution. Can a terrain have multiple materials or more than 2 textures? I couldn't figure that out which is why I created two terrain scene nodes in the first place.
Last edited by gloin92 on Thu Jan 30, 2014 12:15 pm, edited 1 time in total.
CuteAlien
Admin
Posts: 9716
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Turn based strategy game like TW-Series

Post by CuteAlien »

Looking rather nice :-)

As I wrote already - the build in terrainscenenode is likely not sufficient. You can work with more than 2 textures when you leave the fixed-function-pipeline materials behind and write shaders instead. Although having more than 2 sets of uv coordinates per Vertex doesn't seem to be possible (maybe the shader-pipeline branch of Irrlicht is changing that - don't know...).

You can always change materials at runtime by setting new textures.
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
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Turn based strategy game like TW-Series

Post by hendu »

Here's how I'd do the coloring.

1. You pass two textures to the ground shader. The first has the standard color, in the alpha you have the region id. The second is a 1d texture mapping from region id to owner ("region 0 is owned by owner 1"). You update this second small texture via cpu every time a region changes owners.
2. You pass in the owner colors as uniforms, there's only a couple owners at most. You also pass in an uniform that controls whether to do the political colors or not.

Only one UV needed, minimal overhead.
Post Reply