RTS 4X game design

Post your questions, suggestions and experiences regarding game design, integration of external libraries here. For irrEdit, irrXML and irrKlang, see the
ambiera forums
kohansey
Posts: 14
Joined: Tue Apr 01, 2008 3:18 am

RTS 4X game design

Post by kohansey »

I am attempted to create 4x RTS space game. I have the concept, but I an new to game programming and I am having a hard time figuring out how to design the thing. I will list the things that I have came up with so far and maybe someone here can give me some suggestions on how to move farther.

Game concept:

GAMEPLAY
The player will start out with a colonized planet / moon. On the planets / moons, the player can build space station or planetary improvements. From the space stations, the player can build ships.

Ships are used to explore the universe, expand the players control, gather resources, and destroy the enemy. If anyone has played Homeworld you'll understand the kind of look and feel I am going for.

There is research, resources, and customizable ships.

The game world is made up of solar systems interconnected by phase lanes.

THE MACRO-VERSE

This is the highest viewing level of the universe. The player can only zoom in from here.

The player will be able to see all solar-systems that have been discovered. The solar-systems will be represented by small spheres or maybe billboards with player logos. Each solar system will have one or more "phase" lane(s) that allow game objects to move from one solar system to the next. Each phase lane will be represented by a line that is draw between two solar systems.

SOLAR-SYSTEM

This is the next viewing level. The player can zoom out or zoom in.

This is a 3d mostly top-down view a solar system. A Star in the middle and a number of space objects slowly orbiting the star. At this level not very many objects can be seen, mainly the planets and their moons, some asteriods and resource spots. I want to display billboards for objects that are to far/small to see.

PLANET / MOONS / ASTERIODS / RESEARCH POINTS
This would be the final level of view for the game. The player can zoom in close to view game objects or zoom back out to the solar system.

This is a 3d mostly top-down view of a sector of the solar system. All objects will be visible, and objects to small to see will be replaced with billboards.

What I have so far:
I have a few c++ classes for player, space objects, and planets. I have a solar system class that uses std::list to store all the objects within, which I am including the source for at the bottom of this post. This is where the design starts to fade, how do I interconnect the whole universe, should I have a master list of all run-time game objects or should it be broken up into smaller chunks based on sector. The std::list approach doesn't seem to be the way to go for collision detection and user interaction. How do I translate mouse click into game events. After playing around with the tutorials for IrrLicht, I was able to create a demo that moves a single ship to a point "close" to where the mouse click, but now I need to do this for multiple objects, so I need a better approach to send events to game objects. How would I change the GUI interface based off the object selected? Things like this are holding me back to getting past main. I am looking for any feedback, advice, or comments would be appreciated.

My sector.h file (solar system, space object, and planet definitions)

Code: Select all

#ifndef __SECTOR_H__
#define __SECTOR_H__

#include <enginedef.h>

namespace GameEngine {

class space_obj {
public:
    space_obj  (void);
    virtual ~space_obj (void);

    virtual void create_obj (vector3df pos, f32 size, char* meshname);

private:
    space_obj (const space_obj& o);
    space_obj& operator= (const space_obj& o);

    core::vector3df mPos;
};


class planet : public space_obj {
public:
    planet  (void);
    ~planet (void);
 
    void create_obj (vector3df pos, f32 size, char* meshname);

private:
    planet (const planet& p);
    planet& operator= (const planet& p);
};

class sector {
public:
    sector  (void);
    ~sector (void);

    void create_sector (void);

private:
    sector (const sector& s);
    sector& operator= (const sector& s);

    core::vector3df mPos;
    std::list<space_obj*> mObjs;
};

};

#endif // __SECTOR_H__
this is the implementation for sector.h. engine.h is basically a wrapper class for an IrrlichtDevice

Code: Select all

#include "sector.h"
#include "engine.h"

namespace GameEngine {

    space_obj::space_obj (void) :
    mPos(0,0,0)
{ }

space_obj::~space_obj (void) 
{ }

void space_obj::create_obj (vector3df pos, f32 size, char* meshname)
{
    engine::get_engine()->get_scene()->addAnimatedMeshSceneNode(
        engine::get_engine()->get_scene()->getMesh(meshname), 0, -1, pos);
    mPos = pos;
}

planet::planet (void) :
    space_obj()
{ }

planet::~planet (void)
{ }
 
void planet::create_obj (vector3df pos, f32 size, char* meshname)
{
    engine::get_engine()->get_scene()->addAnimatedMeshSceneNode(
        engine::get_engine()->get_scene()->getMesh(meshname), 0, -1, pos);

    engine::get_engine()->get_scene()->addAnimatedMeshSceneNode(
        engine::get_engine()->get_scene()->getMesh("data\\PlanetIce1.3ds"), 0, -1, pos+vector3df(40, 0, 15));

    engine::get_engine()->get_scene()->addAnimatedMeshSceneNode(
        engine::get_engine()->get_scene()->getMesh("data\\PlanetIce1.3ds"), 0, -1, pos+vector3df(-25, 0, 25));
}



sector::sector (void) :
    mPos(0,0,0),
    mObjs(0)
{ }

sector::~sector (void)
{ }

void sector::create_sector (void)
{
    mObjs.clear();
    mObjs.push_front(new space_obj());
    mObjs.push_front(new planet());
    mObjs.push_front(new planet());
    mObjs.push_front(new planet());
    mObjs.push_front(new planet());
    mObjs.push_front(new space_obj());

    std::list<space_obj*>::iterator iter = mObjs.begin();
    (*iter++)->create_obj(vector3df(     0,  0,     0),  400, "data\\Star_Green.3ds");
    (*iter++)->create_obj(vector3df( 175,  0,  900),   20, "data\\PlanetIce0.3ds");
    (*iter++)->create_obj(vector3df( -900,  0, 130),   30, "data\\PlanetIce0.3ds");

}

};
Questions, comments, complains, advice, anything that could help would be greatly appreciated.
kohansey
Posts: 14
Joined: Tue Apr 01, 2008 3:18 am

Post by kohansey »

I did a little more digging into this forum and found a great demo by rogueborg for a 2d space combat. I will be morphing this demo into a workable add-on to my project. I wanted to get your guys advice about objects and players, mainly AI players. What do you think is the best way to have the AI "know" about it units and colonized planets. Should it be a dynamic list of pointers to the actual space objects, or should each player hold a "master" list of objects that they control. Or should it be a copy of the master list? Opinions are welcome.
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

Seriously, gamedev. or igda. Or other gaming coding ressource. While you may find help here, it's still a graphic engine forum.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

The license on that code is "All rights reserved".

It is all rights reserved not because I dislike sharing code, but because I wish to discourage any fellow developer from using such a horrid fragile hacked up demo as the basic for production code. There are so many things (by 'design') wrong with it that I don't even know where to begin, but I'll take a poke at it:

All in one source file.
Uses structs and direct access to public members.
Uses some functions instead of methods to avoid splitting struct declarations/definitions.
Fixed sized arrays.
Almost no error checking.
Global data (SContext).
It is not structured in any meaningful way.

Please, do yourself a favour and don't base anything on that code except a disposable demo.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
BlindSide
Admin
Posts: 2821
Joined: Thu Dec 08, 2005 9:09 am
Location: NZ!

Post by BlindSide »

All in one source file.
:shock:
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

130Kb and counting, wheeeeeeh. It's written to be deliberately hard to maintain, to reduce the temptation to extend the prototype rather than starting over with proper requirements/analysis/design. :D
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

I love this man the way no men has loved a sheep before...
kohansey
Posts: 14
Joined: Tue Apr 01, 2008 3:18 am

Post by kohansey »

So basically what you are saying, dorth, is that there is no one in this community that has any experience designing games and that it is big waste of time to attempt to get any answers.

rogueborg, I agree that your code is a hack job :D , but it gave me some good ideas on how to farther the progress for my game, and for that I thank you.

Well, since no one cares to comment on my game concept, or offer any opinions related to my design, I will just go with a std::list of objects. Each player will contain a list of all objects under that player's control. Also I will continue with the solar system holding an std::list for all objects contained within.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

Strange, I can't find where Dorth "said" that. Perhaps he edited his posts. :?

It's not that we're not interested, it's that you have a big question (well, set of questions), to which there's no quick or obvious answer. It would therefore be a big time investment for anyone else to consider and discuss possible solutions in detail.

Perhaps if you break your questions down into small, encapsulated issues, with the minimum of context, you may get more feedback.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

I didn't ;)
And somehow the above text wasn't sufficient for a post.

--edit--
or it was and it gave me a warning it wasn't...
kohansey
Posts: 14
Joined: Tue Apr 01, 2008 3:18 am

Post by kohansey »

Okay, lets see.

I think best on examples, so here goes.

You have universe full of objects (ISceneNodes). These objects are
Spheres for planets,
Meshes for ships, spacestations, asteriods, and space debris.
Each object is textured.
Number probably don't matter, but say there are a larger number of these objects, in the thousands.

The user is viewing only a small section of this universe.

The user then clicks somewhere on the viewport, a non-gui click.

I know how to translate the 2d coordinate to a 3d ray.

With this 3d ray, what is the best way in Irrlicht to detect what object, if any was under the mouse?

I guess the real question is, will Irrlicht find the object for me, or do I need to run a collision detect on all objects in the universe?
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

ISceneCollisionManager::getSceneNodeFromRayBB() should work.

Have you looked at example 07.Collision?
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
kohansey
Posts: 14
Joined: Tue Apr 01, 2008 3:18 am

Post by kohansey »

Thank you rogerborg for you help. The collision example 07 is for a closed world comprised of a single map mesh and a few objects. How would this work for my world, where the "map" is comprised of many different objects? Would I need to attach a Collision Response animator to all objects? Or will one Collision Response animator on the camera work?
Dorth
Posts: 931
Joined: Sat May 26, 2007 11:03 pm

Post by Dorth »

If you do anything too complex, you're better off with a physic library or at least a collision detection lib.
rogerborg
Admin
Posts: 3590
Joined: Mon Oct 09, 2006 9:36 am
Location: Scotland - gonnae no slag aff mah Engleesh
Contact:

Post by rogerborg »

kohansey wrote:Thank you rogerborg for you help. The collision example 07 is for a closed world comprised of a single map mesh and a few objects. How would this work for my world, where the "map" is comprised of many different objects? Would I need to attach a Collision Response animator to all objects? Or will one Collision Response animator on the camera work?
ISceneCollisionManager::getSceneNodeFromRayBB() and similar "BB" methods use a Bounding Box check. Every scene node has a bounding box that's automatically calculated from its mesh or other visual properties. The ray/box test is relatively cheap, and it can be done on a subsection of the scene tree - i.e. you can arrange your scene tree hierarchically by region, and only check that region.

Given that we're (currently) talking about an operation that's only done in response to user input, it should be more than fast enough, even with a big dumb test of every scene node in a subsection - or even the entirety - of the scene tree.

You don't have to attach any collision response animators, or create triangle selectors, unless you actually need accurate triangle based collisions.
Please upload candidate patches to the tracker.
Need help now? IRC to #irrlicht on irc.freenode.net
How To Ask Questions The Smart Way
Post Reply