-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
63 additions
and
81 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,36 @@ | ||
#pragma once | ||
#include <bave/core/polymorphic.hpp> | ||
#include <bave/core/time.hpp> | ||
#include <bave/graphics/drawable.hpp> | ||
#include <bave/graphics/rect.hpp> | ||
#include <bave/graphics/particle_system.hpp> | ||
#include <bave/graphics/shape.hpp> | ||
#include <bave/services/services.hpp> | ||
#include <spaced/services/layout.hpp> | ||
|
||
namespace spaced { | ||
class Player; | ||
|
||
class IPowerup : public bave::IDrawable { | ||
class Powerup : public bave::IDrawable { | ||
public: | ||
[[nodiscard]] virtual auto get_bounds() const -> bave::Rect<> = 0; | ||
virtual void activate(Player& player) = 0; | ||
explicit Powerup(bave::Services const& services, std::string_view name); | ||
|
||
[[nodiscard]] virtual auto is_destroyed() const -> bool = 0; | ||
void tick(bave::Seconds dt); | ||
void draw(bave::Shader& shader) const final; | ||
|
||
virtual void tick(bave::Seconds dt) = 0; | ||
[[nodiscard]] auto get_bounds() const -> bave::Rect<> { return shape.get_bounds(); } | ||
void activate(Player& player); | ||
|
||
[[nodiscard]] auto is_destroyed() const -> bool { return m_destroyed; } | ||
|
||
float speed{300.0f}; | ||
bave::CircleShape shape{}; | ||
bave::ParticleEmitter emitter{}; | ||
|
||
protected: | ||
virtual void do_activate(Player& player) = 0; | ||
|
||
bave::NotNull<bave::Services const*> m_services; | ||
bave::NotNull<Layout const*> m_layout; | ||
std::string_view m_name{}; | ||
bool m_emitter_ticked{}; | ||
bool m_destroyed{}; | ||
}; | ||
} // namespace spaced |
10 changes: 5 additions & 5 deletions
10
src/spaced/spaced/game/powerups/pu_beam.cpp → src/spaced/spaced/game/powerups/beam.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,20 @@ | ||
#include <bave/services/styles.hpp> | ||
#include <spaced/game/player.hpp> | ||
#include <spaced/game/powerups/pu_beam.hpp> | ||
#include <spaced/game/powerups/beam.hpp> | ||
#include <spaced/game/weapons/gun_beam.hpp> | ||
|
||
namespace spaced { | ||
namespace spaced::powerup { | ||
using bave::Services; | ||
using bave::Styles; | ||
|
||
PUBeam::PUBeam(Services const& services, int rounds) : PUBase(services, "Beam"), m_rounds(rounds) { | ||
Beam::Beam(Services const& services, int rounds) : Powerup(services, "Beam"), m_rounds(rounds) { | ||
emitter.config.lerp.tint.lo = emitter.config.lerp.tint.hi = shape.tint = services.get<Styles>().rgbas["gun_beam"]; | ||
emitter.config.lerp.tint.hi.channels.w = 0; | ||
} | ||
|
||
void PUBeam::do_activate(Player& player) { | ||
void Beam::do_activate(Player& player) { | ||
auto beam = std::make_unique<GunBeam>(*m_services); | ||
beam->rounds = m_rounds; | ||
player.set_special_weapon(std::move(beam)); | ||
} | ||
} // namespace spaced | ||
} // namespace spaced::powerup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#pragma once | ||
#include <spaced/game/powerup.hpp> | ||
|
||
namespace spaced::powerup { | ||
class Beam : public Powerup { | ||
public: | ||
explicit Beam(bave::Services const& services, int rounds = 2); | ||
|
||
private: | ||
void do_activate(Player& player) final; | ||
|
||
int m_rounds{}; | ||
}; | ||
} // namespace spaced::powerup |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters