source: trunk/mrpigeon/blueenemy.cpp @ 1211

Last change on this file since 1211 was 1211, checked in by sam, 9 years ago

mrpigeon: split enemy into red and blue enemies.

  • Property svn:keywords set to Id
File size: 1.3 KB
Line 
1//
2// MrPigeon
3//
4// Copyright: (c) 2012 Various People
5//
6
7#if defined HAVE_CONFIG_H
8#   include "config.h"
9#endif
10
11#if USE_SDL && defined __APPLE__
12#   include <SDL_main.h>
13#endif
14
15#include "core.h"
16#include "debug/fps.h"
17
18using namespace std;
19using namespace lol;
20
21#include "mrpigeon.h"
22#include "blueenemy.h"
23
24BlueEnemy::BlueEnemy(MrPigeon *in_game) :
25    Enemy(in_game),
26    enemytime(0.0f)
27{
28    enemy_casualblue = Tiler::Register("mrpigeon/gfx/enemy_CasualBLUE_walk.png", ivec2(16,24), ivec2(0)); /* 6 frames */
29    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);
33}
34
35void BlueEnemy::TickGame(float deltams)
36{
37    Enemy::TickGame(deltams);
38
39    deltams *= game->GetSpeed();
40
41    enemytime = fmod(deltams + enemytime, 700.0f);;
42
43    position += velocity * deltams;
44}
45
46void BlueEnemy::TickDraw(float deltams)
47{
48    WorldEntity::TickDraw(deltams);
49
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));
52}
53
54BlueEnemy::~BlueEnemy()
55{
56    Tiler::Deregister(enemy_casualblue);
57    Tiler::Deregister(enemy_casualblueattack);
58}
59
Note: See TracBrowser for help on using the repository browser.