old_base = base;
dir = LEFT;
seen = false;
+ frozen_timer.init(true);
animation_offset = 0;
sprite_left = sprite_right = 0;
physic.reset();
if(!seen)
return;
+ if(frozen_timer.check())
+ return;
+
switch (kind)
{
case BAD_MRICEBLOCK:
BadGuy::collision(void *p_c_object, int c_object, CollisionType type)
{
BadGuy* pbad_c = NULL;
+ Bullet* pbullet_c = NULL;
if(type == COLLISION_BUMP) {
bump();
switch (c_object)
{
case CO_BULLET:
- kill_me(10);
+ pbullet_c = (Bullet*) p_c_object;
+
+ if(pbullet_c->kind == FIRE_BULLET)
+ kill_me(10);
+ else if(pbullet_c->kind == ICE_BULLET)
+ frozen_timer.start(FROZEN_TIME);
break;
case CO_BADGUY:
bool removable;
bool seen;
int squishcount; /// number of times this enemy was squiched
+ Timer frozen_timer; // gets frozen when a ice shot hits it
Timer timer;
Physic physic;
#define START_LIVES 4
-#define MAX_BULLETS 2
+#define MAX_FIRE_BULLETS 2
+#define MAX_ICE_BULLETS 1
+#define FROZEN_TIME 3000
#define YM_FOR_JUMP 6.0
#define WALK_ACCELERATION_X 0.03
break;
case SDLK_DELETE:
if(debug_mode)
- tux.got_coffee = 1;
+ tux.got_power = tux.FIRE_POWER;
+ break;
+ case SDLK_HOME:
+ if(debug_mode)
+ tux.got_power = tux.ICE_POWER;
break;
case SDLK_INSERT:
if(debug_mode)
PlayerSprite smalltux;
PlayerSprite largetux;
+PlayerSprite icetux;
PlayerSprite firetux;
PlayerKeymap keymap;
base.height = 32;
size = SMALL;
- got_coffee = false;
+ got_power = NONE_POWER;
base.x = plevel->start_pos_x;
base.y = plevel->start_pos_y;
/* Shoot! */
- if (input.fire == DOWN && input.old_fire == UP && got_coffee)
+ if (input.fire == DOWN && input.old_fire == UP && got_power != NONE_POWER)
{
World::current()->add_bullet(base.x, base.y, physic.get_velocity_x(), dir);
input.old_fire = DOWN;
if (size == SMALL)
sprite = &smalltux;
- else if (got_coffee)
+ else if (got_power == FIRE_POWER)
sprite = &firetux;
+ else if (got_power == ICE_POWER)
+ sprite = &icetux;
else
sprite = &largetux;
if (mode == SHRINK && size == BIG)
{
- if (got_coffee)
+ if (got_power != NONE_POWER)
{
- got_coffee = false;
+ got_power = NONE_POWER;
}
else
{
void
Player::remove_powerups()
{
- got_coffee = false;
+ got_power = NONE_POWER;
size = SMALL;
base.height = 32;
}
extern PlayerSprite smalltux;
extern PlayerSprite largetux;
extern PlayerSprite firetux;
+extern PlayerSprite icetux;
class Player : public GameObject
{
public:
enum HurtMode { KILL, SHRINK };
+ enum Power { NONE_POWER, FIRE_POWER, ICE_POWER };
player_input_type input;
- bool got_coffee;
+ int got_power;
int size;
bool duck;
bool holding_something;
firetux.duck_left = sprite_manager->load("firetux-duck-left");
firetux.duck_right = sprite_manager->load("firetux-duck-right");
+ icetux.stand_left = sprite_manager->load("icetux-stand-left");
+ icetux.stand_right = sprite_manager->load("icetux-stand-right");
+ icetux.walk_left = sprite_manager->load("icetux-walk-left");
+ icetux.walk_right = sprite_manager->load("icetux-walk-right");
+ icetux.jump_left = sprite_manager->load("icetux-jump-left");
+ icetux.jump_right = sprite_manager->load("icetux-jump-right");
+ icetux.kick_left = sprite_manager->load("icetux-kick-left");
+ icetux.kick_right = sprite_manager->load("icetux-kick-right");
+ icetux.skid_right = sprite_manager->load("icetux-skid-right");
+ icetux.skid_left = sprite_manager->load("icetux-skid-left");
+ icetux.grab_left = sprite_manager->load("icetux-grab-left");
+ icetux.grab_right = sprite_manager->load("icetux-grab-right");
+ icetux.duck_left = sprite_manager->load("icetux-duck-left");
+ icetux.duck_right = sprite_manager->load("icetux-duck-right");
+
+
/* Water: */
img_water = new Surface(datadir + "/images/shared/water.png", IGNORE_ALPHA);
#include "sprite_manager.h"
#include "resources.h"
-Sprite* img_bullet;
+Sprite* img_firebullet;
+Sprite* img_icebullet;
Sprite* img_star;
Sprite* img_growup;
Sprite* img_iceflower;
#define BULLET_XM 6
void
-Bullet::init(float x, float y, float xm, Direction dir)
+Bullet::init(float x, float y, float xm, Direction dir, int kind_)
{
life_count = 3;
base.width = 4;
base.y = y;
base.ym = BULLET_STARTING_YM;
old_base = base;
+ kind = kind_;
}
void
life_count -= 1;
}
- base.ym = base.ym + 0.5 * frame_ratio;
+ if(kind == FIRE_BULLET)
+ base.ym = base.ym + 0.5 * frame_ratio;
+ else if(kind == FIRE_BULLET)
+ base.ym = 0;
if (base.x < scroll_x ||
base.x > scroll_x + screen->w ||
if (base.x >= scroll_x - base.width &&
base.x <= scroll_x + screen->w)
{
- img_bullet->draw(base.x, base.y);
+ if(kind == FIRE_BULLET)
+ img_firebullet->draw(base.x, base.y);
+ else if(kind == FIRE_BULLET)
+ img_icebullet->draw(base.x, base.y);
}
}
play_sound(sounds[SND_EXCELLENT], SOUND_CENTER_SPEAKER);
pplayer->grow();
}
+ else if (kind == UPGRADE_FIREFLOWER)
+ {
+ play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
+ pplayer->grow();
+ pplayer->got_power = pplayer->FIRE_POWER;
+ }
else if (kind == UPGRADE_ICEFLOWER)
{
play_sound(sounds[SND_COFFEE], SOUND_CENTER_SPEAKER);
pplayer->grow();
- pplayer->got_coffee = true;
+ pplayer->got_power = pplayer->ICE_POWER;
}
else if (kind == UPGRADE_HERRING)
{
img_star = sprite_manager->load("star");
img_1up = sprite_manager->load("1up");
- img_bullet = sprite_manager->load("bullet");
+ img_firebullet = sprite_manager->load("firebullet");
+ img_icebullet = sprite_manager->load("icebullet");
}
void free_special_gfx()
enum UpgradeKind {
UPGRADE_GROWUP,
+ UPGRADE_FIREFLOWER,
UPGRADE_ICEFLOWER,
UPGRADE_HERRING,
UPGRADE_1UP
void bump(Player* player);
};
+enum BulletsKind {
+ FIRE_BULLET,
+ ICE_BULLET
+};
+
class Bullet : public GameObject
{
public:
int life_count;
base_type base;
base_type old_base;
+
+ int kind;
- void init(float x, float y, float xm, Direction dir);
+ void init(float x, float y, float xm, Direction dir, int kind_);
void action(double frame_ratio);
void draw();
void collision(int c_object);
break;
case PlayerStatus::FLOWER_BONUS:
- tux.got_coffee = true;
+ tux.got_power = tux.FIRE_POWER; // FIXME: add ice power to here
// fall through
case PlayerStatus::GROWUP_BONUS:
void
World::add_bullet(float x, float y, float xm, Direction dir)
{
- if(bullets.size() > MAX_BULLETS-1)
- return;
+ if(tux.got_power == tux.FIRE_POWER)
+ {
+ if(bullets.size() > MAX_FIRE_BULLETS-1)
+ return;
+ }
+ else if(tux.got_power == tux.ICE_POWER)
+ {
+ if(bullets.size() > MAX_ICE_BULLETS-1)
+ return;
+ }
Bullet new_bullet;
- new_bullet.init(x,y,xm,dir);
+ if(tux.got_power == tux.FIRE_POWER)
+ new_bullet.init(x,y,xm,dir, FIRE_BULLET);
+ else if(tux.got_power == tux.ICE_POWER)
+ new_bullet.init(x,y,xm,dir, ICE_BULLET);
bullets.push_back(new_bullet);
play_sound(sounds[SND_SHOOT], SOUND_CENTER_SPEAKER);
bool old_level_state = level->solved;
level->solved = true;
- if (session.get_world()->get_tux()->got_coffee)
+ if (session.get_world()->get_tux()->got_power !=
+ session.get_world()->get_tux()->NONE_POWER)
player_status.bonus = PlayerStatus::FLOWER_BONUS;
else if (session.get_world()->get_tux()->size == BIG)
player_status.bonus = PlayerStatus::GROWUP_BONUS;