Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1858 in orxonox.OLD for orxonox/trunk/core


Ignore:
Timestamp:
May 5, 2004, 7:33:27 PM (21 years ago)
Author:
patrick
Message:

orxonox/trunk/core: world draw function

Location:
orxonox/trunk/core
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/core/npc.cc

    r1855 r1858  
    1919#include "npc.h"
    2020
     21#include <iostream>
     22
     23using namespace std;
    2124
    2225
     
    2831
    2932
     33void NPC::setPosition(int x, int y, int z)
     34{
     35  xCor = x; yCor = y; zCor = z;
     36}
     37
     38void NPC::getPosition(int* x, int* y, int* z)
     39{
     40  *x = xCor;
     41  *y = yCor;
     42  *z = zCor;
     43}
     44
     45
     46void NPC::drawNPC(void)
     47{
     48  cout << "Player::drawNPC()" << endl;
     49}
  • orxonox/trunk/core/npc.h

    r1855 r1858  
    1010  ~NPC ();
    1111
     12  void drawNPC(void);
     13  void setPosition(int x, int y, int z);
     14  void getPosition(int* x, int* y, int* z);
     15
     16 private:
     17  /* position of the non player space craft */
     18
    1219  int npcType;
     20
     21  int xCor;
     22  int yCor;
     23  int zCor;
     24;
    1325
    1426};
  • orxonox/trunk/core/orxonox.cc

    r1856 r1858  
    7272  glutDisplayFunc(display);
    7373  glutReshapeFunc(reshape);
     74  glutKeyboardFunc(keyboard);
    7475}
    7576
     
    8889}
    8990
     91
     92void Orxonox::keyboard(unsigned char key, int x, int y)
     93{
     94  switch(key) {
     95  case 27:
     96    exit 0;
     97    break;
     98  }
     99}
    90100
    91101
     
    122132  (*wd).addPlayer(pl);
    123133  (*wd).addPlayer(pl);
     134
     135  NPC* nl = new NPC;
     136  (*wd).addNPC(nl);
     137  (*wd).addNPC(nl);
     138  (*wd).addNPC(nl);
     139  (*wd).addNPC(nl);
     140  (*wd).addNPC(nl);
     141  (*wd).addNPC(nl);
    124142  (*wd).testThaTest();
    125143
  • orxonox/trunk/core/orxonox.h

    r1856 r1858  
    2323  static void display (void);
    2424  static void reshape (int w, int h);
     25  static void keyboard(unsigned char key, int x, int y);
    2526};
    2627
  • orxonox/trunk/core/player.cc

    r1856 r1858  
    1414
    1515#include "player.h"
     16#include <iostream>
    1617
    1718using namespace std;
     
    2526
    2627
     28void Player::setPosition( int x, int y, int z)
     29{
     30  xCor = x; yCor = y; zCor = z;
     31}
     32
     33
     34void Player::drawPlayer(void)
     35{
     36  cout << "Player::drawPlayer()" << endl;
     37}
  • orxonox/trunk/core/player.h

    r1856 r1858  
    1010  ~Player ();
    1111
     12  void setPosition(int x, int y, int z);
     13  void getPosition(int* x, int* y, int* z);
     14  void drawPlayer(void);
     15
    1216 private:
    1317  /* position of the space craft */
     
    1620  int zCor;
    1721
     22
     23
    1824};
    1925
  • orxonox/trunk/core/world.cc

    r1856 r1858  
    2424
    2525
    26 
     26/**
     27   \brief Create a new World
     28   
     29   This creates a new empty world!
     30*/
    2731World::World () {
    2832  lastPlayer = null;
     33  lastNPC = null;
    2934}
    3035
     
    5762
    5863
     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
    59147
    60148/**
     
    63151   testing, testing, testing...
    64152*/
    65 void World::testThaTest()
     153void World::testThaTest(void)
    66154{
    67155  cout << "World::testThaTest() called" << endl;
     
    75163    }
    76164
     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
    77178  cout << "World::testThaTest() finished" << endl;
    78179}
    79 
    80 bool World::removePlayer(Player* player) {}
    81 
    82 bool World::addNPC(NPC* npc) {}
    83 bool World::removeNPC(NPC* npc) {}
  • orxonox/trunk/core/world.h

    r1856 r1858  
    3030    npcList* next;
    3131    NPC* npc;
     32    int number;
    3233  };
    33   npcList* firstNPC;
     34  npcList* lastNPC;
    3435
    3536  bool addPlayer(Player* player);
     
    3940  bool removeNPC(NPC* npc);
    4041
     42
     43  void drawWorld(void);
     44  void updateWorld(void);
    4145  void testThaTest(void);
    4246
Note: See TracChangeset for help on using the changeset viewer.