Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 21 Sep 2013
Offline Last Active Jan 08 2015 02:26 AM

Topics I've Started

How should i call my classes instead of "xyManager"?

13 December 2014 - 04:42 AM


I am currently working in an RTS game in C++.


I read in alot of place that calling something "Manager" is generally bad, because it's too generic and say nothing about what the class really does.


However, i have no idea how to call them instead. Currently i have these:


- ImageManager: It load the images, and every class that need a texture can get it from this class. This is because IO operations are REALLY expensives, so i rather read the images once and use all from the memory.


- Building and Unit Manager: These classes have a container, which contains all Building/Unit which are currently alive. You can update them through this class and it's also check if you clicked to one of them.


- EventManager: I didn't wrote it yet, but this supposed to handle Commands and other events. You can basically post any command or event to execute them in the next iteration of event loop.


Any idea what name would fit better what these classes do?


Thank you very much for the answer!

(Tower Defense) Template metaprogramming or Factory functions to avoid class hierarchy?

09 September 2014 - 01:13 AM


Currently i am working in a Tower Defense Game (C++, SFML), which i started like 2 years ago, and i stopped developing it since i have a job.

Now i started again to teach a friend about C++, and i should rewrite alot of part.


A key question is how  to store the Tower (and Minion) hierarchy.


Now i have a TowerBase class, which have the Derived types, like ArcherTower, MageTower etc.


This is pretty bad, because TowerBase have the values like Range, Damage etc, which should be initialized there. Now i reassign it in the derived constructor, and it seems like a  terrible pattern.

It's also bad, because in the game i use all towers as a TowerBase, so it doesn't make much sense to derive them just because they can attack differently.


Okay, so the attack part i will use lambdas as template parameters, which will define how should it fire. It's okay.


I like the idea to template the Tower class instead of the class hierarchy (it's also faster, because there will be no virtual calls etc).


The problem come when i should define the towers. They have different damage, range etc.


Solition 1.: I would like the idea to somehow make it possible to typedef the towers with different values.

So when i say:

ArcherTower archerTower;


MageTower mageTower;

 it would call a constructor, which will set different base values (like for archerTower, 30 damage, for mage, 40), while ArcherTower and MageTower are just different typedefs for the same templated class.

Okay so, that's  the first solution, writing a template metaprogrammed class, and typedef it for different towers.

In this case, i must use a TowerBase class, which will let me use containers that store Towers.

This TowerBase should have at least a virtual Attack() function, which is again, problematic. This is because different Towers attack differently, but i just store TowerBase ptr-s, so i can't call the derived functions. How can i solve this?

Solution 2.: The other solution that come to my mind is to make factory functions, like "MakeArcherTower ()", which will do the things for me. It's slower and a bit harder to use, but i am sure i can do this, the solution one is something i don't exactly know, because i don't really have experience in metaprogramming. In this case, i shouldn't use a base class.


What do you think, which is the better? (or is it a 3rd option?)


I would also use this pattern to minions, so it would possible used instead of more than a hundred class.


Thank you for help! smile.png

[C++] Forward declaration VS include in headers

06 January 2014 - 10:26 AM



Is there any issue with using forward declaration in header files instead of includes when it's possible?

It will compile faster, however i am not entirely sure if it's a good idea. ohmy.png


Thank you for answers!


Question about TD game's code design

21 December 2013 - 04:28 AM



I have a half finished TD and i decided to finish it. When i did that project i used pretty bad design, and i had a circular dependency, now i want to fix that.


The idea is:

Make a GameController class, the event loop run here, but GC won't handle it, it just decide who should handle it (the User interface or the map), and convert the mouseclick coordinate depending on the view of the handling class.


If there is an actual command from the UI (like Build XY Tower) the gamecontroller get it and drop down to the map to execute it.


I am sure it can work, but i am not entirely sure that's the best solution i can do.


Any opinion is appreciated!


What graphics API should i use for a Heroes 3 style game?

12 November 2013 - 11:10 AM



I like to start a Heroes 3 style project with C++, i think about what API should i use for graphics?

Now i mostly think about SDL, i have no experience in it yet tho.

Is someone who have experience with it can tell me if there is any issue with SDL for a bigger project?


Thank you for answers!