source: trunk/mrpigeon/redenemy.cpp @ 1300

Last change on this file since 1300 was 1300, checked in by sam, 8 years ago

core: prefix some member variables with m_ for clarity.

  • Property svn:keywords set to Id
File size: 1.4 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 "redenemy.h"
23
24RedEnemy::RedEnemy(MrPigeon *in_game) :
25    Enemy(in_game),
26    enemytime(0.0f)
27{
28    enemy_casualred = Tiler::Register("mrpigeon/gfx/enemy_CasualRED_walk.png", ivec2(16,24), ivec2(0)); /* 6 frames */
29    enemy_casualredjump = Tiler::Register("mrpigeon/gfx/enemy_CasualRED_jump.png", ivec2(16,24), ivec2(0)); /* 4 frames */
30    enemy_casualredfall = Tiler::Register("mrpigeon/gfx/enemy_CasualRED_fall.png", ivec2(16,24), ivec2(0));
31
32    m_position = vec3(512, 81, 0);
33    m_velocity = vec3(-0.15f, 0, 0);
34}
35
36void RedEnemy::TickGame(float deltams)
37{
38    Enemy::TickGame(deltams);
39
40    deltams *= game->GetSpeed();
41
42    enemytime = fmod(deltams + enemytime, 700.0f);;
43
44    m_position += m_velocity * deltams;
45}
46
47void RedEnemy::TickDraw(float deltams)
48{
49    WorldEntity::TickDraw(deltams);
50
51    /* + 48 because of vertical flip */
52    Scene::GetDefault()->AddTile(enemy_casualred, (int)(enemytime * 6 / 700.0f), m_position + vec3(48.0f, 0, 0), 0, vec2(-3.0f, 3.0f));
53}
54
55RedEnemy::~RedEnemy()
56{
57    Tiler::Deregister(enemy_casualred);
58    Tiler::Deregister(enemy_casualredjump);
59    Tiler::Deregister(enemy_casualredfall);
60}
61
Note: See TracBrowser for help on using the repository browser.