Ignore:
Timestamp:
Apr 10, 2012, 3:15:37 AM (9 years ago)
Author:
sam
Message:

mrpigeon: split enemy into red and blue enemies.

File:
1 copied

Legend:

Unmodified
Added
Removed
  • trunk/mrpigeon/blueenemy.cpp

    r1207 r1211  
    2020
    2121#include "mrpigeon.h"
    22 #include "enemy.h"
     22#include "blueenemy.h"
    2323
    24 Enemy::Enemy(MrPigeon *in_game) :
    25     game(in_game),
     24BlueEnemy::BlueEnemy(MrPigeon *in_game) :
     25    Enemy(in_game),
    2626    enemytime(0.0f)
    2727{
    2828    enemy_casualblue = Tiler::Register("mrpigeon/gfx/enemy_CasualBLUE_walk.png", ivec2(16,24), ivec2(0)); /* 6 frames */
    2929    enemy_casualblueattack = Tiler::Register("mrpigeon/gfx/enemy_CasualBLUE_walkAttack.png", ivec2(16,24), ivec2(0)); /* 6 frames */
     30
     31    position = vec3(512, 81, 0);
     32    velocity = vec3(-0.15f, 0, 0);
    3033}
    3134
    32 void Enemy::TickGame(float deltams)
     35void BlueEnemy::TickGame(float deltams)
    3336{
    34     WorldEntity::TickGame(deltams);
     37    Enemy::TickGame(deltams);
    3538
    3639    deltams *= game->GetSpeed();
    3740
    3841    enemytime = fmod(deltams + enemytime, 700.0f);;
     42
     43    position += velocity * deltams;
    3944}
    4045
    41 void Enemy::TickDraw(float deltams)
     46void BlueEnemy::TickDraw(float deltams)
    4247{
    4348    WorldEntity::TickDraw(deltams);
    4449
    45     Scene::GetDefault()->AddTile(enemy_casualblue, (int)(enemytime * 6 / 700.0f), ivec3(420, 81, 0), 0, vec2(-3.0f, 3.0f));
    46     Scene::GetDefault()->AddTile(enemy_casualblueattack, (int)(enemytime * 6 / 700.0f), ivec3(320, 81, 0), 0, vec2(-3.0f, 3.0f));
     50    /* + 48 because of vertical flip */
     51    Scene::GetDefault()->AddTile(position.x > 255 ? enemy_casualblue : enemy_casualblueattack, (int)(enemytime * 6 / 700.0f), position + vec3(48.0f, 0, 0), 0, vec2(-3.0f, 3.0f));
    4752}
    4853
    49 Enemy::~Enemy()
     54BlueEnemy::~BlueEnemy()
    5055{
    5156    Tiler::Deregister(enemy_casualblue);
Note: See TracChangeset for help on using the changeset viewer.