Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1872 in orxonox.OLD for orxonox/trunk/core/orxonox.cc


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

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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(); 
Note: See TracChangeset for help on using the changeset viewer.