Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1875 in orxonox.OLD


Ignore:
Timestamp:
May 7, 2004, 10:49:55 AM (20 years ago)
Author:
patrick
Message:

/orxonox/trunk: it's smothen now. thanks for the tip bensch. if you have to high frame-rates, the square will move very fast.

Location:
orxonox/trunk/core
Files:
4 edited

Legend:

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

    r1872 r1875  
    5353void InputOutput::goLeft()
    5454{
    55   cout << "left";
    5655  (*player).goY(-BASE_STEP);
    5756}
     
    5958void InputOutput::goRight()
    6059{
    61   cout << "right";
    6260  (*player).goY(BASE_STEP);
    6361}
  • orxonox/trunk/core/orxonox.cc

    r1874 r1875  
    3939
    4040
    41 Orxonox::~Orxonox () {}
     41Orxonox::~Orxonox ()
     42{
     43  glutSetKeyRepeat(GLUT_KEY_REPEAT_ON);
     44}
    4245
    4346
     
    4750InputOutput* Orxonox::io = 0;
    4851bool Orxonox::pause = false;
    49 
     52bool Orxonox::upWeGo = false;
     53bool Orxonox::downWeGo = false;
     54bool Orxonox::rightWeGo = false;
     55bool Orxonox::leftWeGo = false;
    5056
    5157Orxonox* Orxonox::getInstance (void)
     
    8793  //  (*localPlayer).addIO(io);
    8894
     95  glutIgnoreKeyRepeat(1);                 /* for win32 */
     96  glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);  /* for linux X11 */
    8997  glutSpecialFunc(specFunc);
     98  glutSpecialUpFunc(releaseKey);
    9099
    91100  //for testing purps only
     
    114123    break;
    115124  case 27:
    116     exit(0);
     125    quitGame();
     126    break;
     127  }
     128}
     129
     130
     131void Orxonox::quitGame()
     132{
     133  glutSetKeyRepeat(GLUT_KEY_REPEAT_DEFAULT); /*do not remove or you will have
     134                                          no repeating keys anymore...*/
     135  cout << "finished garbage colletion, quitting..." << endl;
     136  exit(0);
     137}
     138
     139
     140void Orxonox::releaseKey(int key, int x, int y)
     141
     142  switch(key) {
     143  case GLUT_KEY_UP:
     144    upWeGo = false;
     145    break;
     146  case GLUT_KEY_DOWN:
     147    downWeGo = false;
     148    break;
     149  case GLUT_KEY_RIGHT:
     150    rightWeGo = false;
     151    break;
     152  case GLUT_KEY_LEFT:
     153    leftWeGo = false;
    117154    break;
    118155  }
     
    129166  switch(key) {
    130167  case GLUT_KEY_UP:
    131     cout << "key_up" << endl;
    132     (*io).goUp();
     168    upWeGo = true;
    133169    break;
    134170  case GLUT_KEY_DOWN:
    135     cout << "key_down" << endl;
    136     (*io).goDown();
     171    downWeGo = true;
    137172    break;
    138173  case GLUT_KEY_RIGHT:
    139     cout << "key_right" << endl;
    140     (*io).goRight();
     174    rightWeGo = true;
    141175    break;
    142176  case GLUT_KEY_LEFT:
    143     cout << "key_left" << endl;
    144     (*io).goLeft();
     177    leftWeGo = true;
    145178    break;
    146179  }
     
    158191void Orxonox::continousRedraw()
    159192{
     193  /* check for input to pass it over */
     194  if ( !pause && (rightWeGo || leftWeGo || upWeGo || downWeGo)) {
     195    if (upWeGo)
     196      (*io).goUp();
     197    if (downWeGo)
     198      (*io).goDown();
     199    if (rightWeGo)
     200      (*io).goRight();
     201    if (leftWeGo)
     202      (*io).goLeft();
     203  }
     204  /* request repaint */
    160205  glutPostRedisplay();
    161206}
  • orxonox/trunk/core/orxonox.h

    r1872 r1875  
    2828  static InputOutput* io;
    2929  static bool pause;
     30  static bool upWeGo;
     31  static bool downWeGo;
     32  static bool rightWeGo;
     33  static bool leftWeGo;
    3034
    3135 public:
     
    4145  static void reshape (int w, int h);
    4246  static void keyboard(unsigned char key, int x, int y);
     47  static void releaseKey(int key, int x, int y);
    4348  static void specFunc(int key, int x, int y);
     49  static void quitGame(void);
    4450};
    4551
  • orxonox/trunk/core/player.cc

    r1872 r1875  
    4444void Player::goX(int x)
    4545{
    46   // (*player).goUp();
    4746  xCor += x;
    48   cout << "goX now..." << endl;
    4947}
    5048
Note: See TracChangeset for help on using the changeset viewer.