Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 2036 in orxonox.OLD for orxonox/trunk


Ignore:
Timestamp:
Jun 27, 2004, 7:48:44 PM (20 years ago)
Author:
patrick
Message:

orxonxo/trunk/src: extended framework: class inheritance, right including (had som bugs), framework not finished yet

Location:
orxonox/trunk/src
Files:
6 added
19 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/Makefile.am

    r1959 r2036  
    66
    77bin_PROGRAMS=orxonox
    8 orxonox_SOURCES=orxonox.cc world.cc environment.cc player.cc npc.cc input_output.cc data_tank.cc ai.cc shoot_laser.cc shoot_rocket.cc
     8orxonox_SOURCES=orxonox.cc world.cc environment.cc player.cc npc.cc input_output.cc data_tank.cc ai.cc shoot_laser.cc shoot_rocket.cc world_entity.cc synchronisable.cc list.cc
    99
    1010#  uncomment the following if bencoder requires the math library
  • orxonox/trunk/src/Makefile.in

    r2018 r2036  
    117117#"-O3 -pedantic -fPIC -ffast-math -I/usr/X11R6/include"
    118118bin_PROGRAMS = orxonox
    119 orxonox_SOURCES = orxonox.cc world.cc environment.cc player.cc npc.cc input_output.cc data_tank.cc ai.cc shoot_laser.cc shoot_rocket.cc
     119orxonox_SOURCES = orxonox.cc world.cc environment.cc player.cc npc.cc input_output.cc data_tank.cc ai.cc shoot_laser.cc shoot_rocket.cc world_entity.cc synchronisable.cc list.cc
    120120subdir = src
    121121ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
     
    129129        environment.$(OBJEXT) player.$(OBJEXT) npc.$(OBJEXT) \
    130130        input_output.$(OBJEXT) data_tank.$(OBJEXT) ai.$(OBJEXT) \
    131         shoot_laser.$(OBJEXT) shoot_rocket.$(OBJEXT)
     131        shoot_laser.$(OBJEXT) shoot_rocket.$(OBJEXT) \
     132        world_entity.$(OBJEXT) synchronisable.$(OBJEXT) list.$(OBJEXT)
    132133orxonox_OBJECTS = $(am_orxonox_OBJECTS)
    133134orxonox_LDADD = $(LDADD)
     
    140141@AMDEP_TRUE@DEP_FILES = ./$(DEPDIR)/ai.Po ./$(DEPDIR)/data_tank.Po \
    141142@AMDEP_TRUE@    ./$(DEPDIR)/environment.Po \
    142 @AMDEP_TRUE@    ./$(DEPDIR)/input_output.Po ./$(DEPDIR)/npc.Po \
    143 @AMDEP_TRUE@    ./$(DEPDIR)/orxonox.Po ./$(DEPDIR)/player.Po \
    144 @AMDEP_TRUE@    ./$(DEPDIR)/shoot_laser.Po \
    145 @AMDEP_TRUE@    ./$(DEPDIR)/shoot_rocket.Po ./$(DEPDIR)/world.Po
     143@AMDEP_TRUE@    ./$(DEPDIR)/input_output.Po ./$(DEPDIR)/list.Po \
     144@AMDEP_TRUE@    ./$(DEPDIR)/npc.Po ./$(DEPDIR)/orxonox.Po \
     145@AMDEP_TRUE@    ./$(DEPDIR)/player.Po ./$(DEPDIR)/shoot_laser.Po \
     146@AMDEP_TRUE@    ./$(DEPDIR)/shoot_rocket.Po \
     147@AMDEP_TRUE@    ./$(DEPDIR)/synchronisable.Po ./$(DEPDIR)/world.Po \
     148@AMDEP_TRUE@    ./$(DEPDIR)/world_entity.Po
    146149CXXCOMPILE = $(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
    147150        $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CXXFLAGS) $(CXXFLAGS)
     
    200203@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/environment.Po@am__quote@
    201204@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/input_output.Po@am__quote@
     205@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/list.Po@am__quote@
    202206@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/npc.Po@am__quote@
    203207@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/orxonox.Po@am__quote@
     
    205209@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shoot_laser.Po@am__quote@
    206210@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/shoot_rocket.Po@am__quote@
     211@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/synchronisable.Po@am__quote@
    207212@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/world.Po@am__quote@
     213@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/world_entity.Po@am__quote@
    208214
    209215.cc.o:
  • orxonox/trunk/src/environment.cc

    r1956 r2036  
    1111   any later version.
    1212
    13    ### File Specific:
    14    main-programmer: ...
    15    co-programmer: ...
     13   ### File Specific
     14   main-programmer: Patrick Boenzli
     15   co-programmer:
    1616*/
    1717
     18#include <iostream>
     19#include <GL/glut.h>
     20#include <stdlib.h>
     21
     22#include "data_tank.h"
    1823
    1924#include "environment.h"
    20 #include <iostream>
    21 
    2225
    2326using namespace std;
    2427
    2528
     29//Sorry Bensch
     30#define LEVEL_LENGTH 500
    2631
    2732Environment::Environment ()
     33  : WorldEntity()
    2834{
    2935
    30 
    31   for (int x = 0; x < 10; x++)
     36  /*
     37  //Sorry Bensch: x,y = 10
     38  for (int x = 0; x < 50; x++)
    3239    {
    33       for (int y = 0; y < 10; y++)
     40      for (int y = 0; y < 50; y++)
    3441        {
    35           mountainTest[x][y] = 0;
     42          mountainTest[x][y] =0;
    3643                                                 
    3744        }
    3845    }
    39 
    40   for (int x = 1; x < 9; x++)
     46  //Sorry Bensch: x,y = 9
     47  for (int x = 1; x < LEVEL_LENGTH; x++)
    4148    {
    42       for (int y = 1; y < 9; y++)
     49      for (int y = 1; y < LEVEL_LENGTH; y++)
    4350        {
    44           mountainTest[x][y] = (float)rand() / 900000000;
    45                                                  
     51          //mountainTest[x][y] = (float)random() / 900000000;
     52          mountainTest[x][y] = (float)(random() % 4);                                       
    4653        }
    4754    }
     55  */
    4856}
    4957
     
    5361
    5462
    55 
    56 void Environment::drawEnvironment()
     63void Environment::paint()
    5764{
     65  /*
    5866  glPushMatrix();
    5967  //glScalef(0.5, 0.5, 1.0);
     
    6472 
    6573  glBegin(GL_LINES);
    66   for (int x = 0; x < 9; x += 1)
     74  for (int x = 0; x < LEVEL_LENGTH; x += 1)
    6775    {
    68       for (int y = 0; y < 9; y += 1)
     76      for (int y = 0; y < 190; y += 1)
    6977        {
    7078          glVertex3f((float)(2*x), (float)(2*y), mountainTest[x][y]);
     
    7684 
    7785  glBegin(GL_LINES);
    78   for (int y = 0; y < 9; y += 1)
     86  for (int y = 0; y < LEVEL_LENGTH; y += 1)
    7987    {
    80       for (int x = 0; x < 9; x += 1)
     88      for (int x = 0; x < 90; x += 1)
    8189        {
    8290          glVertex3f((float)(2*x), (float)(2*y), mountainTest[x][y]);
     
    8795 
    8896  glPopMatrix();
     97  */
    8998}
    9099
     100void Environment::drawEnvironment()
     101{
     102
     103}
     104
  • orxonox/trunk/src/environment.h

    r1956 r2036  
    11
    2 #include <GL/glut.h>
    3 #include <stdlib.h>
     2
    43
    54#ifndef ENVIRONEMENT_H
    65#define ENVIRONEMENT_H
    76
    8 #include "data_tank.h"
    97
    10 class Environment {
     8#include "world_entity.h"
     9
     10class Environment : public WorldEntity {
    1111
    1212 private:
     
    2121  ~Environment ();
    2222
     23  void paint(void);
    2324  void drawEnvironment(void);
    2425  void setEnvPosition(void);
  • orxonox/trunk/src/input_output.cc

    r1956 r2036  
    1616*/
    1717
     18#include <iostream>
     19
     20#include "world.h"
     21#include "input_output.h"
     22#include "player.h"
    1823
    1924#include "input_output.h"
    20 #include <iostream>
    2125
    2226using namespace std;
  • orxonox/trunk/src/input_output.h

    r1956 r2036  
    55#define INPUT_OUTPUT_H
    66
    7 #include "world.h"
    8 #include "input_output.h"
    9 #include "player.h"
     7
    108
    119#include "data_tank.h"
     10
     11class World;
     12class Player;
    1213
    1314class InputOutput {
  • orxonox/trunk/src/npc.cc

    r1956 r2036  
    1616*/
    1717
     18#include <iostream>
     19#include <GL/glut.h>
     20
     21#include "ai.h"
     22#include "data_tank.h"
    1823
    1924#include "npc.h"
    20 
    21 #include <iostream>
    22 
    2325
    2426using namespace std;
    2527
    2628
    27 NPC::NPC ()
     29NPC::NPC()
     30  : WorldEntity()
    2831{
    2932  hasDied = 0;
     
    5760
    5861void NPC::addAI(AI* ai)
     62{}
     63
     64void NPC::paint()
    5965{
    60 
    61 }
    62 
    63 void NPC::drawNPC(void)
    64 {
     66  //cout << "WorldEntity::WorldEntity();" << endl; 
    6567  /* fix: died flag approach is very stupid, just to show @ convention */
    6668  if( hasDied == 0 ) {
     
    7375}
    7476
     77void NPC::drawNPC()
     78{
     79
     80}
     81
    7582
    7683/* define the reaction, if the ship is been hit */
     
    8188}
    8289
     90
    8391void NPC::die()
    8492{
  • orxonox/trunk/src/npc.h

    r1956 r2036  
    33#define NPC_H
    44
    5 /* openGL Headers */
    6 #include <GL/glut.h>
     5#include "world_entity.h"
    76
    8 #include "ai.h"
    9 #include "data_tank.h"
     7class AI;
    108
    11 class NPC {
     9class NPC : public WorldEntity {
    1210
    1311 public:
     
    2321
    2422  void drawNPC(void);
     23  void paint(void);
    2524  void setPosition(float x, float y, float z);
    2625  void getPosition(float* x, float* y, float* z);
  • orxonox/trunk/src/orxonox.cc

    r1957 r2036  
    2424*/
    2525
    26 /* class definition header */
     26#include <iostream>
     27#include <cstdio>
     28#include <GL/glut.h>
     29
     30#include "environment.h"
     31#include "world.h"
     32#include "input_output.h"
     33#include "data_tank.h"
     34#include "stdincl.h"
     35#include "player.h"
     36#include "npc.h"
     37#include "shoot_laser.h"
     38
    2739#include "orxonox.h"
    2840
    29 
    3041using namespace std;
    3142
    3243
    33 
    3444Orxonox::Orxonox ()
    3545{
     
    4050
    4151Orxonox::~Orxonox ()
    42 {
    43   glutSetKeyRepeat(GLUT_KEY_REPEAT_ON);
    44 }
     52{}
    4553
    4654
     
    6371//int Orxonox::offsetY = 0;
    6472
     73
    6574Orxonox* Orxonox::getInstance (void)
    6675{
     
    7988  //glutFullScreen();
    8089  glutInitWindowPosition(100, 100);
    81   glutCreateWindow("orxOnox");
     90  glutCreateWindow("OrxonoX");
    8291  glShadeModel(GL_FLAT);
    8392  /* window event dispatchers */
     
    138147  io->setPlayerStep(19.2/fps); /* set player to propper speed */
    139148  localPlayer->shootLaser->setShootStep(20.0/fps); /* set shoot speed */
    140   localPlayer->shootRocket->setShootStep(20.0/fps); /* set shoot speed */
    141149  world->setWorldStep(7.0/fps); /* set the speed of the terrain moving away */
    142150  fps = 0;
  • orxonox/trunk/src/orxonox.h

    r1956 r2036  
    1 
    2 
    31
    42#ifndef ORXONOX_H
    53#define ORXONOX_H
    64
    7 /* standard headers */
    8 #include <iostream>
    9 #include <cstdio>
    10 
    11 /* openGL Headers */
    12 #include <GL/glut.h>
    13 
    14 
    15 #include "environment.h"
    16 #include "world.h"
    17 #include "input_output.h"
    18 #include "data_tank.h"
    19 #include "stdincl.h"
    20 #include "player.h"
     5class World;
     6class InputOutput;
     7class Player;
    218
    229
     
    4734
    4835 public:
    49 
    5036  static Orxonox* getInstance (void);
    5137
  • orxonox/trunk/src/player.cc

    r1957 r2036  
    1616*/
    1717
     18#include <iostream>
     19#include <stdlib.h>
     20#include <GL/glut.h>
     21
     22#include "shoot_laser.h"
     23#include "shoot_rocket.h"
     24#include "data_tank.h"
    1825
    1926#include "player.h"
    20 #include <iostream>
    21 #include <stdlib.h>
    22 
    2327
    2428using namespace std;
    2529
    2630
    27 Player::Player () {
    28   // cout << "Player::Player" << endl;
     31Player::Player()
     32   : WorldEntity() {
     33  //cout << "Player::Player" << endl;
    2934  xCor = yCor = zCor = 0;
    3035  shootLaser = new ShootLaser;
     
    5863void Player::goX(float x)
    5964{
    60   //cout << "Player::goX" << endl;
    6165  xCor += x;
    6266}
     
    7377}
    7478
     79
     80
    7581void Player::shoot(int n)
    7682{
     83
    7784  //  if (shootLaser->inhibitor++ <= 100)
    78     shootLaser->addShoot(xCor, yCor, zCor);
    79     // else if (shootLaser->inhibitor++ <= 200)
    80     shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);
    81     //  else if (shootLaser->inhibitor++ <= 300)
    82     shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);
    83     //  else
    84     shootLaser->inhibitor =0;
     85  shootLaser->addShoot(xCor, yCor, zCor);
     86  // else if (shootLaser->inhibitor++ <= 200)
     87  shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);
     88  //  else if (shootLaser->inhibitor++ <= 300)
     89  shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);
     90  //  else
     91  shootLaser->inhibitor =0;
    8592 
    86     //  if (shootRocket->inhibitor++ >=80)
    87     {
    88       shootRocket->addBackParable(xCor, yCor, zCor);
    89       shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT);
    90       shootRocket->addSideAcc(xCor, yCor, zCor, LEFT);
    91       shootRocket->addRotater(xCor, yCor, zCor);
    92       //  if (shootRocket->inhibitor >=90)
    93       //        shootRocket->inhibitor =0;
    94     }
     93  //  if (shootRocket->inhibitor++ >=80)
     94  {
     95    shootRocket->addBackParable(xCor, yCor, zCor);
     96    shootRocket->addSideAcc(xCor, yCor, zCor, RIGHT);
     97    shootRocket->addSideAcc(xCor, yCor, zCor, LEFT);
     98    shootRocket->addRotater(xCor, yCor, zCor);
     99    //  if (shootRocket->inhibitor >=90)
     100    //        shootRocket->inhibitor =0;
     101  }
    95102  //cout << "Player::shoot" << endl;
     103 
     104  /*
     105  shootLaser->addShoot(xCor, yCor, zCor);
     106  shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0);
     107  shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0);
     108  //shootRocket->addShoot(xCor, yCor, zCor);
     109  //cout << "Player::shoot" << endl;
     110  */
    96111}
    97112
     
    100115
    101116
    102 void Player::drawPlayer(void)
     117void Player::paint()
    103118{
     119  //cout << "Player::drawPlayer" << endl;
    104120  glPushMatrix();
    105121  glTranslatef(xCor, yCor, 3.0);
     
    110126  shootLaser->drawShoot();
    111127  shootRocket->drawShoot();
    112   //cout << "Player::drawPlayer" << endl;
     128  //cout << "Player::drawPlayer, end" << endl;
    113129}
    114130
  • orxonox/trunk/src/player.h

    r1956 r2036  
    33#define PLAYER_H
    44
    5 /* openGL Headers */
    6 #include <GL/glut.h>
     5#include "world_entity.h"
    76
    8 #include "shoot_laser.h"
    9 #include "shoot_rocket.h"
    10 #include "data_tank.h"
     7class ShootLaser;
     8class ShootRocket;
    119
    12 class Player {
     10
     11class Player : public WorldEntity
     12{
    1313
    1414 public:
     
    2323  float collisionRadius;
    2424
     25
    2526  /* this player wanna shoot? so include a ref to ShootLaser */
    2627  ShootLaser* shootLaser;
     
    3031  void getPosition(float* x, float* y, float* z);
    3132  void setCollisionRadius(float radius);
     33  void paint();
    3234  void goX(float x);
    3335  void goY(float y);
  • orxonox/trunk/src/proto_class.h

    r1956 r2036  
    44
    55#include "data_tank.h"
     6
    67
    78class ProtoClass {
  • orxonox/trunk/src/shoot_laser.cc

    r1956 r2036  
    1717
    1818
    19 #include "shoot_laser.h"
    2019
     20
     21#include <GL/glut.h>
    2122#include <iostream>
    2223
     24#include "stdincl.h"
     25#include "data_tank.h"
     26
     27#include "shoot_laser.h"
    2328
    2429using namespace std;
     
    134139  cout << "ShootLaser::setShootStep to " << step << endl;
    135140  this->step = step;
     141  cout << "ShootLaser::setShootStep end " << step << endl;
    136142}
    137143
  • orxonox/trunk/src/shoot_laser.h

    r1956 r2036  
    33#define SHOOT_LASER_H
    44
    5 /* openGL Headers */
    6 #include <GL/glut.h>
    7 
    8 #include "stdincl.h"
    9 #include "data_tank.h"
    105
    116class ShootLaser {
    12 
    137
    148 public:
  • orxonox/trunk/src/shoot_rocket.cc

    r1957 r2036  
    1717
    1818
     19#include <iostream>
     20#include <math.h>
     21#include <GL/glut.h>
     22
     23#include "stdincl.h"
     24#include "data_tank.h"
     25#include "npc.h"
     26
    1927#include "shoot_rocket.h"
    20 
    21 #include <iostream>
    22 
    2328
    2429using namespace std;
  • orxonox/trunk/src/shoot_rocket.h

    r1957 r2036  
    33#define SHOOT_ROCKET_H
    44
    5 /* openGL Headers */
    6 #include <GL/glut.h>
    7 #include <math.h>
    85
    9 #include "stdincl.h"
    10 #include "data_tank.h"
    11 #include "npc.h"
    126
    137enum RocketType { HOMING, SIDEACC, BACKPARABLE, ROTATER};
    148enum RocketDirection {LEFT, RIGHT, UP, DOWN};
    159
     10
    1611class ShootRocket {
    17 
    1812
    1913 public:
  • orxonox/trunk/src/world.cc

    r1956 r2036  
    1515*/
    1616
     17#include <iostream>
     18#include <stdlib.h>
     19#include <cmath>
     20#include <GL/glut.h>
     21
     22#include "npc.h"
     23#include "player.h"
     24#include "environment.h"
     25#include "shoot_laser.h"
     26#include "shoot_rocket.h"
     27#include "stdincl.h"
     28#include "data_tank.h"
    1729
    1830#include "world.h"
    1931
    20 #include <iostream>
    2132
    2233using namespace std;
     
    174185void World::drawWorld(void)
    175186{
     187
    176188  glLoadIdentity();
    177189  gluLookAt(0.0, -14.0 + DataTank::yOffset, 15.0, 0.0, 0.0 + DataTank::yOffset, 0.0, 0.0, 1.0, 0.0);
     
    181193  while( tmpPlayer != null )
    182194    {
    183       (*tmpPlayer->player).drawPlayer();
     195      tmpPlayer->player->paint();
    184196      tmpPlayer = tmpPlayer->next;
    185197    }
     
    188200  while( tmpNPC != null )
    189201    {
    190       (*tmpNPC->npc).drawNPC();
     202      (*tmpNPC->npc).paint();
    191203      tmpNPC = tmpNPC->next;
    192204    }
     
    235247    }
    236248
    237  
     249
    238250}
    239251
     
    254266void World::setWorldStep(float step)
    255267{
     268  //cout << "World::setWorldStep(" << step << ");" << endl;
    256269  this->step = step;
    257   cout << "setting speed to " << step << endl;
     270  //cout << "setting speed to " << step << endl;
    258271}
    259272
  • orxonox/trunk/src/world.h

    r1956 r2036  
    1 
    2 
    31
    42#ifndef WORLD_H
    53#define WORLD_H
    64
    7 #include <stdlib.h>
    8 #include <cmath>
     5class Player;
     6class NPC;
     7class Environment;
    98
    10 #include "npc.h"
    11 #include "player.h"
    12 #include "environment.h"
    13 #include "shoot_laser.h"
    14 #include "shoot_rocket.h"
    15 #include "stdincl.h"
    16 #include "data_tank.h"
    179
    1810class World {
Note: See TracChangeset for help on using the changeset viewer.