Changeset 1883 in orxonox.OLD for orxonox/trunk/core
- Timestamp:
- May 10, 2004, 12:36:58 AM (21 years ago)
- Location:
- orxonox/trunk/core
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/core/Makefile
r1879 r1883 40 40 player.o \ 41 41 world.o \ 42 input_output.o 42 input_output.o \ 43 environment.o 43 44 44 45 TARGET = orxonox -
orxonox/trunk/core/orxonox.cc
r1879 r1883 26 26 /* class definition header */ 27 27 #include "orxonox.h" 28 #include "environment.h" 28 29 29 30 … … 70 71 { 71 72 glutInit(&argc, argv); 72 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB); 73 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH); 74 glEnable(GL_DEPTH_TEST); 73 75 glutInitWindowSize(500, 500); 74 76 //glutFullScreen(); … … 93 95 glClearColor(0.0, 0.0, 0.0, 0.0); 94 96 world = new World; 97 (*world).initEnvironement(); 95 98 Player* localPlayer = new Player; 96 99 io = new InputOutput(world, localPlayer); 97 100 (*world).addPlayer(localPlayer); 98 // (*localPlayer).addIO(io);99 100 //glutIgnoreKeyRepeat(1); /* for win32 */101 //glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF); /* for linux X11 */ 101 Environment *env = new Environment; 102 (*world).addEnv(env); 103 104 102 105 glutSpecialFunc(specFunc); 103 106 glutSpecialUpFunc(releaseKey); … … 144 147 break; 145 148 case 27: 149 case 'q': 146 150 quitGame(); 147 151 break; … … 208 212 void Orxonox::display() 209 213 { 210 glClear(GL_COLOR_BUFFER_BIT );214 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 211 215 212 216 glColor3f(0.0, 0.5, 0.6); -
orxonox/trunk/core/player.cc
r1879 r1883 78 78 79 79 80 cout << "x: " << xCor << " y: " << yCor << endl;80 //cout << "x: " << xCor << " y: " << yCor << endl; 81 81 } -
orxonox/trunk/core/world.cc
r1879 r1883 32 32 lastPlayer = null; 33 33 lastNPC = null; 34 lastEnv = null; 34 35 } 35 36 … … 99 100 } 100 101 lastNPC = listMember; 102 } 103 104 105 /** 106 \brief Add environmental object 107 \param player A reference to the new env object 108 109 Add a new Environment to the world. Env has to be initialised before. 110 */ 111 bool World::addEnv(Environment* env) 112 { 113 envList* listMember = new envList; 114 listMember->env = env; 115 if ( lastEnv != null ) 116 { 117 listMember->number = lastEnv->number + 1; 118 listMember->next = lastEnv; 119 } 120 else 121 { 122 listMember->number = 0; 123 listMember->next = null; 124 } 125 lastEnv = listMember; 101 126 } 102 127 … … 137 162 } 138 163 /* now draw the rest of the world: environement */ 164 /* second draw all npcs */ 165 envList* tmpEnv = lastEnv; 166 while( tmpEnv != null ) 167 { 168 (*tmpEnv->env).drawEnvironment(); 169 tmpEnv = tmpEnv->next; 170 } 171 172 /* 139 173 glColor3f(0.0, 1.0, 0.0); 140 174 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); 175 for (int x = 0; x <= 35; x += 5) 176 { 177 glVertex3f((float)x, -10.0, 0.0); 178 glVertex3f((float)x, 200.0, 0.0); 179 180 glVertex3f(-(float)x, -10.0, 0.0); 181 glVertex3f(-(float)x, 200.0, 0.0); 182 } 183 for (int x = -10; x<= 200; x += 5) 184 { 185 glVertex3f(-50.0, (float)x, 0.0); 186 glVertex3f(50.0, (float)x, 0.0); 187 } 173 188 glEnd(); 174 175 189 */ 190 191 192 glColor3f(0.0, 1.0, 0.0); 193 194 glBegin(GL_LINES); 195 for (int x = 0; x < 60; x += 2) 196 { 197 for (int y = 0; y < 60; y += 2) 198 { 199 glVertex3f((float)(x - 30), (float)(y - 30), surface[x][y]); 200 glVertex3f((float)(x - 30), (float)(y - 28), surface[x][y+2]); 201 } 202 } 203 glEnd(); 204 205 206 glBegin(GL_LINES); 207 for (int y = 0; y < 60; y += 2) 208 { 209 for (int x = 0; x < 60; x += 2) 210 { 211 glVertex3f((float)(x - 30), (float)(y - 30), surface[x][y]); 212 glVertex3f((float)(x - 28), (float)(y - 30), surface[x+2][y]); 213 } 214 } 215 glEnd(); 216 217 } 218 219 220 void World::initEnvironement() 221 { 222 223 for (int x = 0; x < 60; x += 2) 224 { 225 for (int y = 0; y < 60; y += 2) 226 { 227 surface[x][y] = 0; 228 } 229 } 176 230 } 177 231 … … 217 271 } 218 272 273 274 /* test addEnv */ 275 cout << "addEnv test..." << endl; 276 envList* en = lastEnv; 277 while ( en != null ) 278 { 279 cout << "env " << en->number << " was found" << endl; 280 en = en->next; 281 } 282 219 283 /* test drawWorld() */ 220 cout << "drawWorld()..." << endl; 221 drawWorld(); 222 223 cout << "World::testThaTest() finished" << endl; 224 } 284 } -
orxonox/trunk/core/world.h
r1872 r1883 5 5 #define WORLD_H 6 6 7 #include <stdlib.h> 8 7 9 #include "npc.h" 8 10 #include "player.h" 11 #include "environment.h" 9 12 #include "stdincl.h" 10 13 … … 36 39 npcList* lastNPC; 37 40 41 /* a list of all environmental objects */ 42 struct envList { 43 envList* next; 44 Environment* env; 45 int number; 46 }; 47 envList* lastEnv; 48 38 49 bool addPlayer(Player* player); 39 50 bool removePlayer(Player* player); … … 43 54 bool removeNPC(NPC* npc); 44 55 56 bool addEnv(Environment* env); 45 57 46 58 void drawWorld(void); 59 void initEnvironement(void); 47 60 void updateWorld(void); 48 61 void testThaTest(void); 62 63 private: 64 float surface[120][120]; 49 65 50 66
Note: See TracChangeset
for help on using the changeset viewer.