Changeset 1900 in orxonox.OLD for orxonox/trunk/core
- Timestamp:
- May 23, 2004, 11:21:38 PM (20 years ago)
- Location:
- orxonox/trunk/core
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
orxonox/trunk/core/input_output.cc
r1896 r1900 40 40 41 41 42 void InputOutput::setPlayerStep(float step) 43 { 44 cout << "setting player step to: " << step << endl; 45 this->step = step; 46 } 47 42 48 43 49 void InputOutput::goUp() 44 50 { 45 51 //cout << "InoutOutput::goUp" << endl; 46 (*player).goY( STEP_FRONT);52 (*player).goY(step); 47 53 } 48 54 49 55 void InputOutput::goDown() 50 56 { 51 (*player).goY(- STEP_FRONT);57 (*player).goY(-step); 52 58 } 53 59 54 60 void InputOutput::goLeft() 55 61 { 56 (*player).goX(- STEP_SIDE);62 (*player).goX(-step); 57 63 58 64 } … … 61 67 { 62 68 63 (*player).goX( STEP_SIDE);69 (*player).goX(step); 64 70 } 65 71 -
orxonox/trunk/core/input_output.h
r1896 r1900 9 9 #include "player.h" 10 10 11 #define STEP_SIDE 0.412 #define STEP_FRONT 0.413 11 14 12 class InputOutput { … … 18 16 Player* player; 19 17 18 float step; 19 20 20 public: 21 21 InputOutput (World* wld, Player* player); 22 22 ~InputOutput (); 23 23 24 void setPlayerStep(float step); 24 25 void goUp(void); 25 26 void goDown(void); -
orxonox/trunk/core/orxonox.cc
r1899 r1900 51 51 Player* Orxonox::localPlayer = 0; 52 52 bool Orxonox::pause = false; 53 bool Orxonox::inputEnabled = false; 53 54 bool Orxonox::upWeGo = false; 54 55 bool Orxonox::downWeGo = false; … … 87 88 88 89 glutTimerFunc(1000, timeSlice, 0); 90 cout << "measuring performance..."; 89 91 } 90 92 … … 114 116 world->addNPC(npc); 115 117 118 NPC* npc2 = new NPC; 119 npc2->setPosition(-2.0, 10.0, 3.0); 120 npc2->setCollisionRadius(1.0); 121 world->addNPC(npc2); 122 116 123 glutSpecialFunc(specFunc); 117 124 glutSpecialUpFunc(releaseKey); … … 126 133 void Orxonox::timeSlice(int value) 127 134 { 128 cout << "fps: " << fps << endl; 135 cout << "got " << fps << endl; 136 /* this is very very unsafe: io could be uninit */ 137 io->setPlayerStep(19.2 / fps); /* set player to propper speed */ 138 //localPlayer->shootLaser->setShootStep(fps/48.0); /* set shoot speed */ 129 139 fps = 0; 140 inputEnabled = true; 130 141 glutTimerFunc(1000, timeSlice, 0); 131 142 } … … 259 270 260 271 /* check for input to pass it over */ 261 if ( !pause && (rightWeGo || leftWeGo || upWeGo || downWeGo || shoot1)) { 262 if (upWeGo) 263 (*io).goUp(); 264 if (downWeGo) 272 if ( !pause && inputEnabled && 273 (rightWeGo || leftWeGo || upWeGo || downWeGo || shoot1)) 274 { 275 if (upWeGo) 276 (*io).goUp(); 277 if (downWeGo) 265 278 (*io).goDown(); 266 if (rightWeGo)267 268 if (leftWeGo)279 if (rightWeGo) 280 (*io).goRight(); 281 if (leftWeGo) 269 282 (*io).goLeft(); 270 if (shoot1)271 272 }283 if (shoot1) 284 (*io).shoot(); 285 } 273 286 /* request repaint */ 274 287 glutPostRedisplay(); -
orxonox/trunk/core/orxonox.h
r1897 r1900 31 31 static Player* localPlayer; 32 32 static bool pause; 33 static bool inputEnabled; 33 34 static bool upWeGo; 34 35 static bool downWeGo; -
orxonox/trunk/core/player.cc
r1899 r1900 47 47 } 48 48 49 50 void Player::setCollisionRadius(float radius) 51 { 52 collisionRadius = radius; 53 } 54 55 49 56 void Player::goX(float x) 50 57 { … … 67 74 { 68 75 shootLaser->addShoot(xCor, yCor, zCor); 76 shootLaser->addShootExt(xCor, yCor, zCor, .1, .4, .0); 77 shootLaser->addShootExt(xCor, yCor, zCor, -0.1, .4, .0); 69 78 //cout << "Player::shoot" << endl; 70 79 } -
orxonox/trunk/core/player.h
r1899 r1900 19 19 float yCor; 20 20 float zCor; 21 22 float collisionRadius; 21 23 22 24 /* this player wanna shoot? so include a ref to ShootLaser */ … … 25 27 void setPosition(float x, float y, float z); 26 28 void getPosition(float* x, float* y, float* z); 29 void setCollisionRadius(float radius); 27 30 void goX(float x); 28 31 void goY(float y); -
orxonox/trunk/core/shoot_laser.cc
r1899 r1900 29 29 { 30 30 lastShoot = null; 31 step = 1.0; 31 32 } 32 33 … … 46 47 glPushMatrix(); 47 48 glTranslatef(tmpShoot->xCor, tmpShoot->yCor, tmpShoot->zCor); 49 tmpShoot->xCor+=tmpShoot->xInc; 48 50 tmpShoot->yCor+=tmpShoot->yInc; 49 51 glScalef(0.1, 0.1, 0.1); … … 55 57 /* fix2: conditions, that a struct tree can be cut off */ 56 58 /* fix3: more efficent and nicer please */ 57 if (tmpShoot->yCor > 50)59 if (tmpShoot->yCor > 20) 58 60 { 61 /* normal case: delete one element, link the others */ 59 62 if (lastRef != null) 60 63 { 61 cout << "garbage collection" << endl;64 //cout << "garbage collection" << endl; 62 65 lastRef->next = tmpShoot->next; 63 66 delete tmpShoot; 64 tmpShoot = lastRef; 65 lastRef = tmpShoot; 66 tmpShoot = tmpShoot->next; 67 cout << "garbage collection left" << endl; 67 tmpShoot = lastRef->next; 68 //cout << "garbage collection left" << endl; 68 69 } 69 70 else 70 71 { 71 cout << "garbage collecton on last el" << endl; 72 /* special case: first element to be processed */ 73 //cout << "garbage collecton: first el in queue" << endl; 72 74 lastRef = tmpShoot->next; 73 75 delete tmpShoot; 74 76 tmpShoot = lastRef; 75 if (tmpShoot != null) { 76 lastRef = tmpShoot; 77 tmpShoot = tmpShoot->next; 78 cout << "noch nich null" << endl; 79 } 80 else { 81 lastRef = null; 82 tmpShoot = null; 83 lastShoot = null; 84 cout << "endl null" << endl; 85 } 86 cout << "garbage collection on last el left" << endl; 77 lastShoot = tmpShoot; 78 if (tmpShoot != null) 79 { 80 tmpShoot = tmpShoot->next; 81 //cout << "noch nich null" << endl; 82 } 83 else 84 { 85 lastRef = null; 86 tmpShoot = null; 87 lastShoot = null; 88 //cout << "endl null" << endl; 89 } 90 91 //cout << "garbage collection: firtst el in queue left" << endl; 87 92 } 88 93 } … … 108 113 shoot* sh = new shoot; 109 114 sh->xCor = x; sh->yCor = y; sh->zCor = z; 110 sh->xInc = 0; sh->yInc = . 2; sh->zInc = 0;115 sh->xInc = 0; sh->yInc = .4/step; sh->zInc = 0; 111 116 sh->next = lastShoot; 112 117 lastShoot = sh; 113 118 } 114 119 120 void ShootLaser::addShootExt(float x, float y, float z, 121 float xInc, float yInc, float zInc) 122 { 123 //cout << "ShootLaser::addShootExtended" << endl; 124 shoot* sh = new shoot; 125 sh->xCor = x; sh->yCor = y; sh->zCor = z; 126 sh->xInc = xInc/step; sh->yInc = yInc/step; sh->zInc = zInc/step; 127 sh->next = lastShoot; 128 lastShoot = sh; 129 } 130 131 void ShootLaser::setShootStep(float step) 132 { 133 cout << "ShootLaser::setShootStep to " << step << endl; 134 this->step = step; 135 } 136 137 138 /* Exterminate shoot from game, implement this method */ 139 /* if you like to add animatiion */ 140 void ShootLaser::removeShoot(shoot* sh) 141 { 142 glPushMatrix(); 143 glTranslatef(sh->xCor, sh->yCor, sh->zCor); 144 glutWireCube(1.0); 145 glPopMatrix(); 146 } -
orxonox/trunk/core/shoot_laser.h
r1899 r1900 29 29 ~ShootLaser (); 30 30 31 void drawShoot( );31 void drawShoot(void); 32 32 void addShoot(shoot* sh); 33 33 void addShoot(float x, float y, float z); 34 void addShootExt(float x, float y, float z, float xInc, float yInc, float zInc); 35 void setShootStep(float step); 36 void removeShoot(shoot* sh); 34 37 35 38 36 39 private: 37 40 41 float step; 42 38 43 }; 39 44 -
orxonox/trunk/core/world.cc
r1899 r1900 1 2 1 3 2 /* … … 232 231 void World::detectCollision() 233 232 { 233 //cout << "World::detectCollision" << endl; 234 234 float xOff, yOff, zOff, radius; 235 235 npcList* tmpNPC; … … 263 263 /* second: check if any player hits an enemy */ 264 264 265 /* 266 tmpPlayer = lastPlayer; 267 while( tmpPlayer != null ) 268 { 269 tmpNPC = lastNPC; 270 while( tmpNPC != null ) 271 { 272 radius = tmpNPC->npc->collisionRadius + tmpPlayer->player->collisionRadius; 273 xOff = tmpPlayer->player->xCor - tmpNPC->npc->xCor; 274 yOff = tmpPlayer->player->yCor - tmpNPC->npc->yCor; 275 zOff = tmpPlayer->player->zCor - tmpNPC->npc->zCor; 276 if ( sqrt(xOff*xOff + yOff*yOff + zOff*zOff) < radius ) 277 cout << "COLLISION " << endl; 278 279 tmpNPC = tmpNPC->next; 280 } 281 282 tmpPlayer = tmpPlayer->next; 283 } 284 285 */ 286 265 287 /* third: check if any enemy shoots a player */ 266 288
Note: See TracChangeset
for help on using the changeset viewer.