Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1896 in orxonox.OLD for orxonox


Ignore:
Timestamp:
May 20, 2004, 1:01:57 AM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: added ability to shoot. so check out the new release and shoot the fuck up

Location:
orxonox/trunk
Files:
2 added
16 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/README

    r1856 r1896  
    20201) Alien is a great film
    21212) Guiness is the most delicious beer
     223) If you think there is anything missing: you can be shure it's an arcade game
    2223
    2324to be continoued...
  • orxonox/trunk/ToDo

    r1853 r1896  
     1
     2
     3
     4orxonox:
     5--------
     6
     7- perspective change: smooth glide back in zero mode (pb)
    18
    29
  • orxonox/trunk/core/Makefile

    r1883 r1896  
    4141        world.o \
    4242        input_output.o \
    43         environment.o
     43        environment.o \
     44        shoot_laser.o
    4445
    4546TARGET = orxonox
  • orxonox/trunk/core/environment.cc

    r1883 r1896  
    3535                                                 
    3636        }
    37     }
    38 
    39  for (int x = 0; x < 10; x++)
    40     {
    41       for (int y = 0; y < 10; y++)
    42         {
    43           cout << " " << mountainTest[x][y] << " ";
    44          
    45         }
    46       cout << endl;
    4737    }
    4838}
  • orxonox/trunk/core/environment.h

    r1883 r1896  
    33#include <stdlib.h>
    44
    5 #ifndef PROTO_CLASS_H
    6 #define PROTO_CLASS_H
     5#ifndef ENVIRONEMENT_H
     6#define ENVIRONEMENT_H
    77
    88
  • orxonox/trunk/core/input_output.cc

    r1879 r1896  
    4343void InputOutput::goUp()
    4444{
     45  //cout << "InoutOutput::goUp" << endl;
    4546  (*player).goY(STEP_FRONT);
    4647}
  • orxonox/trunk/core/input_output.h

    r1879 r1896  
    1010
    1111#define STEP_SIDE 0.4
    12 #define STEP_FRONT 0.2
     12#define STEP_FRONT 0.4
    1313
    1414class InputOutput {
  • orxonox/trunk/core/npc.cc

    r1858 r1896  
    2121#include <iostream>
    2222
     23
    2324using namespace std;
    2425
    2526
    2627NPC::NPC () {}
    27 
    28 
    2928
    3029NPC::~NPC () {}
     
    4342}
    4443
     44void NPC::setCollisionRadius(int r)
     45{
     46  collisionRadius = r;
     47}
     48
     49float NPC::getCollisionRadius()
     50{
     51  return collisionRadius;
     52}
     53
     54
    4555
    4656void NPC::drawNPC(void)
  • orxonox/trunk/core/npc.h

    r1858 r1896  
    1313  void setPosition(int x, int y, int z);
    1414  void getPosition(int* x, int* y, int* z);
     15  void setCollisionRadius(int r);
     16  float getCollisionRadius();
    1517
    1618 private:
     
    1820
    1921  int npcType;
     22
     23  /* collision control */
     24  int collisionRadius;
    2025
    2126  int xCor;
  • orxonox/trunk/core/orxonox.cc

    r1883 r1896  
    2626/* class definition header */
    2727#include "orxonox.h"
    28 #include "environment.h"
    2928
    3029
     
    5049World* Orxonox::world = 0;
    5150InputOutput* Orxonox::io = 0;
     51Player* Orxonox::localPlayer = 0;
    5252bool Orxonox::pause = false;
    5353bool Orxonox::upWeGo = false;
     
    5555bool Orxonox::rightWeGo = false;
    5656bool Orxonox::leftWeGo = false;
     57bool Orxonox::shoot1 = false;
    5758int Orxonox::alpha = 0;
    5859int Orxonox::beta = 0;
     
    8283  glutReshapeFunc(reshape);
    8384  glutKeyboardFunc(keyboard);
     85  glutKeyboardUpFunc(upKeyboard);
    8486}
    8587
     
    9698  world = new World;
    9799  (*world).initEnvironement();
    98   Player* localPlayer = new Player;
     100  localPlayer = new Player;
    99101  io = new InputOutput(world, localPlayer);
    100102  (*world).addPlayer(localPlayer);
    101103  Environment *env = new Environment;
    102104  (*world).addEnv(env);
    103  
    104105
    105106  glutSpecialFunc(specFunc);
    106107  glutSpecialUpFunc(releaseKey);
    107108
    108   //for testing purps only
    109   //testTheShit();
    110109  glutIdleFunc(continousRedraw);
     110  //cout << "Orxonox::gameInit" << endl;
    111111}
    112112
     
    131131
    132132    /* game controls */
    133 
    134133  case 'p':
    135134    if (pause)
     
    146145      }
    147146    break;
     147  case 32:
     148    shoot1 = true;
     149    break;
    148150  case 27:
    149151  case 'q':
     
    154156
    155157
     158void Orxonox::upKeyboard(unsigned char key, int x, int y)
     159{
     160  switch(key) {
     161  case 32:
     162    shoot1 = false;
     163    break;
     164  }
     165}
     166
     167
    156168void Orxonox::quitGame()
    157169{
    158   //glutIgnoreKeyRepeat(0);                 /* for win32 */
    159   //glutSetKeyRepeat(GLUT_KEY_REPEAT_DEFAULT); /*do not remove or you will have
    160   //                                      no repeating keys anymore...*/
    161   cout << "finished garbage colletion, quitting..." << endl;
     170  //cout << "finished garbage colletion, quitting..." << endl;
    162171  exit(0);
    163172}
     
    191200{
    192201  switch(key) {
    193 
    194202    /* spacecraft controls */
    195    
    196203  case GLUT_KEY_UP:
    197204    upWeGo = true;
     
    226233{
    227234  /* check for input to pass it over */
    228   if ( !pause && (rightWeGo || leftWeGo || upWeGo || downWeGo)) {
     235  if ( !pause && (rightWeGo || leftWeGo || upWeGo || downWeGo || shoot1)) {
    229236    if (upWeGo)
    230237      (*io).goUp();
     
    235242    if (leftWeGo)
    236243      (*io).goLeft();
     244    if (shoot1)
     245      (*io).shoot();
    237246  }
    238247  /* request repaint */
    239 
    240   //cout << "contiousRedraw" << endl;
    241248  glutPostRedisplay();
     249  //cout << "Orxonox::continousRedraw" << endl;
    242250}
    243251
     
    248256  glMatrixMode(GL_PROJECTION);
    249257  glLoadIdentity();
    250   //glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); pb: //simple and working
    251258  glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 200.0);
    252   //glFrustum(-10.0, 10.0, -5.0, 10.0, 0.0, 100.0);
    253259  glMatrixMode(GL_MODELVIEW);
    254260  glLoadIdentity(); //pb why a second time?
  • orxonox/trunk/core/orxonox.h

    r1879 r1896  
    1212#include <GL/glut.h>
    1313
     14
     15#include "environment.h"
    1416#include "world.h"
    1517#include "input_output.h"
    1618#include "data_tank.h"
    1719#include "stdincl.h"
    18 
     20#include "player.h"
    1921
    2022
     
    2729  static World* world;
    2830  static InputOutput* io;
     31  static Player* localPlayer;
    2932  static bool pause;
    3033  static bool upWeGo;
     
    3235  static bool rightWeGo;
    3336  static bool leftWeGo;
     37  static bool shoot1;
    3438
    3539  static int alpha;
     
    5054  static void reshape (int w, int h);
    5155  static void keyboard(unsigned char key, int x, int y);
     56  static void upKeyboard(unsigned char key, int x, int y);
    5257  static void releaseKey(int key, int x, int y);
    5358  static void specFunc(int key, int x, int y);
  • orxonox/trunk/core/player.cc

    r1883 r1896  
    2020#include <iostream>
    2121
     22
    2223using namespace std;
    2324
     
    2526Player::Player () {
    2627  xCor = yCor = zCor = 0;
     28  shootLaser = new ShootLaser;
    2729}
    2830
    29 
    30 
    31 Player::~Player () {}
     31Player::~Player ()
     32{
     33  //delete shootLaser;
     34}
    3235
    3336
     
    3740}
    3841
    39 void Player::getPosition(float* x, float* y, float* z)
     42
     43void Player::getPosition(float* x, float* y, float* z)
    4044{
    4145  *x = xCor; *y = yCor; *z = zCor;
     
    4448void Player::goX(float x)
    4549{
     50  //cout << "Player::goX" << endl;
    4651  xCor += x;
    4752}
     
    5863}
    5964
    60 void Player::shoot(int n) {
     65void Player::shoot(int n)
     66{
     67  shootLaser->addShoot(xCor, yCor, zCor);
     68  //cout << "Player::shoot" << endl;
    6169}
    6270
     
    6775void Player::drawPlayer(void)
    6876{
    69   //cout << "Player::drawPlayer()" << endl;
    70   //glColor3f(0.0, 0.9, 0.7);
    71   //glRectf(-0.5 + yCor, -0.5 + xCor, 0.5 + yCor, 2.0 + xCor);
    72 
    7377  glPushMatrix();
     78  glTranslatef(xCor, yCor, 3.0);
    7479  glScalef(1.0, 3.0, 1.0);
    75   glTranslatef(xCor, yCor, 3.0);
    7680  glutWireCube(1.0);
    7781  glPopMatrix();
     82  /* draw all the shoots additionaly */
     83  shootLaser->drawShoot();
     84  //cout << "Player::drawPlayer" << endl;
     85}
    7886
    7987
    80   //cout << "x: " << xCor << " y: " << yCor << endl;
    81 }
     88
     89
     90
     91
     92
     93
     94
     95
     96
     97
     98
     99
     100
     101
     102
     103
     104
     105
     106
     107
     108
     109
     110
     111
  • orxonox/trunk/core/player.h

    r1879 r1896  
    66#include <GL/glut.h>
    77
    8 //#include "input_output.h"
     8#include "shoot_laser.h"
     9//#include "world.h"
    910
    1011class Player {
     
    2425
    2526 private:
    26   /* position of the space craft */
     27  /* position of the spacecraft */
    2728  float xCor;
    2829  float yCor;
     
    3031
    3132
    32 
     33  /* this player wanna shoot? so include a ref to ShootLaser */
     34  ShootLaser* shootLaser;
    3335};
    3436
  • orxonox/trunk/core/world.cc

    r1883 r1896  
    3333  lastNPC = null;
    3434  lastEnv = null;
     35  lastShoot = null;
    3536}
    3637
     
    128129
    129130/**
    130    \brief Remove Non-Player-Character
     131   \brief Add environmental object
     132   \param player A reference to the new env object
     133   
     134   Add a new Environment to the world. Env has to be initialised before.
     135*/
     136bool World::addShoot(ShootLaser* shoot)
     137{
     138  shootList* listMember = new shootList;
     139  listMember->shoot = shoot;
     140  if ( lastShoot != null )
     141    {
     142      listMember->number = lastShoot->number + 1;
     143      listMember->next = lastShoot;
     144    }
     145  else
     146    {
     147      listMember->number = 0;
     148      listMember->next = null;
     149    }
     150  lastShoot = listMember;
     151}
     152
     153
     154/**
     155   \brief Remove Non-Player Character
    131156   \param player A reference to the new npc object
    132157   
     
    162187    }
    163188  /* now draw the rest of the world: environement */
    164   /* second draw all npcs */
    165189  envList* tmpEnv = lastEnv;
    166190  while( tmpEnv != null )
     
    169193      tmpEnv = tmpEnv->next;
    170194    }
    171 
    172   /*
    173   glColor3f(0.0, 1.0, 0.0);
    174   glBegin(GL_LINES);
    175   for (int x = 0; x <= 35; x += 5)
    176     {
    177       glVertex3f((float)x, -10.0, 0.0);
    178       glVertex3f((float)x, 200.0, 0.0);
    179 
    180       glVertex3f(-(float)x, -10.0, 0.0);
    181       glVertex3f(-(float)x, 200.0, 0.0);
    182     }
    183   for (int x = -10; x<= 200; x += 5)
    184     {
    185       glVertex3f(-50.0, (float)x, 0.0);
    186       glVertex3f(50.0, (float)x, 0.0);
    187     }
    188   glEnd();
    189   */
    190  
     195  /* now draw all the shoots (many) */
     196  shootList* tmpShoot = lastShoot;
     197  while( tmpShoot != null )
     198    {
     199      (*tmpShoot->shoot).drawShoot();
     200      tmpShoot = tmpShoot->next;
     201    }
    191202 
    192203  glColor3f(0.0, 1.0, 0.0);
  • orxonox/trunk/core/world.h

    r1883 r1896  
    1010#include "player.h"
    1111#include "environment.h"
     12#include "shoot_laser.h"
    1213#include "stdincl.h"
    1314
     
    4748  envList* lastEnv;
    4849
     50  /* a list of all shoot-amental objects */
     51  struct shootList {
     52    shootList* next;
     53    ShootLaser* shoot;
     54    int number;
     55  };
     56  shootList* lastShoot;
     57
     58
    4959  bool addPlayer(Player* player);
    5060  bool removePlayer(Player* player);
    5161  Player* getLocalPlayer();
    52 
    5362  bool addNPC(NPC* npc);
    5463  bool removeNPC(NPC* npc);
    55 
    5664  bool addEnv(Environment* env);
     65  bool addShoot(ShootLaser* shoot);
    5766
    5867  void drawWorld(void);
  • orxonox/trunk/gui/Makefile

    r1864 r1896  
    7474clean:
    7575        rm -rf *.o *~
    76         rm $(TARGET)
     76        rm -f $(TARGET)
    7777
    7878####compile
Note: See TracChangeset for help on using the changeset viewer.