Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1872 in orxonox.OLD


Ignore:
Timestamp:
May 6, 2004, 10:50:39 PM (20 years ago)
Author:
patrick
Message:

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

Location:
orxonox/trunk/core
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/core/Makefile

    r1853 r1872  
    3939        npc.o \
    4040        player.o \
    41         world.o
     41        world.o \
     42        input_output.o
    4243
    4344TARGET = orxonox
  • orxonox/trunk/core/orxonox.cc

    r1859 r1872  
    2424*/
    2525
    26 
    27 
    28 
    29 
    30 
    3126/* class definition header */
    3227#include "orxonox.h"
    33 #include "data_tank.h"
    34 
    35 /* standard headers */
    36 #include <iostream>
    37 #include <cstdio>
    38 
    39 /* openGL Headers */
    40 #include <GL/glut.h>
     28
    4129
    4230using namespace std;
     
    4432
    4533
    46 Orxonox::Orxonox () {}
     34Orxonox::Orxonox ()
     35{
     36  pause = false;
     37}
    4738
    4839
     
    5344/* this is a singleton class to prevent dublicates */
    5445Orxonox* Orxonox::singleton_ref = 0;
     46World* Orxonox::world = 0;
     47InputOutput* Orxonox::io = 0;
     48bool Orxonox::pause = false;
     49
     50
    5551Orxonox* Orxonox::getInstance (void)
    5652{
     
    5955  return singleton_ref;
    6056}
    61 
    6257
    6358
     
    6964  glutInitWindowPosition(100, 100);
    7065  glutCreateWindow("orxOnox");
     66  glShadeModel(GL_FLAT);
    7167  /* window event dispatchers */
    7268  glutDisplayFunc(display);
    7369  glutReshapeFunc(reshape);
    7470  glutKeyboardFunc(keyboard);
     71}
     72
     73
     74int Orxonox::menuInit (void)
     75{
     76  glClearColor(0.0, 0.0, 0.0, 0.0);
     77}
     78
     79
     80int Orxonox::gameInit (void)
     81{
     82  glClearColor(0.0, 0.0, 0.0, 0.0);
     83  world = new World;
     84  Player* localPlayer = new Player;
     85  io = new InputOutput(world, localPlayer);
     86  (*world).addPlayer(localPlayer);
     87  //  (*localPlayer).addIO(io);
     88
    7589  glutSpecialFunc(specFunc);
    76 }
    77 
    78 
    79 
    80 int Orxonox::menuInit (void)
    81 {
    82   glClearColor(0.0, 0.0, 0.0, 0.0);
    83 }
    84 
    85 
    86 
    87 int Orxonox::gameInit (void)
    88 {
    89 
     90
     91  //for testing purps only
     92  //testTheShit();
    9093}
    9194
     
    9497{
    9598  switch(key) {
     99
     100  case 'p':
     101    if (pause)
     102      {
     103        cout << "unset pause" << endl;
     104        glutIdleFunc(continousRedraw);
     105        pause = false;
     106      }
     107    else
     108      {
     109        cout << "set pause" << endl;
     110        glutIdleFunc(NULL);
     111        pause = true;
     112      }
     113    break;
    96114  case 27:
    97115    exit(0);
     
    101119
    102120
     121/**
     122   \brief special keys function. called by glut
     123   
     124   Here are all special key function defined.
     125*/
    103126void Orxonox::specFunc(int key, int x, int y)
    104127{
     
    106129  case GLUT_KEY_UP:
    107130    cout << "key_up" << endl;
     131    (*io).goUp();
    108132    break;
    109133  case GLUT_KEY_DOWN:
    110134    cout << "key_down" << endl;
     135    (*io).goDown();
    111136    break;
    112137  case GLUT_KEY_RIGHT:
    113138    cout << "key_right" << endl;
     139    (*io).goRight();
    114140    break;
    115141  case GLUT_KEY_LEFT:
    116142    cout << "key_left" << endl;
     143    (*io).goLeft();
    117144    break;
    118145  }
     
    120147
    121148
    122 void Orxonox::display (void)
     149void Orxonox::display()
    123150{
    124151  glClear(GL_COLOR_BUFFER_BIT);
     152  (*world).drawWorld();
    125153  glutSwapBuffers();
    126154}
    127155
     156
     157void Orxonox::continousRedraw()
     158{
     159  glutPostRedisplay();
     160}
    128161
    129162
     
    139172
    140173
     174void Orxonox::testTheShit()
     175{
     176  Player* pl = new Player;
     177  (*pl).setPosition(1, 1, 1);
     178  (*world).addPlayer(pl);
     179 
     180  //NPC* nl = new NPC;
     181  //(*world).addNPC(nl);
     182  //(*world).addNPC(nl);
     183  //(*world).addNPC(nl);
     184  //(*world).addNPC(nl);
     185  //(*world).addNPC(nl);
     186  //(*world).addNPC(nl);
     187  //(*world).testThaTest();
     188}
     189
    141190
    142191int main (int argc, char** argv)
     
    144193  Orxonox *orx = Orxonox::getInstance();
    145194  (*orx).globalInit(argc, argv);
    146   (*orx).menuInit();
    147 
    148   World* wd = new World;
    149   Player* pl = new Player;
    150   (*wd).addPlayer(pl);
    151   (*wd).addPlayer(pl);
    152   (*wd).addPlayer(pl);
    153   (*wd).addPlayer(pl);
    154 
    155   NPC* nl = new NPC;
    156   (*wd).addNPC(nl);
    157   (*wd).addNPC(nl);
    158   (*wd).addNPC(nl);
    159   (*wd).addNPC(nl);
    160   (*wd).addNPC(nl);
    161   (*wd).addNPC(nl);
    162   (*wd).testThaTest();
     195  //(*orx).menuInit(); pb: directly jump to the game, no menu
     196  (*orx).gameInit();
    163197
    164198  glutMainLoop(); 
  • orxonox/trunk/core/orxonox.h

    r1859 r1872  
    11
    2 #include "world.h"
     2
    33
    44#ifndef ORXONOX_H
    55#define ORXONOX_H
    66
    7 #define NULL 0
     7/* standard headers */
     8#include <iostream>
     9#include <cstdio>
     10
     11/* openGL Headers */
     12#include <GL/glut.h>
     13
     14#include "world.h"
     15#include "input_output.h"
     16#include "data_tank.h"
     17#include "stdincl.h"
     18
     19
    820
    921class Orxonox {
    1022
    1123 private:
    12   static Orxonox *singleton_ref;
     24  static Orxonox* singleton_ref;
    1325  Orxonox ();
    1426  ~Orxonox ();
     27  static World* world;
     28  static InputOutput* io;
     29  static bool pause;
    1530
    1631 public:
     
    2136  int menuInit (void);
    2237  int gameInit (void);
     38  void testTheShit(void);
    2339  static void display (void);
     40  static void continousRedraw(void);
    2441  static void reshape (int w, int h);
    2542  static void keyboard(unsigned char key, int x, int y);
  • orxonox/trunk/core/player.cc

    r1858 r1872  
    1010   the Free Software Foundation; either version 2, or (at your option)
    1111   any later version.
     12
     13   ### File Specific:
     14   main-programmer: Patrick Boenzli
     15   co-programmer:
    1216*/
    1317
     
    1923
    2024
    21 Player::Player () {}
     25Player::Player () {
     26  xCor = yCor = zCor = 0;
     27}
    2228
    2329
     
    3137}
    3238
     39void Player::getPosition(int* x, int* y, int* z)
     40{
     41  *x = xCor; *y = yCor; *z = zCor;
     42}
     43
     44void Player::goX(int x)
     45{
     46  // (*player).goUp();
     47  xCor += x;
     48  cout << "goX now..." << endl;
     49}
     50
     51
     52void Player::goY(int y)
     53{
     54  yCor += y;
     55}
     56
     57void Player::goZ(int z)
     58{
     59  zCor += z;
     60}
     61
     62void Player::shoot(int n) {
     63}
     64
     65
     66//void Player::addIO(InputOutput *io) {}
     67
    3368
    3469void Player::drawPlayer(void)
    3570{
    36   cout << "Player::drawPlayer()" << endl;
     71  //cout << "Player::drawPlayer()" << endl;
     72  glColor3f(1.0, 0.9, 0.4);
     73  glRectf(-5.0 + yCor, -5.0 + xCor, 5.0 + yCor, 5.0 + xCor);
     74  cout << "x: " << xCor << " y: " << yCor << endl;
    3775}
  • orxonox/trunk/core/player.h

    r1858 r1872  
    33#define PLAYER_H
    44
     5/* openGL Headers */
     6#include <GL/glut.h>
     7
     8//#include "input_output.h"
    59
    610class Player {
     
    1216  void setPosition(int x, int y, int z);
    1317  void getPosition(int* x, int* y, int* z);
     18  void goX(int x);
     19  void goY(int y);
     20  void goZ(int x);
     21  void shoot(int n);
     22  //  void addIO(InputOutput *io);
    1423  void drawPlayer(void);
    1524
  • orxonox/trunk/core/world.cc

    r1858 r1872  
    7070bool World::removePlayer(Player* player) {
    7171  cout << "World::removeNPC not implemented yet" << endl;
     72}
     73
     74Player* World::getLocalPlayer()
     75{
     76  return localPlayer;
    7277}
    7378
  • orxonox/trunk/core/world.h

    r1858 r1872  
     1
     2
     3
     4#ifndef WORLD_H
     5#define WORLD_H
    16
    27#include "npc.h"
    38#include "player.h"
    49#include "stdincl.h"
    5 
    6 #ifndef WORLD_H
    7 #define WORLD_H
    8 
    910
    1011class World {
     
    1516
    1617  /* for easier use: map the first two player here */
     18  Player *localPlayer;
    1719  Player *player1;
    1820  Player *player2;
     
    3638  bool addPlayer(Player* player);
    3739  bool removePlayer(Player* player);
     40  Player* getLocalPlayer();
    3841
    3942  bool addNPC(NPC* npc);
Note: See TracChangeset for help on using the changeset viewer.