Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Oct 30, 2017, 4:04:29 PM (7 years ago)
Author:
vyang
Message:

Files hinzugefuegt, versucht Aehnlichkeiten mit anderen minigames (dodgerace, invader) zu finden. Testlevel noch zu bearbeiten. Gametype Asteroids crashed immer noch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • code/branches/Asteroid_HS17/src/modules/asteroids/AsteroidsStone.cc

    r11506 r11516  
    3232*/
    3333
    34 #include "InvaderEnemy.h"
    35 
     34#include "AsteroidsStone.h"
    3635#include "core/CoreIncludes.h"
    37 #include "Invader.h"
    38 #include "InvaderShip.h"
     36#include "Asteroids.h"
     37#include "AsteroidsShip.h"
     38#include <cmath>
     39#include "util/Math.h"
    3940
    4041namespace orxonox
    4142{
    42     RegisterClass(InvaderEnemy);
     43    RegisterClass(AsteroidsStone);
    4344
    44     InvaderEnemy::InvaderEnemy(Context* context) : Pawn(context)
     45    AsteroidsStone::AsteroidsStone(Context* context) : MovableEntity(context)
    4546    {
    46         RegisterObject(InvaderEnemy);
    47         enableCollisionCallback();
    48         lifetime = 0;
     47        RegisterObject(AsteroidsStone);
     48
     49        maxspeed = 50.0f;
     50        //Random Spawn? pos= random?
     51        this->setPosition(rnd(0, fieldWidth_), rnd(0, fieldHeigth_), 0);
     52                if(r){
     53                        this.r = r*0.5;
     54                }else{
     55                        this.r = rnd(15, 50);
     56                }
     57
     58                //random Geschwindigkeit und Richtung
     59                velocity.x = rnd(0, maxspeed);
     60                velocity.y = rnd(0, maxspeed);
     61    }
     62//Bis hier geschrieben
     63    void AsteroidsStone::tick(float dt)
     64    {
     65        Vector3 pos = this->getPosition();
     66        pos.x += velocity.x*dt;
     67        pos.y += velocity.y*dt;
     68        setPosition(pos);
     69        SUPER(AsteroidsStone, tick, dt);
    4970    }
    5071
    51     void InvaderEnemy::tick(float dt)
    52     {
    53         lifetime += dt;
    54         // die after 5 seconds.
    55         if (lifetime > 5000)
    56             removeHealth(2000);
    57 
    58         if (player != nullptr)
    59         {
    60             float newZ = 2/(pow(std::abs(getPosition().x - player->getPosition().x) * 0.01f, 2) + 1) * (player->getPosition().z - getPosition().z);
    61             setVelocity(Vector3(1000.f - level * 100 , 0, newZ));
    62         }
    63         SUPER(InvaderEnemy, tick, dt);
    64     }
    65 
    66     inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     72    inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
    6773    {
    6874        if(orxonox_cast<InvaderShip*>(otherObject))
     
    7177    }
    7278
    73     Invader* InvaderEnemy::getGame()
    74     {
    75         if (game == nullptr)
    76         {
    77             for (Invader* invader : ObjectList<Invader>())
    78                 game = invader;
    79         }
    80         return game;
    81     }
    8279
    83     void InvaderEnemy::damage(float damage, float healthdamage, float shielddamage, Pawn* originator, const btCollisionShape* cs)
    84     {
    85         Pawn::damage(damage, healthdamage, shielddamage, originator, cs);
    86         if (getGame() && orxonox_cast<InvaderShip*>(originator) != nullptr && getHealth() <= 0)
    87             getGame()->addPoints(42);
    88     }
    8980}
Note: See TracChangeset for help on using the changeset viewer.