source: trunk/mrpigeon/redenemy.cpp @ 1310

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

core: tick methods now use seconds, like any sane system.

  • Property svn:keywords set to Id
File size: 1.4 KB
RevLine 
[1211]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
[1300]32    m_position = vec3(512, 81, 0);
[1310]33    m_velocity = vec3(-150.f, 0, 0);
[1211]34}
35
[1310]36void RedEnemy::TickGame(float seconds)
[1211]37{
[1310]38    Enemy::TickGame(seconds);
[1211]39
[1310]40    seconds *= game->GetSpeed();
[1211]41
[1310]42    enemytime = fmod(seconds + enemytime, .7f);;
[1211]43
[1310]44    m_position += m_velocity * seconds;
[1211]45}
46
[1310]47void RedEnemy::TickDraw(float seconds)
[1211]48{
[1310]49    WorldEntity::TickDraw(seconds);
[1211]50
51    /* + 48 because of vertical flip */
[1310]52    Scene::GetDefault()->AddTile(enemy_casualred, (int)(enemytime * 6 / .7f), m_position + vec3(48.0f, 0, 0), 0, vec2(-3.0f, 3.0f));
[1211]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.