Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

network: found a loading error

File size: 3.4 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#include "world_entity.h"
27#include "npcs/npc_test1.h"
28
29
30using namespace std;
31
32//! This creates a Factory to fabricate a SinglePlayerWorld
33CREATE_FACTORY(SinglePlayerWorld, CL_SINGLE_PLAYER_WORLD);
34
35
36
37SinglePlayerWorld::SinglePlayerWorld(const TiXmlElement* root)
38  : GameWorld(root)
39{
40  this->loadParams(root);
41}
42
43
44/**
45 *  remove the SinglePlayerWorld from memory
46 *
47 *  delete everything explicitly, that isn't contained in the parenting tree!
48 *  things contained in the tree are deleted automaticaly
49 */
50SinglePlayerWorld::~SinglePlayerWorld ()
51{
52  PRINTF(3)("SinglePlayerWorld::~SinglePlayerWorld() - deleting current world\n");
53}
54
55
56/**
57 * initializes the world.
58 * @param name the name of the world
59 * @param worldID the ID of this world
60 *
61 * set all stuff here that is world generic and does not use to much memory
62 * because the real init() function StoryEntity::init() will be called
63 * shortly before start of the game.
64 * since all worlds are initiated/referenced before they will be started.
65 * NO LEVEL LOADING HERE - NEVER!
66*/
67void SinglePlayerWorld::constuctorInit(const char* name, int worldID)
68{
69  this->setClassID(CL_SINGLE_PLAYER_WORLD, "SinglePlayerSinglePlayerWorld");
70  this->setName(name);
71
72  this->gameTime = 0.0f;
73  this->setSpeed(1.0);
74  this->music = NULL;
75  this->shell = NULL;
76  this->localPlayer = NULL;
77  this->localCamera = NULL;
78
79  this->showPNodes = false;
80  this->showBV = false;
81}
82
83
84/**
85 * loads the parameters of a SinglePlayerWorld from an XML-element
86 * @param root the XML-element to load from
87 */
88void SinglePlayerWorld::loadParams(const TiXmlElement* root)
89{
90  static_cast<GameWorld*>(this)->loadParams(root);
91
92  PRINTF(4)("Creating a SinglePlayerWorld\n");
93}
94
95
96
97/**
98 * this is executed just before load
99 *
100 * since the load function sometimes needs data, that has been initialized
101 * before the load and after the proceeding storyentity has finished
102 */
103ErrorMessage SinglePlayerWorld::preLoad()
104{
105  static_cast<GameWorld*>(this)->preLoad();
106
107  /* the the single player specific stuff */
108}
109
110
111/**
112 *  loads the SinglePlayerWorld by initializing all resources, and set their default values.
113 */
114ErrorMessage SinglePlayerWorld::load()
115{
116  static_cast<GameWorld*>(this)->load();
117
118  /* the the single player specific stuff here */
119
120  /* some static world entities */
121  for(int i = 0; i < 100; i++)
122  {
123    WorldEntity* tmp = new NPCTest1();
124    char npcChar[10];
125    sprintf (npcChar, "NPC_%d", i);
126    tmp->setName(npcChar);
127    tmp->setAbsCoor(((float)rand()/RAND_MAX) * 5000, 50/*+ (float)rand()/RAND_MAX*20*/, ((float)rand()/RAND_MAX -.5) *30);
128    this->spawn(tmp);
129  }
130}
131
132
133/**
134 *  post loads the SinglePlayerWorld by initializing all resources, and set their default values.
135 */
136ErrorMessage SinglePlayerWorld::postLoad()
137{
138  static_cast<GameWorld*>(this)->postLoad();
139
140  /* the single player specific stuff here */
141}
Note: See TracBrowser for help on using the repository browser.