Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 1879 in orxonox.OLD


Ignore:
Timestamp:
May 8, 2004, 1:12:33 PM (20 years ago)
Author:
patrick
Message:

orxonox/trunk: perspective view, key-repeat bug fixed

Location:
orxonox/trunk
Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/core/Makefile

    r1872 r1879  
    5151
    5252.cc.o:
    53         @ echo "$@ wird kompiliert..."
     53        @ echo "$@ is being compiled..."
    5454        @ $(CXX) -c $(CFLAGS) -I$(INCDIR) -o $@ $<
    5555
     
    6060
    6161$(TARGET): $(OBJECTS)
    62         @ echo "orxonox wird gelinkt..."
     62        @ echo "orxonox is being linked..."
    6363        @ $(CXX) $(LIBS) -o $(TARGET) $(OBJECTS)
    6464
     
    7474       
    7575clean:
    76         rm -rf *.o *~
     76        rm -rf *.o *~ orxonox
    7777
    7878
  • orxonox/trunk/core/input_output.cc

    r1875 r1879  
    4343void InputOutput::goUp()
    4444{
    45   (*player).goX(BASE_STEP);
     45  (*player).goY(STEP_FRONT);
    4646}
    4747
    4848void InputOutput::goDown()
    4949{
    50   (*player).goX(-BASE_STEP);
     50  (*player).goY(-STEP_FRONT);
    5151}
    5252
    5353void InputOutput::goLeft()
    5454{
    55   (*player).goY(-BASE_STEP);
     55  (*player).goX(-STEP_SIDE);
     56
    5657}
    5758
    5859void InputOutput::goRight()
    5960{
    60   (*player).goY(BASE_STEP);
     61
     62  (*player).goX(STEP_SIDE);
    6163}
    6264
    6365void InputOutput::shoot()
    6466{
    65   (*player).shoot(BASE_STEP);
     67  (*player).shoot(1);
    6668}
  • orxonox/trunk/core/input_output.h

    r1873 r1879  
    99#include "player.h"
    1010
    11 #define BASE_STEP 2
     11#define STEP_SIDE 0.4
     12#define STEP_FRONT 0.2
    1213
    1314class InputOutput {
  • orxonox/trunk/core/orxonox.cc

    r1875 r1879  
    5454bool Orxonox::rightWeGo = false;
    5555bool Orxonox::leftWeGo = false;
     56int Orxonox::alpha = 0;
     57int Orxonox::beta = 0;
     58//int Orxonox::offsetX = 0;
     59//int Orxonox::offsetY = 0;
    5660
    5761Orxonox* Orxonox::getInstance (void)
     
    6872  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB);
    6973  glutInitWindowSize(500, 500);
     74  //glutFullScreen();
    7075  glutInitWindowPosition(100, 100);
    7176  glutCreateWindow("orxOnox");
     
    9398  //  (*localPlayer).addIO(io);
    9499
    95   glutIgnoreKeyRepeat(1);                 /* for win32 */
    96   glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);  /* for linux X11 */
     100  //glutIgnoreKeyRepeat(1);                 /* for win32 */
     101  //glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);  /* for linux X11 */
    97102  glutSpecialFunc(specFunc);
    98103  glutSpecialUpFunc(releaseKey);
     
    107112{
    108113  switch(key) {
     114
     115    /* perspectiv control */
     116  case 'w':
     117    beta -= 1;
     118    break;
     119  case 's':
     120    beta += 1;
     121    break;
     122  case 'a':
     123    alpha -= 1;
     124    break;
     125  case 'd':
     126    alpha += 1;
     127    break;
     128
     129    /* game controls */
    109130
    110131  case 'p':
     
    131152void Orxonox::quitGame()
    132153{
    133   glutSetKeyRepeat(GLUT_KEY_REPEAT_DEFAULT); /*do not remove or you will have
    134                                           no repeating keys anymore...*/
     154  //glutIgnoreKeyRepeat(0);                 /* for win32 */
     155  //glutSetKeyRepeat(GLUT_KEY_REPEAT_DEFAULT); /*do not remove or you will have
     156  //                                      no repeating keys anymore...*/
    135157  cout << "finished garbage colletion, quitting..." << endl;
    136158  exit(0);
     
    165187{
    166188  switch(key) {
     189
     190    /* spacecraft controls */
     191   
    167192  case GLUT_KEY_UP:
    168193    upWeGo = true;
     
    184209{
    185210  glClear(GL_COLOR_BUFFER_BIT);
     211
     212  glColor3f(0.0, 0.5, 0.6);
     213  glLoadIdentity();
     214  gluLookAt(0.0, -14.0, 15.0, 0.0 + alpha, 0.0 + beta, 0.0, 0.0, 1.0, 0.0);
    186215  (*world).drawWorld();
     216
    187217  glutSwapBuffers();
    188218}
     
    203233  }
    204234  /* request repaint */
     235
     236  //cout << "contiousRedraw" << endl;
    205237  glutPostRedisplay();
    206238}
     
    212244  glMatrixMode(GL_PROJECTION);
    213245  glLoadIdentity();
    214   glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0);
     246  //glOrtho(-50.0, 50.0, -50.0, 50.0, -1.0, 1.0); pb: //simple and working
     247  glFrustum(-1.0, 1.0, -1.0, 1.0, 1.5, 200.0);
     248  //glFrustum(-10.0, 10.0, -5.0, 10.0, 0.0, 100.0);
    215249  glMatrixMode(GL_MODELVIEW);
    216250  glLoadIdentity(); //pb why a second time?
     
    220254void Orxonox::testTheShit()
    221255{
    222   Player* pl = new Player;
    223   (*pl).setPosition(1, 1, 1);
    224   (*world).addPlayer(pl);
     256  //Player* pl = new Player;
     257  //(*pl).setPosition(1, 1, 1);
     258  //(*world).addPlayer(pl);
    225259 
    226260  //NPC* nl = new NPC;
  • orxonox/trunk/core/orxonox.h

    r1875 r1879  
    3333  static bool leftWeGo;
    3434
     35  static int alpha;
     36  static int beta;
     37  static int offsetX;
     38  static int offsetY;
     39
    3540 public:
    3641
  • orxonox/trunk/core/player.cc

    r1875 r1879  
    3232
    3333
    34 void Player::setPosition( int x, int y, int z)
     34void Player::setPosition( float x, float y, float z)
    3535{
    3636  xCor = x; yCor = y; zCor = z;
    3737}
    3838
    39 void Player::getPosition(int* x, int* y, int* z)
     39void Player::getPosition(float* x, float* y, float* z)
    4040{
    4141  *x = xCor; *y = yCor; *z = zCor;
    4242}
    4343
    44 void Player::goX(int x)
     44void Player::goX(float x)
    4545{
    4646  xCor += x;
     
    4848
    4949
    50 void Player::goY(int y)
     50void Player::goY(float y)
    5151{
    5252  yCor += y;
    5353}
    5454
    55 void Player::goZ(int z)
     55void Player::goZ(float z)
    5656{
    5757  zCor += z;
     
    6868{
    6969  //cout << "Player::drawPlayer()" << endl;
    70   glColor3f(1.0, 0.9, 0.4);
    71   glRectf(-5.0 + yCor, -5.0 + xCor, 5.0 + yCor, 5.0 + xCor);
     70  //glColor3f(0.0, 0.9, 0.7);
     71  //glRectf(-0.5 + yCor, -0.5 + xCor, 0.5 + yCor, 2.0 + xCor);
     72
     73  glPushMatrix();
     74  glScalef(1.0, 3.0, 1.0);
     75  glTranslatef(xCor, yCor, 3.0);
     76  glutWireCube(1.0);
     77  glPopMatrix();
     78
     79
    7280  cout << "x: " << xCor << " y: " << yCor << endl;
    7381}
  • orxonox/trunk/core/player.h

    r1872 r1879  
    1414  ~Player ();
    1515
    16   void setPosition(int x, int y, int z);
    17   void getPosition(int* x, int* y, int* z);
    18   void goX(int x);
    19   void goY(int y);
    20   void goZ(int x);
     16  void setPosition(float x, float y, float z);
     17  void getPosition(float* x, float* y, float* z);
     18  void goX(float x);
     19  void goY(float y);
     20  void goZ(float x);
    2121  void shoot(int n);
    2222  //  void addIO(InputOutput *io);
     
    2525 private:
    2626  /* position of the space craft */
    27   int xCor;
    28   int yCor;
    29   int zCor;
     27  float xCor;
     28  float yCor;
     29  float zCor;
    3030
    3131
  • orxonox/trunk/core/world.cc

    r1872 r1879  
    117117   \brief Draws the World and all Objects contained
    118118   
    119    Calls the draw function of all: Objects, Players, Environement
     119   Calls the draw function of all: Objects, Players, Environement. This is the core of all graphics here.
    120120*/
    121121void World::drawWorld(void)
    122122{
     123  /* first draw all players */
    123124  playerList* tmpPlayer = lastPlayer;
    124125  Player* player = tmpPlayer->player;
     
    128129      tmpPlayer = tmpPlayer->next;
    129130    }
     131  /* second draw all npcs */
    130132  npcList* tmpNPC = lastNPC;
    131133  while( tmpNPC != null )
     
    134136      tmpNPC = tmpNPC->next;
    135137    }
     138  /* now draw the rest of the world: environement */
     139  glColor3f(0.0, 1.0, 0.0);
     140  glBegin(GL_LINES);
     141  glVertex3f(0.0, -10.0, 0.0);
     142  glVertex3f(0.0, 200.0, 0.0);
     143
     144  glVertex3f(5.0, -10.0, 0.0);
     145  glVertex3f(5.0, 200.0, 0.0);
     146
     147  glVertex3f(-5.0, -10.0, 0.0);
     148  glVertex3f(-5.0, 200.0, 0.0);
     149
     150  glVertex3f(10.0, -10.0, 0.0);
     151  glVertex3f(10.0, 200.0, 0.0);
     152
     153  glVertex3f(-10.0, -10.0, 0.0);
     154  glVertex3f(-10.0, 200.0, 0.0);
     155
     156  glVertex3f(15.0, -10.0, 0.0);
     157  glVertex3f(15.0, 200.0, 0.0);
     158
     159  glVertex3f(-15.0, -10.0, 0.0);
     160  glVertex3f(-15.0, 200.0, 0.0);
     161
     162  glVertex3f(20.0, -10.0, 0.0);
     163  glVertex3f(20.0, 200.0, 0.0);
     164
     165  glVertex3f(-20.0, -10.0, 0.0);
     166  glVertex3f(-20.0, 200.0, 0.0);
     167
     168  glVertex3f(25.0, -10.0, 0.0);
     169  glVertex3f(25.0, 200.0, 0.0);
     170
     171  glVertex3f(-25.0, -10.0, 0.0);
     172  glVertex3f(-25.0, 200.0, 0.0);
     173  glEnd();
     174
     175
    136176}
    137177
Note: See TracChangeset for help on using the changeset viewer.