Skip to content

Commit 4617b48

Browse files
committed
light the candles by copyrat90 merged
1 parent 0ef2532 commit 4617b48

File tree

56 files changed

+1364
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1364
-0
lines changed

audio/cr90_ltcd_correct.wav

34 KB
Binary file not shown.

audio/cr90_ltcd_credits.txt

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
cr90_ltcd_set_fire.wav
2+
kingsrow
3+
CC0 1.0 Universal (CC0 1.0)
4+
https://freesound.org/people/kingsrow/sounds/181578/
5+
6+
cr90_ltcd_correct.wav
7+
copyrat90
8+
CC0 1.0 Universal (CC0 1.0)
9+
https://github.com/copyrat90

audio/cr90_ltcd_set_fire.wav

32.5 KB
Binary file not shown.

dmg_audio/cr90_ltcd_credits.txt

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
cr90_ltcd_spooky_birthday_t*.vgm
2+
copyrat90
3+
CC0 1.0 Universal (CC0 1.0)
4+
https://github.com/copyrat90/my-gb-songs/blob/main/dmg_audio/furnace/spooky_birthday.fur
5.54 KB
Binary file not shown.
5.4 KB
Binary file not shown.
5.23 KB
Binary file not shown.
5.1 KB
Binary file not shown.
4.97 KB
Binary file not shown.
4.86 KB
Binary file not shown.
4.73 KB
Binary file not shown.
4.63 KB
Binary file not shown.
4.52 KB
Binary file not shown.
4.45 KB
Binary file not shown.
4.35 KB
Binary file not shown.
4.28 KB
Binary file not shown.
4.19 KB
Binary file not shown.
4.11 KB
Binary file not shown.
4.04 KB
Binary file not shown.
3.98 KB
Binary file not shown.

graphics/cr90_ltcd_black.bmp

32.1 KB
Binary file not shown.

graphics/cr90_ltcd_black.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "regular_bg"
3+
}

graphics/cr90_ltcd_cake.bmp

32.1 KB
Binary file not shown.

graphics/cr90_ltcd_cake.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"type": "regular_bg"
3+
}

graphics/cr90_ltcd_candle.bmp

4.12 KB
Binary file not shown.

graphics/cr90_ltcd_candle.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 64
4+
}

graphics/cr90_ltcd_credits.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
cr90_ltcd_black.bmp
2+
cr90_ltcd_cake.bmp
3+
cr90_ltcd_candle.bmp
4+
cr90_ltcd_flying_candle.bmp
5+
cr90_ltcd_matchstick.bmp
6+
cr90_ltcd_light_w8.bmp
7+
cr90_ltcd_light_w16.bmp
8+
cr90_ltcd_light_w32.bmp
9+
cr90_ltcd_light_w64.bmp
10+
copyrat90
11+
CC0 1.0 Universal (CC0 1.0)
12+
https://github.com/copyrat90

graphics/cr90_ltcd_flying_candle.bmp

4.12 KB
Binary file not shown.

graphics/cr90_ltcd_flying_candle.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 64
4+
}

graphics/cr90_ltcd_light_w16.bmp

630 Bytes
Binary file not shown.

graphics/cr90_ltcd_light_w16.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 16
4+
}

graphics/cr90_ltcd_light_w32.bmp

4.12 KB
Binary file not shown.

graphics/cr90_ltcd_light_w32.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 32
4+
}

graphics/cr90_ltcd_light_w64.bmp

32.1 KB
Binary file not shown.

graphics/cr90_ltcd_light_w64.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 64
4+
}

graphics/cr90_ltcd_light_w8.bmp

278 Bytes
Binary file not shown.

graphics/cr90_ltcd_light_w8.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 8
4+
}

graphics/cr90_ltcd_matchstick.bmp

8.12 KB
Binary file not shown.

graphics/cr90_ltcd_matchstick.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"type": "sprite",
3+
"height": 64
4+
}

include/cr90_ltcd_Candle.h

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
// SPDX-FileCopyrightText: Copyright 2023 copyrat90 <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include "cr90_ltcd_Fireable.h"
7+
8+
#include "bn_optional.h"
9+
#include "bn_sprite_animate_actions.h"
10+
#include "bn_sprite_ptr.h"
11+
12+
namespace cr90::ltcd
13+
{
14+
15+
class Candle final : public Fireable
16+
{
17+
public:
18+
Candle(const bn::fixed_point& position, bool fire, bool flying, bn::fixed game_speed);
19+
20+
void update(const mj::game_data&, Game&) override;
21+
22+
public:
23+
bool flying() const;
24+
25+
void set_fire(bool) override;
26+
27+
public:
28+
void set_position(const bn::fixed_point&) override;
29+
void set_x(bn::fixed) override;
30+
void set_y(bn::fixed) override;
31+
32+
private:
33+
const bool _flying;
34+
35+
bn::sprite_ptr _spr_candle;
36+
bn::optional<bn::sprite_animate_action<4>> _anim;
37+
};
38+
39+
} // namespace cr90::ltcd

include/cr90_ltcd_CircleCollider.h

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
// SPDX-FileCopyrightText: Copyright 2023 copyrat90 <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include "cr90_ltcd_Entity.h"
7+
8+
namespace cr90::ltcd
9+
{
10+
11+
class CircleCollider : public Entity
12+
{
13+
public:
14+
CircleCollider(const bn::fixed_point position, bn::fixed radius);
15+
16+
bool collide_with(const CircleCollider& other) const;
17+
18+
private:
19+
bn::fixed _radius;
20+
};
21+
22+
} // namespace cr90::ltcd

include/cr90_ltcd_CircleLight.h

+62
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// SPDX-FileCopyrightText: Copyright 2023 copyrat90 <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include "cr90_ltcd_Entity.h"
7+
8+
#include "bn_span.h"
9+
#include "bn_sprite_ptr.h"
10+
#include "bn_vector.h"
11+
12+
namespace cr90::ltcd
13+
{
14+
15+
class CircleLight final : public Entity
16+
{
17+
public:
18+
static constexpr int MAX_FRAMES = 8;
19+
20+
static constexpr int MIN_RADIUS = 0;
21+
static constexpr int MAX_RADIUS = 32;
22+
23+
public:
24+
CircleLight(const bn::fixed_point& position, int radius);
25+
26+
void update(const mj::game_data&, Game&) override;
27+
28+
public:
29+
/**
30+
* @brief Set the `CircleLight` sprite radius.
31+
* Calling this stops animation, too.
32+
*
33+
* @param radius radius in the range [0..32].
34+
*/
35+
void set_radius(int radius);
36+
37+
/**
38+
* @brief Set the `CircleLight` sprite animation.
39+
*
40+
* @param radiuses radiuses in the range [0..32]. max frames are 8.
41+
*/
42+
void set_radius_animation(bool forever, int wait_updates, const bn::span<const uint16_t>& radiuses);
43+
44+
bool animation_running() const;
45+
46+
public:
47+
void set_position(const bn::fixed_point&) override;
48+
void set_x(bn::fixed) override;
49+
void set_y(bn::fixed) override;
50+
51+
private:
52+
bn::sprite_ptr _spr;
53+
int _radius;
54+
55+
bn::vector<uint16_t, MAX_FRAMES> _radiuses;
56+
int _wait_updates = 0;
57+
int _current_radiuses_index = 0;
58+
int _current_wait_updates = 0;
59+
bool _forever = true;
60+
};
61+
62+
} // namespace cr90::ltcd

include/cr90_ltcd_Entity.h

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// SPDX-FileCopyrightText: Copyright 2023 copyrat90 <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include "bn_fixed_point.h"
7+
8+
namespace mj
9+
{
10+
struct game_data;
11+
}
12+
13+
namespace cr90::ltcd
14+
{
15+
16+
class Game;
17+
18+
class Entity
19+
{
20+
public:
21+
virtual ~Entity() = 0;
22+
Entity(const bn::fixed_point& position);
23+
24+
virtual void handle_input(const mj::game_data&, Game&){}
25+
virtual void update(const mj::game_data&, Game&){}
26+
27+
public:
28+
auto position() const -> const bn::fixed_point&;
29+
auto x() const -> bn::fixed;
30+
auto y() const -> bn::fixed;
31+
32+
virtual void set_position(const bn::fixed_point&);
33+
virtual void set_x(bn::fixed);
34+
virtual void set_y(bn::fixed);
35+
36+
private:
37+
bn::fixed_point _position;
38+
};
39+
40+
} // namespace cr90::ltcd

include/cr90_ltcd_EntityActions.h

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// SPDX-FileCopyrightText: Copyright 2023 copyrat90 <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include "bn_value_template_actions.h"
7+
8+
#include <functional>
9+
10+
#include "cr90_ltcd_Entity.h"
11+
12+
namespace cr90::ltcd
13+
{
14+
15+
class EntityPositionManager
16+
{
17+
public:
18+
static auto get(const std::reference_wrapper<Entity> entity) -> const bn::fixed_point&
19+
{
20+
return entity.get().position();
21+
}
22+
23+
static void set(const bn::fixed_point& position, std::reference_wrapper<Entity> entity)
24+
{
25+
entity.get().set_position(position);
26+
}
27+
};
28+
29+
class EntityMoveLoopAction
30+
: public bn::loop_value_template_action<std::reference_wrapper<Entity>, bn::fixed_point, EntityPositionManager>
31+
{
32+
public:
33+
EntityMoveLoopAction(Entity& entity, int duration_updates, const bn::fixed_point& final_position)
34+
: loop_value_template_action(entity, duration_updates, final_position)
35+
{
36+
}
37+
38+
EntityMoveLoopAction(Entity& entity, int duration_updates, bn::fixed final_x, bn::fixed final_y)
39+
: loop_value_template_action(entity, duration_updates, bn::fixed_point(final_x, final_y))
40+
{
41+
}
42+
};
43+
44+
} // namespace cr90::ltcd

include/cr90_ltcd_Fireable.h

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-FileCopyrightText: Copyright 2023 copyrat90 <[email protected]>
2+
// SPDX-License-Identifier: MIT
3+
4+
#pragma once
5+
6+
#include "cr90_ltcd_Entity.h"
7+
8+
#include "cr90_ltcd_CircleCollider.h"
9+
#include "cr90_ltcd_CircleLight.h"
10+
11+
namespace cr90::ltcd
12+
{
13+
14+
class Fireable : public Entity
15+
{
16+
public:
17+
virtual ~Fireable() = 0;
18+
Fireable(const bn::fixed_point& position, bool fire, int light_median_radius, bn::fixed collider_radius,
19+
int particle_emit_interval, const bn::fixed_point& light_diff = {},
20+
const bn::fixed_point& collider_diff = {});
21+
22+
void update(const mj::game_data&, Game&) override;
23+
24+
public:
25+
bool fire() const;
26+
virtual void set_fire(bool);
27+
28+
auto collider() const -> const CircleCollider&;
29+
30+
public:
31+
void set_position(const bn::fixed_point&) override;
32+
void set_x(bn::fixed) override;
33+
void set_y(bn::fixed) override;
34+
35+
private:
36+
const bn::fixed_point _light_diff;
37+
const bn::fixed_point _collider_diff;
38+
39+
const int _light_median_radius;
40+
const int _particle_emit_interval;
41+
42+
CircleLight _light;
43+
CircleCollider _collider;
44+
45+
int _particle_emit_countdown;
46+
bool _fire;
47+
};
48+
49+
} // namespace cr90::ltcd

0 commit comments

Comments
 (0)