Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/network/src/story_entities/single_player_world.cc @ 6358

Last change on this file since 6358 was 6358, checked in by patrick, 18 years ago

network: major changes in the world files

File size: 3.3 KB
Line 
1/*
2   orxonox - the future of 3D-vertical-scrollers
3
4   Copyright (C) 2004 orx
5
6   This program is free software; you can redistribute it and/or modify
7   it under the terms of the GNU General Public License as published by
8   the Free Software Foundation; either version 2, or (at your option)
9   any later version.
10
11   ### File Specific:
12   main-programmer: Patrick Boenzli
13*/
14
15#define DEBUG_SPECIAL_MODULE DEBUG_MODULE_WORLD
16
17#include "single_player_world.h"
18
19#include "state.h"
20#include "class_list.h"
21
22#include "load_param.h"
23#include "fast_factory.h"
24#include "factory.h"
25
26
27
28using namespace std;
29
30//! This creates a Factory to fabricate a SinglePlayerWorld
31CREATE_FACTORY(SinglePlayerSinglePlayerWorld, CL_SINGLE_PLAYER_WORLD);
32
33
34
35SinglePlayerWorld::SinglePlayerWorld(const TiXmlElement* root)
36  : GameWorld(root)
37{
38  this->loadParams(root);
39}
40
41
42/**
43 *  remove the SinglePlayerWorld from memory
44 *
45 *  delete everything explicitly, that isn't contained in the parenting tree!
46 *  things contained in the tree are deleted automaticaly
47 */
48SinglePlayerWorld::~SinglePlayerWorld ()
49{
50  PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n");
51}
52
53
54/**
55 * initializes the world.
56 * @param name the name of the world
57 * @param worldID the ID of this world
58 *
59 * set all stuff here that is world generic and does not use to much memory
60 * because the real init() function StoryEntity::init() will be called
61 * shortly before start of the game.
62 * since all worlds are initiated/referenced before they will be started.
63 * NO LEVEL LOADING HERE - NEVER!
64*/
65void SinglePlayerWorld::constuctorInit(const char* name, int worldID)
66{
67  this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld");
68  this->setName(name);
69
70  this->gameTime = 0.0f;
71  this->setSpeed(1.0);
72  this->music = NULL;
73  this->shell = NULL;
74  this->localPlayer = NULL;
75  this->localCamera = NULL;
76
77  this->showPNodes = false;
78  this->showBV = false;
79}
80
81
82/**
83 * loads the parameters of a SinglePlayerWorld from an XML-element
84 * @param root the XML-element to load from
85 */
86void SinglePlayerWorld::loadParams(const TiXmlElement* root)
87{
88  static_cast<GameWorld*>(this)->loadParams(root);
89
90  PRINTF(4)("Creating a SinglePlayerWorld\n");
91}
92
93
94
95/**
96 * this is executed just before load
97 *
98 * since the load function sometimes needs data, that has been initialized
99 * before the load and after the proceeding storyentity has finished
100 */
101ErrorMessage GameWorld::preLoad()
102{
103  static_cast<GameWorld*>(this)->preLoad();
104
105  /* the the single player specific stuff */
106}
107
108
109/**
110 *  loads the GameWorld by initializing all resources, and set their default values.
111 */
112ErrorMessage GameWorld::load()
113{
114  static_cast<GameWorld*>(this)->load();
115
116  /* the the single player specific stuff here */
117
118  /* some static world entities */
119  for(int i = 0; i < 100; i++)
120  {
121    WorldEntity* tmp = new NPCTest1();
122    char npcChar[10];
123    sprintf (npcChar, "NPC_%d", i);
124    tmp->setName(npcChar);
125    tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
126    this->spawn(tmp);
127  }
128}
129
130
131/**
132 *  post loads the GameWorld by initializing all resources, and set their default values.
133 */
134ErrorMessage GameWorld::postLoad()
135{
136  static_cast<GameWorld*>(this)->postLoad();
137
138  /* the single player specific stuff here */
139}
Note: See TracBrowser for help on using the repository browser.