Changeset 11541
- Timestamp:
- Nov 6, 2017, 4:06:54 PM (7 years ago)
- Location:
- code/branches/Asteroid_HS17
- Files:
-
- 1 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Asteroid_HS17/data/levels/Asteroid.oxw
r11490 r11541 1 1 <LevelInfo 2 name = " emptyLevel"2 name = "AsteroidsTest" 3 3 description = "A level with absolutely nothing in it." 4 4 tags = "test" … … 14 14 15 15 <?lua 16 include("templates/spaceship Escort.oxt")16 include("templates/spaceship.oxt") 17 17 include("templates/endurancetest_template.oxt") 18 18 ?> … … 30 30 31 31 <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> 32 <SpawnPoint team=0 position=" -200,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipescort/>32 <SpawnPoint team=0 position="0,0,0" lookat="0,0,0" spawnclass=SpaceShip pawndesign=spaceshipAsteroids /> 33 33 34 <ModularSpaceShip velocity= "20,0,0" position="0,0,200" lookat= "0,0,0" health="1000" maxhealth="1000" initialhealth="1000">35 <templates>36 <Template link=endurance />37 </templates>38 </ModularSpaceShip>39 34 40 35 </Scene> -
code/branches/Asteroid_HS17/data/levels/Asteroids.oxw
r11528 r11541 2 2 name = "Asteroids" 3 3 description = "Try to prevent asteroids from colliding into your spaceshuttle. Be prepared to dodge all asteroids or destroy them." 4 tags = " asteroids,minigame"4 tags = "minigame" 5 5 screenshot = "emptylevel.png" 6 6 /> … … 15 15 include("templates/spaceshipAssff2.oxt") 16 16 include("templates/spaceshipPirate.oxt") 17 include("templates/spaceshipInvader.oxt") 18 include("templates/enemyInvader.oxt") 17 include("templates/spaceshipAsteroids.oxt") 19 18 include("overlays/InvaderHUD.oxo") 20 19 ?> 21 20 21 <Template name=asteroidsshipcamera defaults=0> 22 <AsteroidsShip> 23 <camerapositions> 24 <CameraPosition position="55,75,200" absolute=true /> 25 <!--CameraPosition position="0,50,160" drag=true mouselook=true /> 26 <CameraPosition position="0,50,0" pitch=-90 drag=true mouselook=true /--> 27 </camerapositions> 28 </AsteroidsShip> 29 </Template> 30 31 <Template name=asteroidsship> 32 <AsteroidsShip camerapositiontemplate=asteroidsshipcamera> 33 </AsteroidsShip> 34 </Template> 35 22 36 <Level 23 plugins = invader24 gametype = Invader37 plugins = asteroids 38 gametype = Asteroids 25 39 > 26 40 <templates> … … 38 52 <!-- <Light type=directional position="0,0,0" direction="0.253, 0.593, -0.765" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0"/> --> 39 53 <Light type=directional position="1100, 11000, -7000" lookat="0, 0, 0" diffuse="1.0, 0.9, 0.9, 1.0" specular="1.0, 0.9, 0.9, 1.0" /> 40 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass= InvaderShip pawndesign=spaceshipinvader/>54 <SpawnPoint team=0 position="-200,0,0" lookat="0,0,0" spawnclass=AsteroidsShip pawndesign=asteroidsship /> 41 55 42 56 <DistanceTrigger name="start" position="-200,0,0" target="Pawn" distance=10 stayActive="true" delay=0 /> 43 57 44 58 45 < InvaderCenterPoint name=invadercenter />59 <AsteroidsCenterPoint name=asteroidscenter /> 46 60 47 <?lua48 for i = 1, 300, 1 do49 j = math.random()50 ?>51 52 <MovableEntity53 position = "<?lua print(math.random()* 40000 + 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"54 collisionType = dynamic55 linearDamping = 0.856 angularDamping = 057 scale = "<?lua print(j * 150)?>"58 collisiondamage = 059 enablecollisiondamage = true60 >61 <attached>62 <Model mass="<?lua print(j * 1000) ?>" mesh="ast<?lua print( math.mod(i,6) + 1) ?>.mesh" />63 </attached>64 <collisionShapes>65 <SphereCollisionShape radius="<?lua print(j * 350) ?>" />66 </collisionShapes>67 </MovableEntity>68 69 <?lua70 end71 ?>72 61 73 62 </Scene> -
code/branches/Asteroid_HS17/src/modules/asteroids/Asteroids.cc
r11528 r11541 69 69 70 70 //spawnt durch den Timer Asteroiden, denk dran, dass falls ein Asteroid stirbt er in 2 teile geteilt wird 71 Asteroids::spawnStone(){ 72 if(getPlayer() == nullptr){ 73 return; 74 } 71 void Asteroids::spawnStone() 72 { 73 if(getPlayer() == nullptr) return; 75 74 76 75 AsteroidsStone* newStone; … … 78 77 newStone->addTemplate("asteroidsstone"); 79 78 newStone->setAsteroidsPlayer(player); 80 }81 82 void Invader::spawnEnemy()83 {84 if (getPlayer() == nullptr)85 return;86 87 for (int i = 0; i < (3*log10(static_cast<double>(level)) + 1); i++)88 {89 InvaderEnemy* newPawn;90 if (rand() % 42/(1 + level*level) == 0)91 {92 newPawn = new InvaderEnemyShooter(this->center_->getContext());93 newPawn->addTemplate("enemyinvadershooter");94 }95 else96 {97 newPawn = new InvaderEnemy(this->center_->getContext());98 newPawn->addTemplate("enemyinvader");99 }100 newPawn->setInvaderPlayer(player);101 newPawn->level = level;102 // spawn enemy at random points in front of player.103 newPawn->setPosition(player->getPosition() + Vector3(500.f + 100 * i, 0, float(rand())/RAND_MAX * 400 - 200));104 }105 79 } 106 80 … … 155 129 { 156 130 lives = 0; 157 }; 131 } 132 158 133 void Asteroids::start() 159 134 { -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsCenterPoint.h
r11528 r11541 60 60 { return Vector2(this->width_, this->height_); } 61 61 62 float getFieldWidth() const 63 {return this->width_;} 64 65 float getFieldHeight() const 66 {return this->height_;} 67 62 68 private: 63 69 void checkGametype(); -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.cc
r11528 r11541 18 18 { 19 19 RegisterObject(AsteroidsShip); 20 /*radius = 20;21 x = getPosition().x;22 y = getPosition().y;23 dx = 3.0f;24 dy = 3.0f;25 angle= 0.0f;*/26 20 27 speed = 830; 21 angle= 0.0f; 22 23 24 28 25 isFireing = false; 29 damping = 10;26 damping = 0.90; 30 27 31 28 lastTimeFront = 0; 32 29 lastTimeLeft = 0; 33 30 lastTime = 0; 31 32 height = this->getGame()->center_->getFieldHeight(); 33 width = this->getGame()->center_->getFieldWidth(); 34 35 force.x =0; 36 force.y =0; 37 38 velocity.x = 0; 39 velocity.y = 0; 34 40 35 41 } … … 47 53 void AsteroidsShip::tick(float dt) 48 54 { 49 / *Movement computation55 //Movement computation beachte Beschleunigung? 50 56 Vector3 pos = getPosition(); 51 57 52 dx *= damping; 53 dy *= damping; 54 55 float speed = sqrt(dx*dx+ dy*dy); 58 float speed = sqrt(velocity.x*velocity.x+ velocity.y*velocity.y); 56 59 if(speed > maxspeed) 57 60 { 58 dx *= maxspeed/speed;59 dy *= mayspeed/speed;61 velocity.x *= maxspeed/speed; 62 velocity.y *= mayspeed/speed; 60 63 } 61 64 62 x += dx;63 y += dy;65 pos.x += velocity.x*dt; 66 pos.y += velocity.y*dt; 64 67 65 if(x>W) x=0;66 if(x<0) x=W;67 if(y>H) y=0;68 if(y<0) y=H;69 setPosition(x,y,0);70 68 71 //roll? muss sich das Raumschiff drehen? 72 setOrientation(angle, x, y, 0); 69 //haelt ship innerhalb des Kamerafensters 70 if(x>width) x=0; 71 if(x<0) x=width; 72 if(y>height) y=0; 73 if(y<0) y=height); 74 73 75 74 76 //Schiessen wenn geschossen wurde 75 77 // shoot! 78 /* 76 79 if (isFireing) 77 80 ControllableEntity::fire(0); 78 79 //Leben verloren */ 80 Vector3 pos = getPosition(); 81 82 //Movement calculation 83 lastTimeFront += dt * damping; 84 lastTimeLeft += dt * damping; 85 lastTime += dt; 86 87 velocity.x = interpolate(clamp(lastTimeLeft, 0.0f, 1.0f), desiredVelocity.x, 0.0f); 88 velocity.y = interpolate(clamp(lastTimeFront, 0.0f, 1.0f), desiredVelocity.y, 0.0f); 81 */ 89 82 90 83 //Execute movement 91 84 if (this->hasLocalController()) 92 85 { 93 float dist_y = velocity.y * dt; 94 //float dist_x = velocity.x * dt; 95 if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6) 96 posforeward += dist_y; 97 else 98 { 99 velocity.y = 0; 100 // restart if game ended 101 /* 102 if (getGame()) 103 if (getGame()->bEndGame) 104 { 105 getGame()->start(); 106 return; 107 }*/ 108 } 109 110 pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt; 86 force.x += 1; 87 force.y += 1; 111 88 112 89 } … … 118 95 if (camera != nullptr) 119 96 { 120 // camera->setPosition(Vector3(-pos.z, -posforeward, 0));121 camera->setOrientation(Vector3::UNIT_Z, Degree( 0));97 camera->setPosition(Vector3(0,cameradistance, 0)); 98 camera->setOrientation(Vector3::UNIT_Z, Degree(90)); 122 99 } 123 100 … … 130 107 } 131 108 109 velocity.x *= damping; 110 velocity.y *= damping; 111 132 112 setPosition(pos); 133 113 setOrientation(Vector3::UNIT_Y, Degree(270)); 134 114 135 115 SUPER(AsteroidsShip, tick, dt); 116 136 117 } 137 118 138 119 void AsteroidsShip::moveFrontBack(const Vector2& value) 139 120 { 140 141 121 velocity.x += 1; 142 122 } 143 123 144 void AsteroidsShip::move FrontBack(const Vector2& value)124 void AsteroidsShip::moveUpDown(const Vector2& value) 145 125 { 126 velocity.y +=1; 146 127 147 128 } 148 void AsteroidsShip::moveFront Back(const Vector2& value)129 void AsteroidsShip::moveFrontLeftRight(const Vector2& value) 149 130 { 150 131 -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsShip.h
r11528 r11541 72 72 int lives; 73 73 float angle, radius; 74 float speed,damping, posforeward;74 float damping, posforeward; 75 75 bool isFireing; 76 float dx, dy; 77 const float maxspeed = 500; 78 const float cameradistance = 100; 76 79 77 80 //Nachschauen wie gross das Spielfeld ist! 78 float H = 1000; 79 float W = 1000; 81 float height; 82 float width; 83 84 80 85 81 86 protected: … … 88 93 Camera* camera; 89 94 float lastTimeFront, lastTimeLeft, lastTime; 90 struct Ve locity95 struct Vector 91 96 { 92 97 float x; 93 98 float y; 94 } velocity, desiredVelocity;99 }force, velocity 95 100 96 101 }; -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc
r11528 r11541 39 39 #include "util/Math.h" 40 40 41 41 42 namespace orxonox 42 43 { … … 47 48 RegisterObject(AsteroidsStone); 48 49 49 50 51 50 maxspeed = 50.0f; 52 //Random Spawn? pos= random? 51 //Random Spawn? pos= random? -> spawn durch timer in der Asteroids Klasse 53 52 this->setPosition(rnd(0, fieldWidth_), rnd(0, fieldHeigth_), 0); 54 if(r){55 this.r = r*0.5;56 }else{57 this.r = rnd(15, 50);58 }59 53 60 54 //random Geschwindigkeit und Richtung 61 55 velocity.x = rnd(0, maxspeed); 62 56 velocity.y = rnd(0, maxspeed); 57 this->context = context; 63 58 } 59 60 void Asteroids::death() 61 { 62 if(this->size == 1){ 63 Pawn::death(); 64 }else if(this->size == 2){ 65 Pawn::death(); 66 67 //Wie mache ich das ? Eigentlich in der game Klasse? sonst zeigt der Pointer auf einen falschen Bereich 68 69 for(int i = 0; i<2; i++) 70 { 71 AsteroidsStone* newStone; 72 newStone = new AsteroidsStone(this->context); 73 newStone->addTemplate("asteroidsstone"); 74 newStone->setAsteroidsPlayer(player); 75 } 76 77 } 78 } 79 80 64 81 //Bis hier geschrieben 65 82 void AsteroidsStone::tick(float dt) … … 67 84 Vector3 pos = this->getPosition(); 68 85 pos.x += velocity.x*dt; 69 pos.y += velocity.y*dt; 86 pos.z += velocity.y*dt; 87 88 if(pos.y != 0){ 89 pos.y=0; 90 } 70 91 setPosition(pos); 71 92 SUPER(AsteroidsStone, tick, dt); -
code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.h
r11528 r11541 38 38 39 39 #include "worldentities/Pawn.h" 40 #include "core/object/Context.h" 40 41 41 42 namespace orxonox … … 47 48 virtual void tick(float dt) override; 48 49 49 // Radius of the asteroid50 float r;50 //Es gibt 3 Groessen von Meteroiden gross, mittel, klein, gross ->2 mittleren, mittel -> 2 kleinen, kleine-> verschwinden 51 int size; 51 52 int level; 52 53 virtual void setAsteroidsPlayer(AsteroidsShip* player){this->player = player;} 53 54 55 54 56 protected: 57 58 virtual void death() override; 59 55 60 56 61 //herausfinden->ueber Kamera Einstellung wie bei Pong? … … 59 64 Vector2 velocity; 60 65 float maxspeed; 66 67 private: 68 Context* context; 61 69 }; 62 70 }
Note: See TracChangeset
for help on using the changeset viewer.