Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Nov 13, 2017, 4:05:34 PM (8 years ago)
Author:
vyang
Message:

Level file: korrekte Kameraposition, Raumschiff bewegt sich nicht, schiesst aber → wird AsteroidsShip ueberhaupt geladen? AsteroidsShip: neue Steuerung (vgl Jump, Rotation muss noch angepasst werden)

File:
1 edited

Legend:

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

    r11541 r11555  
    2828
    2929/**
    30     @file InvaderEnemy.h
    31     @brief Declaration of the InvaderEnemy class.
     30    @file AsteroidsEnemy.h
     31    @brief Declaration of the AsteroidsEnemy class.
    3232*/
    3333
     
    3636#include "Asteroids.h"
    3737#include "AsteroidsShip.h"
     38#include <cstdlib>
    3839#include <cmath>
    3940#include "util/Math.h"
    4041
     42const float delta = 3;
    4143
    4244namespace orxonox
     
    4850        RegisterObject(AsteroidsStone);
    4951
     52        direction = 0;
     53        //Spielfeld x als Horizontale und z als Vertikale
     54        fieldWidth_ = this->getGame()->center_->getFieldWidth;
     55        fieldHeigth_ = this->getGame()->center_->getFieldHeight;
     56
     57
     58        //Random size 1, 2, 3 ->muss noch realisiert werden. Templates erstellen
     59        this.size = 1;
    5060        maxspeed = 50.0f;
    5161        //Random Spawn? pos= random? -> spawn durch timer in der Asteroids Klasse
    52         this->setPosition(rnd(0, fieldWidth_), rnd(0, fieldHeigth_), 0);
     62        this->setPosition(rnd(fieldWidth_), 0, rnd(fieldHeigth));
    5363
    54                 //random Geschwindigkeit und Richtung
    55                 velocity.x = rnd(0, maxspeed);
    56                 velocity.y = rnd(0, maxspeed);
    57         this->context = context;
     64        //random Geschwindigkeit und Richtung
     65        velocity.x = rnd(maxspeed);
     66        velocity.y = rnd(maxspeed);
     67    }
     68
     69    inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
     70    {
     71        if(orxonox_cast<AsteroidsShip*>(otherObject))
     72            removeHealth(2000);
     73        return false;
    5874    }
    5975
     
    6480        }else if(this->size == 2){
    6581            Pawn::death();
    66 
    6782            //Wie mache ich das ? Eigentlich in der game Klasse? sonst zeigt der Pointer auf einen falschen Bereich
    68 
    6983            for(int i = 0; i<2; i++)
    7084            {
    7185                AsteroidsStone* newStone;
    72                 newStone = new AsteroidsStone(this->context);
     86                newStone = new AsteroidsStone(this->getGame()->center_->getContext());
    7387                newStone->addTemplate("asteroidsstone");
    74                 newStone->setAsteroidsPlayer(player);
     88                newStone->setAsteroidsPlayer(this->getGame()->player);
    7589            }
    7690
    7791        }
     92    }
     93   
     94
     95    Asteroids* AsteroidsStone::getGame()
     96    {
     97        if (game == nullptr)
     98        {
     99            for (Asteroids* Asteroids : ObjectList<Asteroids>())
     100                game = asteroids;
     101        }
     102        return game;
    78103    }
    79104
     
    82107    void AsteroidsStone::tick(float dt)
    83108    {
    84         Vector3 pos = this->getPosition();
    85         pos.x += velocity.x*dt;
    86         pos.z += velocity.y*dt;
     109        Vector3 pos = getPosition();
    87110
     111
     112
     113
     114        //bounce on the borders
     115        if(pos.x-delta <= 0 || pos.x+delta >= fieldWidth_)
     116            direction = -direction;
     117
     118
     119
     120        //zurück bringen
    88121        if(pos.y != 0){
    89122            pos.y=0;
    90123        }
     124
     125        //spin
     126
     127        setOrientation()
    91128        setPosition(pos);
     129
    92130        SUPER(AsteroidsStone, tick, dt);
    93131    }
     
    95133    inline bool AsteroidsStone::collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)
    96134    {
    97         if(orxonox_cast<InvaderShip*>(otherObject))
     135        if(orxonox_cast<AsteroidsShip*>(otherObject))
    98136            removeHealth(2000);
    99137        return false;
Note: See TracChangeset for help on using the changeset viewer.