Changeset 10166
- Timestamp:
- Dec 10, 2014, 3:40:05 PM (10 years ago)
- Location:
- code/branches/surfaceraceHS14
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/surfaceraceHS14/data/levels/DodgeRace.oxw
r10152 r10166 1 1 <LevelInfo 2 2 name = "Dodge Race" 3 description = " 2D Arcade shooter. Maximise your points!!!\nTip: try to keep the multiplier high by avoiding shots and enemies."3 description = "Try to come as far as possible" 4 4 tags = "minigame" 5 screenshot = " orxonoxArcade.png"5 screenshot = "DodgeRace.png" 6 6 /> 7 7 <?lua … … 16 16 include("templates/enemyInvader.oxt") 17 17 include("templates/DodgeRacePattern.oxt") 18 include("overlays/ InvaderHUD.oxo")18 include("overlays/DodgeRaceHUD.oxo") 19 19 ?> 20 20 -
code/branches/surfaceraceHS14/data/levels/templates/spaceshipDodgeRace.oxt
r10154 r10166 69 69 <DodgeRaceShip> 70 70 <camerapositions> 71 <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true /> 72 <CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true /> 73 <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true /> 71 <CameraPosition position="0,100,180" direction="0, -0.2, -1" drag=false mouselook=true /> 72 <CameraPosition position="0,200,250" direction="0, -0.4, -1" drag=false mouselook=true /> 73 <CameraPosition position="0,30,150" direction="0, 0, -1" drag=false mouselook=true /> 74 <CameraPosition position="0,1300,-100" direction="0, -1, 0" drag=false mouselook=true /> 74 75 </camerapositions> 75 76 </DodgeRaceShip> -
code/branches/surfaceraceHS14/data/overlays/DodgeRaceHUD.oxo
r10116 r10166 6 6 <Template name="DodgeRaceHUD"> 7 7 <OverlayGroup name="DodgeRaceHUD" scale = "1, 1"> 8 <DodgeRaceHUDinfo9 position = "0.14, 0.02"10 pickpoint = "0.0, 0.0"11 font = "ShareTechMono"12 textsize = 0.0413 colour = "1.0, 1.0, 1.0, 1.0"14 align = "left"15 8 16 showlives = true17 showlevel = false18 showpoints = false19 />20 9 <OverlayText 21 10 position = "0.02, 0.02" 22 pickpoint = "0.0, 0.0"23 font = "ShareTechMono"24 textsize = 0.0425 colour = "1.0, 1.0, 1.0, 1.0"26 align = "left"27 caption = "Lives: "28 />29 30 <OverlayText31 position = "0.02, 0.055"32 pickpoint = "0.0, 0.0"33 font = "ShareTechMono"34 textsize = 0.0435 colour = "1.0, 1.0, 1.0, 1.0"36 align = "left"37 caption = "Level: "38 />39 40 <DodgeRaceHUDinfo41 position = "0.14, 0.055"42 pickpoint = "0.0, 0.0"43 font = "ShareTechMono"44 textsize = 0.0445 colour = "1.0, 1.0, 1.0, 1.0"46 align = "left"47 48 showlives = false49 showlevel = true50 showpoints = false51 />52 53 <OverlayText54 position = "0.02, 0.1"55 11 pickpoint = "0.0, 0.0" 56 12 font = "ShareTechMono" … … 62 18 63 19 <DodgeRaceHUDinfo 64 position = "0.14, 0. 1"20 position = "0.14, 0.02" 65 21 pickpoint = "0.0, 0.0" 66 22 font = "ShareTechMono" … … 69 25 align = "left" 70 26 71 showlives = false72 showlevel = false73 27 showpoints = true 74 28 /> 75 29 76 <DodgeRaceHUDinfo 77 position = "0.25, 0.1" 78 pickpoint = "0.0, 0.0" 79 font = "ShareTechMono" 80 textsize = 0.04 81 colour = "1.0, 1.0, 1.0, 1.0" 82 align = "left" 83 84 showMultiplier = true 85 /> 30 86 31 </OverlayGroup> 87 32 </Template> 88 33 89 90 34 <Template name="spaceshiphud"> 91 35 <OverlayGroup name = "spaceshiphud" scale = "1, 1"> 92 <HUDHealthBar 93 name = "HealthBar1" 94 background = "Orxonox/HealthBarBackground" 95 size = "0.35, 0.0875" 96 position = "0.0 , 0.9 " 97 pickpoint = "0, 1" 98 bartexture = "healthbar_bar.png" 99 textfont = "VeraMono" 100 textusebarcolour = true 101 textsize = 0.039 102 textoffset = "0.315, 0.05" 103 textpickpoint = "0, 0" 104 textalign = "right" 105 correctaspect = false 106 textcorrectaspect = false 107 > 108 <BarColour position = 0.0 colour = "0.7,0.2,0.2" /> 109 <BarColour position = 0.5 colour = "0.7,0.7,0.2" /> 110 <BarColour position = 1.0 colour = "0.2,0.7,0.2" /> 111 </HUDHealthBar> 36 112 37 </OverlayGroup> 113 38 </Template> -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.cc
r10154 r10166 46 46 this->numberOfBots_ = 0; //sets number of default bots temporarly to 0 47 47 this->center_ = 0; 48 /* 49 this->setHUDTemplate("DodgeRaceHUD"); // !!!!!!!!!!!!!!! change later*/48 49 this->setHUDTemplate("DodgeRaceHUD"); 50 50 } 51 51 … … 53 53 { 54 54 bEndGame = false; 55 lives = 3;55 lives = 1; 56 56 level = 1; 57 57 point = 0; … … 59 59 multiplier = 1; 60 60 b_combo = false; 61 counter = 0;61 counter = 5000; 62 62 pattern = 1; 63 63 lastPosition = 0; … … 95 95 counter = counter + (currentPosition - lastPosition); 96 96 lastPosition = currentPosition; 97 98 for(int i=0; i< cubeList.size();i++) 97 point = currentPosition; 98 getPlayer()->speed = 830 - (point / 1000); 99 100 for(uint i=0; i < cubeList.size();i++) 99 101 { 100 102 if(cubeList.at(i)->getPosition().x < currentPosition-3000) … … 108 110 { 109 111 counter = 0; 110 111 112 for(int i = 0; i<6; i++) 112 113 { … … 147 148 return player; 148 149 } 149 /* 150 void DodgeRace::spawnEnemy() 151 { 152 if (getPlayer() == NULL) 153 return; 154 155 for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++) 156 { 157 WeakPtr<DodgeRaceEnemy> newPawn; 158 if (rand() % 42/(1 + level*level) == 0) 159 { 160 newPawn = new DodgeRaceEnemyShooter(this->center_->getContext()); 161 newPawn->addTemplate("enemyinvadershooter"); 162 } 163 else 164 { 165 newPawn = new DodgeRaceEnemy(this->center_->getContext()); 166 newPawn->addTemplate("enemyinvader"); 167 } 168 newPawn->setPlayer(player); 169 newPawn->level = level; 170 // spawn enemy at random points in front of player. 171 newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200)); 172 } 173 } 174 */ 150 175 151 void DodgeRace::costLife() 176 152 { 177 orxout() << "CostLife" << endl; 178 endGameTimer.setTimer(3.0f, false, createExecutor(createFunctor(&DodgeRace::end, this))); 179 180 multiplier = 1; 153 //endGameTimer.setTimer(8.0f, false, createExecutor(createFunctor(&DodgeRace::end, this))); 154 lives = 0; 181 155 }; 182 156 … … 193 167 void DodgeRace::start() 194 168 { 195 orxout() << "start function called." << endl;169 orxout() << "start" << endl; 196 170 init(); 171 for(uint i=0; i< cubeList.size();i++) 172 { 173 cubeList.at(i)->destroy(); 174 cubeList.erase(cubeList.begin()+i); 175 176 } 177 cubeList.clear(); 178 // Set variable to temporarily force the player to spawn. 179 this->bForceSpawn_ = false; 180 181 if (this->center_ == NULL) // abandon mission! 182 { 183 orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl; 184 GSLevel::startMainMenu(); 185 return; 186 } 187 // Call start for the parent class. 188 Deathmatch::start(); 189 } 190 191 void DodgeRace::playerPreSpawn(PlayerInfo* player) 192 { 193 if(lives <= 0) 194 { 195 this->end(); 196 } 197 198 // Reset all the cubes 199 /* 200 orxout() << "prespawn" << endl; 201 init(); 197 202 for(int i=0; i< cubeList.size();i++) 198 203 { 199 204 cubeList.at(i)->destroy(); 200 205 cubeList.erase(cubeList.begin()+i); 201 202 206 } 203 cubeList.clear(); 204 // Set variable to temporarily force the player to spawn. 205 this->bForceSpawn_ = true; 206 207 if (this->center_ == NULL) // abandon mission! 208 { 209 orxout(internal_error) << "DodgeRace: No Centerpoint specified." << endl; 210 GSLevel::startMainMenu(); 211 return; 212 } 213 // Call start for the parent class. 214 Deathmatch::start(); 215 } 207 cubeList.clear(); 208 lives = 1; 209 point = 0; 210 lastPosition = 0; 211 */ 212 } 213 216 214 void DodgeRace::addPoints(int numPoints) 217 215 { -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRace.h
r10154 r10166 77 77 virtual void tick(float dt); 78 78 79 virtual void playerPreSpawn(PlayerInfo* player); 80 79 81 void levelUp(); 80 82 -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.cc
r10124 r10166 41 41 42 42 this->DodgeRaceGame = 0; 43 this->bShowLives_ = false; 44 this->bShowLevel_ = false; 45 this->bShowPoints_ = false; 46 this->bShowMultiplier_ = false; 43 this->bShowPoints_ = true; 47 44 } 48 /* 45 49 46 void DodgeRaceHUDinfo::XMLPort(Element& xmlelement, XMLPort::Mode mode) 50 47 { 51 48 SUPER(DodgeRaceHUDinfo, XMLPort, xmlelement, mode); 52 49 53 XMLPortParam(DodgeRaceHUDinfo, "showlives", setShowLives, getShowLives, xmlelement, mode).defaultValues(false); 54 XMLPortParam(DodgeRaceHUDinfo, "showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); 55 XMLPortParam(DodgeRaceHUDinfo, "showLevel", setShowLevel, getShowLevel, xmlelement, mode).defaultValues(false); 56 XMLPortParam(DodgeRaceHUDinfo, "showMultiplier", setShowMultiplier, getShowMultiplier, xmlelement, mode).defaultValues(false); 50 XMLPortParam(DodgeRaceHUDinfo,"showPoints", setShowPoints, getShowPoints, xmlelement, mode).defaultValues(false); 57 51 } 58 52 … … 61 55 SUPER(DodgeRaceHUDinfo, tick, dt); 62 56 63 if (this->DodgeRaceGame) 64 { 65 if (this->bShowLives_) 66 { 67 const std::string& lives = multi_cast<std::string>(this->DodgeRaceGame->getLives()); 68 this->setCaption(lives); 69 } 70 else if(this->bShowLevel_) 71 { 72 const std::string& Level = multi_cast<std::string>(this->DodgeRaceGame->getLevel()); 73 if (this->DodgeRaceGame->lives <= 0) 74 { 75 setPosition(Vector2(0.1, 0.65)); 76 this->setCaption("Game ends in 30 seconds.\nPress (e)xit / (q)uit to go to the main menu.\nTo restart fly out of the screen!"); 77 setTextSize(0.05); 78 this->DodgeRaceGame->bEndGame = true; 79 } 80 else if (this->DodgeRaceGame->bShowLevel) 81 { 82 setTextSize(0.1); 83 setPosition(Vector2(0.3, 0.55)); 84 std::stringstream sstm; 85 sstm << "Level " << Level; 86 this->setCaption(sstm.str()); // + level 87 } 88 else 89 { 90 setTextSize(0.04); 91 setPosition(Vector2(0.14, 0.055)); 92 this->setCaption(Level); 93 } 94 } 95 else if(this->bShowPoints_) 96 { 97 const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints()); 98 if (this->DodgeRaceGame->lives <= 0) 99 { 100 setTextSize(0.2); 101 setPosition(Vector2(0.1, 0.25)); 102 this->setCaption("Final score:\n" + points); 103 this->setColour(ColourValue(1, 0, 0, 1)); 104 } 105 else 106 { 107 setTextSize(0.04); 108 setPosition(Vector2(0.14, 0.1)); 109 this->setColour(ColourValue(1, 1, 1, 1)); 110 this->setCaption(points); 111 } 112 } 113 else if(this->bShowMultiplier_) 114 { 115 int mult = this->DodgeRaceGame->getMultiplier(); 116 const std::string& Multiplier = "X " + multi_cast<std::string>(mult); 117 this->setCaption(Multiplier); 118 this->setColour(ColourValue(1, 0, 0, clamp(float(mult * 0.1), 0.0f, 1.0f))); 119 this->setTextSize(clamp(float(mult * 0.1), 0.0f, 1.0f) * 0.01f + 0.04f); 120 } 121 } 57 58 if(this->bShowPoints_) 59 { 60 const std::string& points = multi_cast<std::string>(this->DodgeRaceGame->getPoints()); 61 if (this->DodgeRaceGame->lives <= 0) 62 { 63 setTextSize(0.2); 64 setPosition(Vector2(0.1, 0.02)); 65 this->setCaption("Final score:\n" + points); 66 this->setColour(ColourValue(1, 0, 0, 1)); 67 } 68 else 69 { 70 setTextSize(0.04); 71 setPosition(Vector2(0.14, 0.02)); 72 this->setColour(ColourValue(1, 1, 1, 1)); 73 this->setCaption(points); 74 } 75 } 122 76 } 123 77 … … 134 88 this->DodgeRaceGame = 0; 135 89 } 136 } */90 } 137 91 } -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceHUDinfo.h
r10124 r10166 44 44 DodgeRaceHUDinfo(Context* context); 45 45 46 // virtual void tick(float dt); 47 // virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 //virtual void changedOwner(); 49 50 inline void setShowLives(bool value) 51 { this->bShowLives_ = value; } 52 inline bool getShowLives() const 53 { return this->bShowLives_; } 54 55 inline void setShowLevel(bool value) 56 { this->bShowLevel_ = value; } 57 inline bool getShowLevel() const 58 { return this->bShowLevel_; } 46 virtual void tick(float dt); 47 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 48 virtual void changedOwner(); 59 49 60 50 inline void setShowPoints(bool value) … … 63 53 { return this->bShowPoints_; } 64 54 65 inline void setShowMultiplier(bool value)66 { this->bShowMultiplier_ = value; }67 inline bool getShowMultiplier() const68 { return this->bShowMultiplier_; }69 70 55 71 56 private: 72 57 DodgeRace* DodgeRaceGame; 73 bool bShowLives_;74 bool bShowLevel_;75 58 bool bShowPoints_; 76 bool bShowMultiplier_;77 59 }; 78 60 } -
code/branches/surfaceraceHS14/src/modules/dodgerace2/DodgeRaceShip.cc
r10154 r10166 42 42 RegisterObject(DodgeRaceShip); 43 43 44 speed = 8 00;44 speed = 830; 45 45 isFireing = false; 46 46 damping = 10; … … 68 68 { 69 69 float dist_y = velocity.y * dt; 70 float dist_x = velocity.x * dt;70 //float dist_x = velocity.x * dt; 71 71 if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6) 72 72 posforeward += dist_y; … … 75 75 velocity.y = 0; 76 76 // restart if game ended 77 77 /* 78 78 if (getGame()) 79 79 if (getGame()->bEndGame) … … 83 83 }*/ 84 84 } 85 /* 86 if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3) 87 { 88 velocity.x = 0; 89 } 90 */ 85 91 86 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 92 }93 94 // shoot!95 if (isFireing)96 {97 //pos += Vector3(900, 0, 0) * dt;98 //ControllableEntity::fire(0);99 87 } 100 88 … … 150 138 void DodgeRaceShip::boost(bool bBoost) 151 139 { 152 // isFireing= bBoost;140 //getGame()->bEndGame = bBoost; 153 141 } 154 142 155 143 inline bool DodgeRaceShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint) 156 144 { 157 /*158 if (otherObject != NULL && lastEntity != otherObject)159 {160 lastEntity = otherObject;161 removeHealth(20);162 }163 */164 145 165 146 removeHealth(100);
Note: See TracChangeset
for help on using the changeset viewer.