- Timestamp:
- May 6, 2004, 10:50:39 PM (21 years ago)
- Location:
- orxonox/trunk/core
- Files:
-
- 2 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/core/Makefile
r1853 r1872 39 39 npc.o \ 40 40 player.o \ 41 world.o 41 world.o \ 42 input_output.o 42 43 43 44 TARGET = orxonox -
orxonox/trunk/core/orxonox.cc
r1859 r1872 24 24 */ 25 25 26 27 28 29 30 31 26 /* class definition header */ 32 27 #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 41 29 42 30 using namespace std; … … 44 32 45 33 46 Orxonox::Orxonox () {} 34 Orxonox::Orxonox () 35 { 36 pause = false; 37 } 47 38 48 39 … … 53 44 /* this is a singleton class to prevent dublicates */ 54 45 Orxonox* Orxonox::singleton_ref = 0; 46 World* Orxonox::world = 0; 47 InputOutput* Orxonox::io = 0; 48 bool Orxonox::pause = false; 49 50 55 51 Orxonox* Orxonox::getInstance (void) 56 52 { … … 59 55 return singleton_ref; 60 56 } 61 62 57 63 58 … … 69 64 glutInitWindowPosition(100, 100); 70 65 glutCreateWindow("orxOnox"); 66 glShadeModel(GL_FLAT); 71 67 /* window event dispatchers */ 72 68 glutDisplayFunc(display); 73 69 glutReshapeFunc(reshape); 74 70 glutKeyboardFunc(keyboard); 71 } 72 73 74 int Orxonox::menuInit (void) 75 { 76 glClearColor(0.0, 0.0, 0.0, 0.0); 77 } 78 79 80 int 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 75 89 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(); 90 93 } 91 94 … … 94 97 { 95 98 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; 96 114 case 27: 97 115 exit(0); … … 101 119 102 120 121 /** 122 \brief special keys function. called by glut 123 124 Here are all special key function defined. 125 */ 103 126 void Orxonox::specFunc(int key, int x, int y) 104 127 { … … 106 129 case GLUT_KEY_UP: 107 130 cout << "key_up" << endl; 131 (*io).goUp(); 108 132 break; 109 133 case GLUT_KEY_DOWN: 110 134 cout << "key_down" << endl; 135 (*io).goDown(); 111 136 break; 112 137 case GLUT_KEY_RIGHT: 113 138 cout << "key_right" << endl; 139 (*io).goRight(); 114 140 break; 115 141 case GLUT_KEY_LEFT: 116 142 cout << "key_left" << endl; 143 (*io).goLeft(); 117 144 break; 118 145 } … … 120 147 121 148 122 void Orxonox::display (void)149 void Orxonox::display() 123 150 { 124 151 glClear(GL_COLOR_BUFFER_BIT); 152 (*world).drawWorld(); 125 153 glutSwapBuffers(); 126 154 } 127 155 156 157 void Orxonox::continousRedraw() 158 { 159 glutPostRedisplay(); 160 } 128 161 129 162 … … 139 172 140 173 174 void 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 141 190 142 191 int main (int argc, char** argv) … … 144 193 Orxonox *orx = Orxonox::getInstance(); 145 194 (*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(); 163 197 164 198 glutMainLoop(); -
orxonox/trunk/core/orxonox.h
r1859 r1872 1 1 2 #include "world.h" 2 3 3 4 4 #ifndef ORXONOX_H 5 5 #define ORXONOX_H 6 6 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 8 20 9 21 class Orxonox { 10 22 11 23 private: 12 static Orxonox *singleton_ref;24 static Orxonox* singleton_ref; 13 25 Orxonox (); 14 26 ~Orxonox (); 27 static World* world; 28 static InputOutput* io; 29 static bool pause; 15 30 16 31 public: … … 21 36 int menuInit (void); 22 37 int gameInit (void); 38 void testTheShit(void); 23 39 static void display (void); 40 static void continousRedraw(void); 24 41 static void reshape (int w, int h); 25 42 static void keyboard(unsigned char key, int x, int y); -
orxonox/trunk/core/player.cc
r1858 r1872 10 10 the Free Software Foundation; either version 2, or (at your option) 11 11 any later version. 12 13 ### File Specific: 14 main-programmer: Patrick Boenzli 15 co-programmer: 12 16 */ 13 17 … … 19 23 20 24 21 Player::Player () {} 25 Player::Player () { 26 xCor = yCor = zCor = 0; 27 } 22 28 23 29 … … 31 37 } 32 38 39 void Player::getPosition(int* x, int* y, int* z) 40 { 41 *x = xCor; *y = yCor; *z = zCor; 42 } 43 44 void Player::goX(int x) 45 { 46 // (*player).goUp(); 47 xCor += x; 48 cout << "goX now..." << endl; 49 } 50 51 52 void Player::goY(int y) 53 { 54 yCor += y; 55 } 56 57 void Player::goZ(int z) 58 { 59 zCor += z; 60 } 61 62 void Player::shoot(int n) { 63 } 64 65 66 //void Player::addIO(InputOutput *io) {} 67 33 68 34 69 void Player::drawPlayer(void) 35 70 { 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; 37 75 } -
orxonox/trunk/core/player.h
r1858 r1872 3 3 #define PLAYER_H 4 4 5 /* openGL Headers */ 6 #include <GL/glut.h> 7 8 //#include "input_output.h" 5 9 6 10 class Player { … … 12 16 void setPosition(int x, int y, int z); 13 17 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); 14 23 void drawPlayer(void); 15 24 -
orxonox/trunk/core/world.cc
r1858 r1872 70 70 bool World::removePlayer(Player* player) { 71 71 cout << "World::removeNPC not implemented yet" << endl; 72 } 73 74 Player* World::getLocalPlayer() 75 { 76 return localPlayer; 72 77 } 73 78 -
orxonox/trunk/core/world.h
r1858 r1872 1 2 3 4 #ifndef WORLD_H 5 #define WORLD_H 1 6 2 7 #include "npc.h" 3 8 #include "player.h" 4 9 #include "stdincl.h" 5 6 #ifndef WORLD_H7 #define WORLD_H8 9 10 10 11 class World { … … 15 16 16 17 /* for easier use: map the first two player here */ 18 Player *localPlayer; 17 19 Player *player1; 18 20 Player *player2; … … 36 38 bool addPlayer(Player* player); 37 39 bool removePlayer(Player* player); 40 Player* getLocalPlayer(); 38 41 39 42 bool addNPC(NPC* npc);
Note: See TracChangeset
for help on using the changeset viewer.