Game design -> GameWorld

This is a discussion on Game design -> GameWorld within the Game Programming forums, part of the General Programming Boards category; Hallo, I am now at the point where I have to start thinking about how to design my game. So ...

  1. #1
    Registered User
    Join Date
    Oct 2006
    Location
    UK/Norway
    Posts
    485

    Game design -> GameWorld

    Hallo,

    I am now at the point where I have to start thinking about how to design my game. So far I have just made classes and forced them in between others to see how different functions work. Now I want to take on step back and start designing at all so it makes a bit more sense.

    Here is my "outline" so far:
    Code:
    gameWorld
    {
    	public:
    		update();
    		draw();
    
    	private:
    		TimerFunction();
    
    	// Variables
    	private:
    		BulletMgr class
    		Map class
    		EnentyMgr class
    }
    I also have a global (singleton) class for drawing and manging graphics.

    The problem is that BulletMgr, Map, and EntetyMgr all need to know about each other(I think?) Is there a neat way to solve this?

  2. #2
    Frequently Quite Prolix dwks's Avatar
    Join Date
    Apr 2005
    Location
    Canada
    Posts
    8,048
    Note that you're missing the "class" (or "struct" if you want to be picky) keyword in your example.

    EntetyMgr
    "Entity", perhaps?

    The first thing that strikes me is that you could have a Mgr or Sprite class to handle bullets and entities. Perhaps you could inherit from this class to create entity and bullet versions if they're different enough.

    And what does your Map class represent? If it decides where entities can go, then the Sprite/whatever class will probably need to know about it somehow.

    Is there a neat way to solve this? I don't know. I think maybe you need to provide more information if you can . . . .
    dwk

    Seek and ye shall find. quaere et invenies.

    "Simplicity does not precede complexity, but follows it." -- Alan Perlis
    "Testing can only prove the presence of bugs, not their absence." -- Edsger Dijkstra
    "The only real mistake is the one from which we learn nothing." -- John Powell


    Other boards: DaniWeb, TPS
    Unofficial Wiki FAQ: cpwiki.sf.net

    My website: http://dwks.theprogrammingsite.com/
    Projects: codeform, xuni, atlantis, nort, etc.

  3. #3
    mov.w #$1337,D0 Jeremy G's Avatar
    Join Date
    Nov 2001
    Posts
    704
    I'll describe the method I'm using and you can decide if it suits you. My method is inspired by (what I remember of) quake 3 code.

    Your winMain has three entry points for "the game":

    // called after window initialization and openGl setup
    Game Setup

    // called during the main windows loop
    Game Loop

    // called after the main windows loop during shutdown procedure
    Game Shutdown


    Your key object that is going to link everything together is your Game State object.
    Heres a rough outline of that object

    Code:
    class GameState {
         long currentTick;
         long lastTick;
    
         std::vector<entity_npc> npcEntites; 
         std::vector<entity_player> playerEntities;
         std::vector<entity_projectile> projectileEntities;
         std::vector<entity_emitter> emitterEntities;
         Level * map;
    }
    The method is as follows:
    Game Setup:
    Initialize your GameState object and all the objects it consists of etc.

    Game Loop:
    Save the Current GameState as Last GameState.
    Do all updates / calculations based on the Last GameState and put the new values
    in Current GameState.
    Do Rendering based on Current GameState.

    Game Shutdown:
    Free all your memory / standard shutdown etc.


    Pseudo Code Example
    Code:
    GameState lastState;
    GameState currentState;
    
    function GameSetup() {
         // first tick
         currentState.currentTick = GetTickCount();
         currentState.prevTick = GetTickCount() - GOAL_TICK_PER_FRAME; // start off with ideal difference
         // load level
         Level map = new Level();
         currentState.map = map;
    
         // load players
         for(i = 0; i < clients; i++)
              currentState.playerEntities.push_back(new entity_player(client[i]));
    
         // load npc entities
         for(i = 0; i < npcs; i++)
              currentState.npcEntities.push_back(new entity_npc(npcs[i]));
    
         // no projectile data yet
    
         // no particle emitters yet
    }
       
    function gameLoop() {
         // save currentState as last
         lastState = currentState;
         
         currentState.currentTick = GetTickCount();
         currentState.prevTick = lastState.currentTick(); 
         
         // update projectile entities
         for(i = 0; i < projectileEntities.size(); i++) {
              currentState.projectileEntities[i].position = lastState.projectileEntities[i].position + lastState.projectileEntities[i].velocity;
         }
         // update player entities
         for(i = 0; i < playerEntities.size(); i++) 
              updatePlayerPositionFromInput(playerEntities[i]);
    
         // update npc entities
         for(i = 0; i < npcEntities.size(); i++) 
              updateNpcPositionFromAi(npcEntities[i]);
    
         // etc
    
         // now that currentState has been updated we do rendering based on objects in currentState.
         // render map, players, npcs, projectiles, etc.
         // render ui 
         // etc.
    }
    
    function gameShutdown() {
         // free up memory etc.
    }
    Of course, your main game loop wont do any of the actual data updates, i did the projectile stuff in place as an example, but ideally it would be handled similar to player input and npc control in the example. You just pass all the needed info (entity object, entire entity list or even the entire game state object(s)) to your physics, ai, or input systems and let them do the updates.


    It will be up to you to decide what objects are included in your game state and decide how you want to manage those objects (this example uses vectors).

    Hope this helps you decide on a way to tie everything together.
    c++->visualc++->directx->opengl->c++;
    (it should be realized my posts are all in a light hearted manner. And should not be taken offense to.)

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Game design question
    By h3ro in forum Game Programming
    Replies: 6
    Last Post: 02-28-2008, 07:20 AM
  2. Game Engine Link Prob
    By swgh in forum Game Programming
    Replies: 2
    Last Post: 01-25-2006, 11:14 PM
  3. Game Independent Anti-cheat Project Needs Programmers
    By GIA Project Lea in forum Projects and Job Recruitment
    Replies: 3
    Last Post: 09-15-2005, 07:41 PM
  4. Anyone heard of FULL SAIL GAME DESIGN DEGREE?
    By marCplusplus in forum A Brief History of Cprogramming.com
    Replies: 7
    Last Post: 11-30-2001, 09:06 PM
  5. Im a Newbie with a graphics design problem for my simple game
    By Robert_Ingleby in forum C++ Programming
    Replies: 1
    Last Post: 11-23-2001, 05:41 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21