Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/orxonox/trunk/core/world.cc @ 1872

Last change on this file since 1872 was 1872, checked in by patrick, 20 years ago

orxonox/trunk: play the square - its possible now…

File size: 3.5 KB
Line 
1
2
3/*
4   orxonox - the future of 3D-vertical-scrollers
5
6   Copyright (C) 2004 orx
7
8   This program is free software; you can redistribute it and/or modify
9   it under the terms of the GNU General Public License as published by
10   the Free Software Foundation; either version 2, or (at your option)
11   any later version.
12
13   ### File Specific:
14   main-programmer: Patrick Boenzli
15   co-programmer:
16*/
17
18
19#include "world.h"
20
21#include <iostream>
22
23using namespace std;
24
25
26/**
27   \brief Create a new World
28   
29   This creates a new empty world!
30*/
31World::World () {
32  lastPlayer = null;
33  lastNPC = null;
34}
35
36
37World::~World () {}
38
39
40/**
41   \brief Add Player
42   \param player A reference to the new player object
43   
44   Add a new Player to the game. Player has to be initialised previously
45*/
46bool World::addPlayer(Player* player) 
47{
48  playerList* listMember = new playerList;
49  listMember->player = player;
50  if ( lastPlayer != null ) 
51    {
52      listMember->number = lastPlayer->number + 1;
53      listMember->next = lastPlayer;
54    }
55  else 
56    {
57      listMember->number = 0;
58      listMember->next = null;
59    }
60  lastPlayer = listMember;
61}
62
63
64/**
65   \brief Remove Player
66   \param player A reference to the new npc object
67   
68   Remove a new Player to the game.
69*/
70bool World::removePlayer(Player* player) {
71  cout << "World::removeNPC not implemented yet" << endl;
72}
73
74Player* World::getLocalPlayer() 
75{
76  return localPlayer;
77}
78
79
80/**
81   \brief Add Non-Player-Character
82   \param player A reference to the new npc object
83   
84   Add a new Non-Player-Character to the game. Player has to be initialised previously
85*/
86bool World::addNPC(NPC* npc) 
87{
88  npcList* listMember = new npcList;
89  listMember->npc = npc;
90  if ( lastNPC != null ) 
91    {
92      listMember->number = lastNPC->number + 1;
93      listMember->next = lastNPC;
94    }
95  else 
96    {
97      listMember->number = 0;
98      listMember->next = null;
99    }
100  lastNPC = listMember;
101}
102
103
104/**
105   \brief Remove Non-Player-Character
106   \param player A reference to the new npc object
107   
108   Remove a new Non-Player-Character to the game.
109*/
110bool World::removeNPC(NPC* npc) {
111  cout << "World::removeNPC not implemented yet" << endl;
112}
113
114
115
116/**
117   \brief Draws the World and all Objects contained
118   
119   Calls the draw function of all: Objects, Players, Environement
120*/
121void World::drawWorld(void) 
122{
123  playerList* tmpPlayer = lastPlayer;
124  Player* player = tmpPlayer->player;
125  while( tmpPlayer != null ) 
126    {
127      (*tmpPlayer->player).drawPlayer();
128      tmpPlayer = tmpPlayer->next;
129    }
130  npcList* tmpNPC = lastNPC;
131  while( tmpNPC != null )
132    {
133      (*tmpNPC->npc).drawNPC();
134      tmpNPC = tmpNPC->next;
135    }
136}
137
138
139/**
140   \brief Updates the world and all its objects
141   
142   Calculates the new state of the world. User-input and AI of
143   the enemies are accounted for.
144*/
145void World::updateWorld(void) 
146{
147 
148
149}
150
151
152
153/**
154   \brief Routine for testing purposes.
155   
156   testing, testing, testing...
157*/
158void World::testThaTest(void) 
159{
160  cout << "World::testThaTest() called" << endl;
161  /* test addPlayer */
162  cout << "addPlayer test..." << endl;
163  playerList* pl = lastPlayer;
164  while ( pl != null )
165    {
166      cout << "player " << pl->number << " was found" << endl;
167      pl = pl->next;
168    }
169
170  /* test addNPC */
171  cout << "addNPC test..." << endl;
172  npcList* nl = lastNPC;
173  while ( nl != null )
174    {
175      cout << "npc " << nl->number << " was found" << endl;
176      nl = nl->next;
177    }
178
179  /* test drawWorld() */
180  cout << "drawWorld()..." << endl;
181  drawWorld();
182
183  cout << "World::testThaTest() finished" << endl;
184}
Note: See TracBrowser for help on using the repository browser.