Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 9828


Ignore:
Timestamp:
Nov 25, 2013, 5:35:30 PM (10 years ago)
Author:
zifloria
Message:

HUD + take damage

Location:
code/branches/invaders
Files:
3 added
11 edited

Legend:

Unmodified
Added
Removed
  • code/branches/invaders/data/levels/Invaders.oxw

    r9777 r9828  
    55 screenshot = "emptylevel.png"
    66/>
    7 
     7<!-- include("HUDTemplates3.oxo") -->
    88<?lua
    99  include("stats.oxo")
    10   include("HUDTemplates3.oxo")
    1110  include("templates/lodInformation.oxt")
    1211?>
     
    1716  include("templates/spaceshipInvader.oxt")
    1817  include("templates/enemyInvader.oxt")
     18  include("overlays/InvaderHUD.oxo")
    1919?>
    2020
     
    6161
    6262    <MovableEntity
    63       position = "<?lua print(math.random()* 30000 - 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"
     63      position = "<?lua print(math.random()* 40000 + 1000) ?>,-1000,<?lua print(math.random() * 4000 - 2000) ?>"
    6464      collisionType = dynamic
    6565      linearDamping = 0.8
  • code/branches/invaders/data/levels/templates/enemyInvader.oxt

    r9793 r9828  
    3434
    3535   collisionType     = "dynamic"
    36    mass              = 5
     36   mass              = 0.00001
    3737   linearDamping     = 0
    3838   angularDamping    = 0
  • code/branches/invaders/data/levels/templates/spaceshipInvader.oxt

    r9744 r9828  
    3434
    3535   collisionType     = "dynamic"
    36    mass              = 80
     36   mass              = 4200000
    3737   linearDamping     = 0.7
    3838   angularDamping    = 0.9999999
     39
     40    collisiondamage = 100
     41    enablecollisiondamage = true
    3942  >
    4043    <engines>
  • code/branches/invaders/src/modules/invader/CMakeLists.txt

    r9777 r9828  
    66  InvaderEnemy.cc
    77  InvaderWeapon.cc
     8  InvaderHUDinfo.cc
    89END_BUILD_UNIT
    910)
  • code/branches/invaders/src/modules/invader/Invader.cc

    r9793 r9828  
    6262        this->console_addEnemy = createConsoleCommand( "spawnEnemy", createExecutor( createFunctor(&Invader::spawnEnemy, this) ) );
    6363        //this->context = context;
     64        this->setHUDTemplate("InvaderHUD");
    6465
    6566        enemySpawnTimer.setTimer(2.0f, true, createExecutor(createFunctor(&Invader::spawnEnemy, this)));
     
    8384        newPawn->addTemplate("enemyinvader");
    8485
    85         newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0));
     86        newPawn->setPosition(player->getPosition() + Vector3(1000, 0, 0)); // BUG:
    8687    }
    8788
  • code/branches/invaders/src/modules/invader/Invader.h

    r9777 r9828  
    6262            void setCenterpoint(InvaderCenterPoint* center)
    6363            { this->center_ = center; }
     64
     65            int getLives(){return this->lives;}
     66            int getLevel(){return this->level;}
     67            int getPoints(){return this->point;}
    6468        private:
    6569            WeakPtr<InvaderCenterPoint> center_;
    66             InvaderShip * player;
     70            WeakPtr<InvaderShip> player;
    6771
    6872            ConsoleCommand* console_addEnemy;
    69 
    7073            Timer enemySpawnTimer;
    7174            //Context* context;
     75            int lives;
     76            int level;
     77            int point;
    7278    };
    7379}
  • code/branches/invaders/src/modules/invader/InvaderEnemy.cc

    r9793 r9828  
    4343    {
    4444        RegisterObject(InvaderEnemy);
     45        enableCollisionCallback();
    4546    }
    4647
     
    4950        SUPER(InvaderEnemy, tick, dt);
    5051    }
     52
     53    inline bool InvaderEnemy::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     54    {
     55        orxout() << "sadsadasfasf" << endl;
     56        removeHealth(2000);
     57        setVelocity(Vector3(0,0,1000));
     58        return false;
     59    }
    5160}
  • code/branches/invaders/src/modules/invader/InvaderEnemy.h

    r9793 r9828  
    4848
    4949            virtual void tick(float dt);
     50            virtual bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    5051
    5152        private:
  • code/branches/invaders/src/modules/invader/InvaderPrereqs.h

    r9777 r9828  
    7373    class InvaderEnemy;
    7474    class InvaderWeapon;
     75    class InvaderHUDinfo;
    7576}
    7677
  • code/branches/invaders/src/modules/invader/InvaderShip.cc

    r9793 r9828  
    7070        {
    7171            float dist_y = velocity.y * dt;
     72            float dist_x = velocity.x * dt;
    7273            if(dist_y + posforeward > -42*3 && dist_y + posforeward < 42*6)
    7374                posforeward += dist_y;
    7475            else
    7576                velocity.y = 0;
     77            if (pos.z + dist_x > 42*2.5 || pos.z + dist_x < -42*3)
     78                velocity.x = 0;
    7679            // this->setVelocity(Vector3(1000 + velocity.y, 0, velocity.x));
    7780            pos += Vector3(1000 + velocity.y, 0, velocity.x) * dt;
     
    9396
    9497        // bring back on track!
    95         if (pos.z > 42*2.5)
    96             pos.z = 42*2.5;
    97         else if (pos.z < -42*3)
    98             pos.z = -42*3;
     98        // if (pos.z > 42*2.5)
     99        //     pos.z = 42*2.5;
     100        // else if (pos.z < -42*3)
     101        //     pos.z = -42*3;
    99102        if(pos.y != 0)
    100103            pos.y = 0;
    101         // if (camera != NULL)
    102         // {
    103         //     float x = camera->getWorldPosition().x;
    104         //     if (pos.x > x + 20)
    105         //         pos.x = x + 20;
    106         //     else if (pos.x < x - 20)
    107         //         pos.x = x - 20;
    108         // }
    109         // if (abs(posforeward) < 20)
    110104           
    111105
     
    114108
    115109        // Level up!
    116         if (pos.x > 30000)
     110        if (pos.x > 42000)
    117111        {
    118112            updateLevel();
    119             setPosition(Vector3(0, 0, 0)); // pos - Vector3(30000, 0, 0)
     113            setPosition(Vector3(0, 0, pos.z)); // pos - Vector3(30000, 0, 0)
    120114        }
    121115
     
    144138        isFireing = bBoost;
    145139    }
     140    inline bool InvaderShip::collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint)
     141    {
     142        // orxout() << "touch!!! " << endl; //<< otherObject << " at " << contactPoint;
     143
     144        WeakPtr<InvaderEnemy> enemy = orxonox_cast<InvaderEnemy*>(otherObject);
     145        if (enemy != NULL && lastEnemy != enemy)
     146        {
     147            lastEnemy = enemy;
     148            orxout() << "Enemy!!!! " << endl;
     149            removeHealth(20);
     150            if (getHealth() <= 0)
     151            {
     152                orxout() << "DIED!!!! " << endl;
     153            }
     154            return false;
     155        }
     156        return false;
     157        // SUPER(InvaderShip, collidesAgainst, otherObject, contactPoint);
     158    }
    146159}
  • code/branches/invaders/src/modules/invader/InvaderShip.h

    r9793 r9828  
    6363
    6464            // *InvaderShip getShip(){return this;}
     65            virtual inline bool collidesAgainst(WorldEntity* otherObject, btManifoldPoint& contactPoint);
    6566        private:
    6667            Camera* camera;
     
    7475            } velocity, desiredVelocity;
    7576
     77            WeakPtr<InvaderEnemy> lastEnemy;
     78
    7679    };
    7780}
Note: See TracChangeset for help on using the changeset viewer.