Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

orxonox/trunk/core: world draw function

File size: 3.4 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
74
75/**
76   \brief Add Non-Player-Character
77   \param player A reference to the new npc object
78   
79   Add a new Non-Player-Character to the game. Player has to be initialised previously
80*/
81bool World::addNPC(NPC* npc) 
82{
83  npcList* listMember = new npcList;
84  listMember->npc = npc;
85  if ( lastNPC != null ) 
86    {
87      listMember->number = lastNPC->number + 1;
88      listMember->next = lastNPC;
89    }
90  else 
91    {
92      listMember->number = 0;
93      listMember->next = null;
94    }
95  lastNPC = listMember;
96}
97
98
99/**
100   \brief Remove Non-Player-Character
101   \param player A reference to the new npc object
102   
103   Remove a new Non-Player-Character to the game.
104*/
105bool World::removeNPC(NPC* npc) {
106  cout << "World::removeNPC not implemented yet" << endl;
107}
108
109
110
111/**
112   \brief Draws the World and all Objects contained
113   
114   Calls the draw function of all: Objects, Players, Environement
115*/
116void World::drawWorld(void) 
117{
118  playerList* tmpPlayer = lastPlayer;
119  Player* player = tmpPlayer->player;
120  while( tmpPlayer != null ) 
121    {
122      (*tmpPlayer->player).drawPlayer();
123      tmpPlayer = tmpPlayer->next;
124    }
125  npcList* tmpNPC = lastNPC;
126  while( tmpNPC != null )
127    {
128      (*tmpNPC->npc).drawNPC();
129      tmpNPC = tmpNPC->next;
130    }
131}
132
133
134/**
135   \brief Updates the world and all its objects
136   
137   Calculates the new state of the world. User-input and AI of
138   the enemies are accounted for.
139*/
140void World::updateWorld(void) 
141{
142 
143
144}
145
146
147
148/**
149   \brief Routine for testing purposes.
150   
151   testing, testing, testing...
152*/
153void World::testThaTest(void) 
154{
155  cout << "World::testThaTest() called" << endl;
156  /* test addPlayer */
157  cout << "addPlayer test..." << endl;
158  playerList* pl = lastPlayer;
159  while ( pl != null )
160    {
161      cout << "player " << pl->number << " was found" << endl;
162      pl = pl->next;
163    }
164
165  /* test addNPC */
166  cout << "addNPC test..." << endl;
167  npcList* nl = lastNPC;
168  while ( nl != null )
169    {
170      cout << "npc " << nl->number << " was found" << endl;
171      nl = nl->next;
172    }
173
174  /* test drawWorld() */
175  cout << "drawWorld()..." << endl;
176  drawWorld();
177
178  cout << "World::testThaTest() finished" << endl;
179}
Note: See TracBrowser for help on using the repository browser.