Skip to content

Commit

Permalink
bugfixes, fix healthbar issue, screen flash animation for first boss
Browse files Browse the repository at this point in the history
  • Loading branch information
evanbowman committed Apr 24, 2020
1 parent e380397 commit 11bbdea
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 28 deletions.
Binary file modified images/overlay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
48 changes: 34 additions & 14 deletions source/entity/bosses/theFirstExplorer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -473,6 +473,22 @@ void TheFirstExplorer::on_collision(Platform& pf, Game& game, Laser&)
}


Game::DeferredCallback screen_flash_animation(int remaining)
{
return [remain = remaining](Platform& pf, Game& game) {
if (remain > 0) {
pf.screen().fade(255 - remain, ColorConstant::silver_white);

game.on_timeout(milliseconds(20),
screen_flash_animation(remain - 1));

} else {
pf.screen().fade(0);
}
};
}


void TheFirstExplorer::on_death(Platform& pf, Game& game)
{
hide_boss_health(game);
Expand All @@ -481,27 +497,31 @@ void TheFirstExplorer::on_death(Platform& pf, Game& game)

const auto off = 50.f;

for (int i = 0; i < 3; ++i) {
game.details().spawn<Item>(
sample<32>(position_), pf, Item::Type::heart);
}

big_explosion(pf, game, {position_.x - off, position_.y - off});
big_explosion(pf, game, {position_.x + off, position_.y + off});

game.on_timeout(milliseconds(300),
[pos = position_](Platform& pf, Game& game) {
big_explosion(pf, game, pos);
const auto off = -50.f;
game.on_timeout(
milliseconds(300), [pos = position_](Platform& pf, Game& game) {
big_explosion(pf, game, pos);
const auto off = -50.f;

big_explosion(pf, game, {pos.x - off, pos.y + off});
big_explosion(pf, game, {pos.x + off, pos.y - off});

big_explosion(pf, game, {pos.x - off, pos.y + off});
big_explosion(pf, game, {pos.x + off, pos.y - off});
});
game.on_timeout(milliseconds(100), [pos](Platform& pf, Game& game) {
for (int i = 0; i < 3; ++i) {
game.details().spawn<Item>(
sample<32>(pos), pf, Item::Type::heart);
}

game.transporter().set_position(pos);

screen_flash_animation(255)(pf, game);
});
});

pf.speaker().stop_music();
pf.sleep(10);

game.score() += 1000;

game.transporter().set_position(position_);
}
1 change: 1 addition & 0 deletions source/graphics/color.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ enum class ColorConstant {
safety_orange, // #FC7500
rich_black, // #000010
stil_de_grain, // #F9DC5C
silver_white, // #F4F4F8
count
};

Expand Down
16 changes: 8 additions & 8 deletions source/graphics/images.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// + 477 tiles not compressed
// Total size: 512 + 15264 = 15776
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:28
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -38,7 +38,7 @@ extern const unsigned short old_poster_flattenedPal[256];
// + 504 tiles not compressed
// Total size: 512 + 16128 = 16640
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:28
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -67,7 +67,7 @@ extern const unsigned short overlayPal[256];
// + 73 tiles not compressed
// Total size: 512 + 2336 = 2848
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:28
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -96,7 +96,7 @@ extern const unsigned short overlay_journalPal[256];
// + 1008 tiles Metatiled by 2x4 not compressed
// Total size: 512 + 32256 = 32768
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:27
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -125,7 +125,7 @@ extern const unsigned short spritesheetPal[256];
// + 1008 tiles Metatiled by 2x4 not compressed
// Total size: 512 + 32256 = 32768
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:27
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -154,7 +154,7 @@ extern const unsigned short spritesheet2Pal[256];
// + 1008 tiles Metatiled by 2x4 not compressed
// Total size: 512 + 32256 = 32768
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:28
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -183,7 +183,7 @@ extern const unsigned short spritesheet_boss0Pal[256];
// + 504 tiles Metatiled by 4x3 not compressed
// Total size: 512 + 16128 = 16640
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:28
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down Expand Up @@ -212,7 +212,7 @@ extern const unsigned short tilesheetPal[256];
// + 504 tiles Metatiled by 4x3 not compressed
// Total size: 512 + 16128 = 16640
//
// Time-stamp: 2020-04-23, 00:30:26
// Time-stamp: 2020-04-24, 00:08:28
// Exported by Cearn's GBA Image Transmogrifier, v
// ( http://www.coranac.com/projects/#grit )
//
Expand Down
6 changes: 3 additions & 3 deletions source/graphics/overlay.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,7 +377,7 @@ BossHealthBar::BossHealthBar(Platform& pfrm,
: pfrm_(pfrm), position_(position), height_(height)
{
pfrm_.set_overlay_tile(position_.x, position_.y, 82);
pfrm_.set_overlay_tile(position_.x, position_.y + height, 83);
pfrm_.set_overlay_tile(position_.x, position_.y + height + 1, 83);
set_health(0.f);
}

Expand All @@ -396,14 +396,14 @@ void BossHealthBar::set_health(Float percentage)
++current_tile;
}

if (current_tile < height_ + 1 and fractional_pixels % 8 not_eq 0) {
if (current_tile < height_ and fractional_pixels % 8 not_eq 0) {
pfrm_.set_overlay_tile(position_.x,
position_.y + 1 + current_tile,
83 + fractional_pixels % 8);
++current_tile;
}

while (current_tile < height_ + 1) {
while (current_tile < height_) {
pfrm_.set_overlay_tile(position_.x, position_.y + 1 + current_tile, 92);
++current_tile;
}
Expand Down
4 changes: 2 additions & 2 deletions source/graphics/overlay.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
@ + 504 tiles not compressed
@ Total size: 512 + 16128 = 16640
@
@ Time-stamp: 2020-04-23, 00:30:26
@ Time-stamp: 2020-04-24, 00:08:28
@ Exported by Cearn's GBA Image Transmogrifier, v
@ ( http://www.coranac.com/projects/#grit )
@
Expand Down Expand Up @@ -112,7 +112,7 @@ overlayTiles:
.word 0x44444444,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000
.word 0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000
.word 0x00000000,0x44444440,0x42444240,0x42222240,0x42424240,0x42222240,0x44222440,0x44444440
.word 0x44444440,0x44444440,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000
.word 0x44444440,0x44444440,0x44444440,0x00000000,0x00000000,0x00000000,0x00000000,0x00000000
.word 0x42222240,0x44444440,0x44444440,0x44444440,0x44444440,0x44444440,0x44444440,0x44444440
.word 0x42222240,0x42222240,0x44444440,0x44444440,0x44444440,0x44444440,0x44444440,0x44444440
.word 0x42222240,0x42222240,0x42222240,0x44444440,0x44444440,0x44444440,0x44444440,0x44444440
Expand Down
2 changes: 1 addition & 1 deletion source/number/numeric.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ inline UnitVec direction(const Vec2<Float>& origin, const Vec2<Float>& target)
}


inline Vec2<Float> rotate(const Vec2<Float>& input, Angle angle)
inline Vec2<Float> rotate(const Vec2<Float>& input, Float angle)
{
const s16 converted_angle = INT16_MAX * (angle / 360.f);
const Float cos_theta = Float(cosine(converted_angle)) / INT16_MAX;
Expand Down
4 changes: 4 additions & 0 deletions source/platform/gba_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,10 @@ const Color& real_color(ColorConstant k)
static const Color steel_blue(6, 10, 16);
return steel_blue;

case ColorConstant::silver_white:
static const Color silver_white(29, 29, 30);
return silver_white;

default:
case ColorConstant::null:
case ColorConstant::rich_black:
Expand Down

0 comments on commit 11bbdea

Please sign in to comment.