Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,4 @@ compile_commands.json
imgui.ini
bave*.log
/spaced
/notes.txt
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ set(CMAKE_CXX_EXTENSIONS OFF)
include(FetchContent)

FetchContent_Declare(
bave
GIT_REPOSITORY https://github.com/karnkaul/bave
GIT_TAG v0.5.4
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/bave"
bgf
GIT_REPOSITORY https://github.com/karnkaul/bgf
GIT_TAG v0.1.0
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ext/bgf"
)

FetchContent_MakeAvailable(bave)
FetchContent_MakeAvailable(bgf)

add_subdirectory(src)
Binary file added assets/fonts/CuteDino.otf
Binary file not shown.
Binary file removed assets/fonts/hesitation.regular.ttf
Binary file not shown.
12 changes: 6 additions & 6 deletions assets/styles.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@
"padding": 10
},
"enemy": {
"background": "#f75c03ff",
"fill": "#ffffffff",
"background": "orange",
"fill": "milk",
"corner_ratio": 0.5,
"padding": 5
}
Expand All @@ -50,9 +50,9 @@
10.000000
],
"corner_ratio": 0.25,
"background_tint": "#e5cdaeff",
"outline_tint": "#231d2aff",
"content_text_tint": "#231d2aff"
"background_tint": "milk",
"outline_tint": "black",
"content_text_tint": "black"
}
},
"sliders": {
Expand All @@ -63,7 +63,7 @@
}
},
"loading_screen": {
"background_tint": "#231d2aff",
"background_tint": "black",
"spinner": {
"size": [
100.000000,
Expand Down
4 changes: 3 additions & 1 deletion src/spaced/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ add_library(${PROJECT_NAME})
add_library(spaced::lib ALIAS ${PROJECT_NAME})

target_link_libraries(${PROJECT_NAME} PUBLIC
bave::bave
bave::bgf
bave::bave-compile-options
)

Expand All @@ -19,3 +19,5 @@ target_include_directories(${PROJECT_NAME} PUBLIC
file(GLOB_RECURSE sources LIST_DIRECTORIES false CONFIGURE_DEPENDS "spaced/*.?pp")

target_sources(${PROJECT_NAME} PRIVATE ${sources})

target_precompile_headers(${PROJECT_NAME} REUSE_FROM bave)
5 changes: 4 additions & 1 deletion src/spaced/spaced/assets/asset_list.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include <bave/services/resources.hpp>
#include <spaced/assets/asset_list.hpp>
#include <spaced/assets/asset_loader.hpp>
#include <spaced/services/resources.hpp>

namespace spaced {
using bave::AsyncExec;
using bave::Loader;
using bave::Resources;
using bave::Services;

AssetList::AssetList(Loader loader, Services const& services) : m_loader(std::move(loader)), m_resources(&services.get<Resources>()) {}

Expand Down
20 changes: 12 additions & 8 deletions src/spaced/spaced/assets/asset_list.hpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
#pragma once
#include <bave/async_exec.hpp>
#include <bave/loader.hpp>
#include <bave/services/resources.hpp>
#include <bave/services/services.hpp>
#include <spaced/assets/asset_manifest.hpp>
#include <spaced/async_exec.hpp>
#include <spaced/services/services.hpp>
#include <set>

namespace spaced {
namespace bave {
struct Resources;
}

namespace spaced {
class AssetLoader;

class AssetList {
public:
explicit AssetList(bave::Loader loader, Services const& services);
explicit AssetList(bave::Loader loader, bave::Services const& services);

auto add_texture(std::string uri, bool mip_map = false) -> AssetList&;
auto add_font(std::string uri) -> AssetList&;
Expand All @@ -20,7 +24,7 @@ class AssetList {

void add_manifest(AssetManifest manifest);

[[nodiscard]] auto build_task_stages() const -> std::vector<AsyncExec::Stage>;
[[nodiscard]] auto build_task_stages() const -> std::vector<bave::AsyncExec::Stage>;

private:
struct Tex {
Expand All @@ -32,11 +36,11 @@ class AssetList {
auto operator<(Tex const& rhs) const -> bool { return uri < rhs.uri; }
};

auto build_stage_0(AssetLoader& asset_loader) const -> AsyncExec::Stage;
auto build_stage_1(AssetLoader& asset_loader) const -> AsyncExec::Stage;
auto build_stage_0(AssetLoader& asset_loader) const -> bave::AsyncExec::Stage;
auto build_stage_1(AssetLoader& asset_loader) const -> bave::AsyncExec::Stage;

bave::Loader m_loader;
bave::NotNull<Resources*> m_resources;
bave::NotNull<bave::Resources*> m_resources;

std::set<Tex> m_textures{};
std::set<std::string> m_fonts{};
Expand Down
1 change: 1 addition & 0 deletions src/spaced/spaced/assets/asset_loader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ using bave::Loader;
using bave::Logger;
using bave::NotNull;
using bave::ParticleEmitter;
using bave::Resources;
using bave::Texture;

struct AssetLoader::Impl {
Expand Down
4 changes: 2 additions & 2 deletions src/spaced/spaced/assets/asset_loader.hpp
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include <bave/core/ptr.hpp>
#include <bave/loader.hpp>
#include <spaced/services/resources.hpp>
#include <bave/services/resources.hpp>
#include <functional>
#include <memory>

Expand All @@ -10,7 +10,7 @@ class AssetLoader {
public:
using LoadTask = std::function<void()>;

explicit AssetLoader(bave::Loader loader, bave::NotNull<Resources*> resources);
explicit AssetLoader(bave::Loader loader, bave::NotNull<bave::Resources*> resources);

[[nodiscard]] auto make_load_font(std::string uri, bool reload = false) -> LoadTask;
[[nodiscard]] auto make_load_texture(std::string uri, bool mip_map = false, bool reload = false) -> LoadTask;
Expand Down
60 changes: 0 additions & 60 deletions src/spaced/spaced/async_exec.cpp

This file was deleted.

45 changes: 0 additions & 45 deletions src/spaced/spaced/async_exec.hpp

This file was deleted.

1 change: 1 addition & 0 deletions src/spaced/spaced/game/arsenal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

namespace spaced {
using bave::Seconds;
using bave::Services;
using bave::Shader;

Arsenal::Arsenal(Services const& services) : m_primary(services), m_stats(&services.get<Stats>()) {}
Expand Down
2 changes: 1 addition & 1 deletion src/spaced/spaced/game/arsenal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ struct Stats;
// Weapons only switch when they are idle.
class Arsenal {
public:
explicit Arsenal(Services const& services);
explicit Arsenal(bave::Services const& services);

[[nodiscard]] auto get_weapon() const -> Weapon const&;
[[nodiscard]] auto get_weapon() -> Weapon&;
Expand Down
2 changes: 1 addition & 1 deletion src/spaced/spaced/game/controllers/auto_controller.hpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
#pragma once
#include <bave/core/ptr.hpp>
#include <bave/input/gamepad.hpp>
#include <bave/services/services.hpp>
#include <spaced/game/controllers/follow_controller.hpp>
#include <spaced/game/spring_arm.hpp>
#include <spaced/game/target_provider.hpp>
#include <spaced/services/gamepad_provider.hpp>
#include <spaced/services/layout.hpp>
#include <spaced/services/services.hpp>

namespace spaced {
class AutoController : public FollowController {
Expand Down
12 changes: 7 additions & 5 deletions src/spaced/spaced/game/controllers/player_controller.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,20 @@ using bave::Action;
using bave::EnumArray;
using bave::GamepadAxis;
using bave::GamepadButton;
using bave::IDisplay;
using bave::im_text;
using bave::PointerMove;
using bave::PointerTap;
using bave::Seconds;
using bave::Services;

PlayerController::PlayerController(Services const& services) : m_layout(&services.get<ILayout>()), m_gamepad_provider(&services.get<IGamepadProvider>()) {
max_y = 0.5f * m_layout->get_world_space().y;
PlayerController::PlayerController(Services const& services) : m_display(&services.get<IDisplay>()), m_gamepad_provider(&services.get<IGamepadProvider>()) {
max_y = 0.5f * m_display->get_world_space().y;
min_y = -max_y; // NOLINT(cppcoreguidelines-prefer-member-initializer)
}

void PlayerController::on_move(PointerMove const& pointer_move) {
auto const world_pos = m_layout->project_to_world(pointer_move.pointer.position);
auto const world_pos = m_display->project_to_world(pointer_move.pointer.position);

if (m_type == Type::eTouch) {
if (!is_in_move_area(world_pos)) {
Expand All @@ -39,7 +41,7 @@ void PlayerController::on_move(PointerMove const& pointer_move) {
}

void PlayerController::on_tap(PointerTap const& pointer_tap) {
auto const world_pos = m_layout->project_to_world(pointer_tap.pointer.position);
auto const world_pos = m_display->project_to_world(pointer_tap.pointer.position);
if (m_type == Type::eTouch && is_in_move_area(world_pos)) {
// pointer tap in move area is ingored
return;
Expand All @@ -66,7 +68,7 @@ void PlayerController::stop_firing() {
}

auto PlayerController::is_in_move_area(glm::vec2 const position) const -> bool {
auto const n_pos = position.x / m_layout->get_world_space().x;
auto const n_pos = position.x / m_display->get_world_space().x;
return n_pos <= -n_move_area;
}

Expand Down
8 changes: 4 additions & 4 deletions src/spaced/spaced/game/controllers/player_controller.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#pragma once
#include <bave/core/ptr.hpp>
#include <bave/input/gamepad.hpp>
#include <bave/services/display.hpp>
#include <bave/services/services.hpp>
#include <spaced/game/controllers/follow_controller.hpp>
#include <spaced/game/spring_arm.hpp>
#include <spaced/services/gamepad_provider.hpp>
#include <spaced/services/layout.hpp>
#include <spaced/services/services.hpp>

namespace spaced {
class PlayerController : public FollowController {
Expand All @@ -18,7 +18,7 @@ class PlayerController : public FollowController {

[[nodiscard]] auto get_type_name() const -> std::string_view final { return type_name_v; };

explicit PlayerController(Services const& services);
explicit PlayerController(bave::Services const& services);

void on_move(bave::PointerMove const& pointer_move) final;
void on_tap(bave::PointerTap const& pointer_tap) final;
Expand All @@ -45,7 +45,7 @@ class PlayerController : public FollowController {
auto tick_y(bave::Seconds dt) -> float final;
void do_inspect() final;

bave::Ptr<ILayout const> m_layout{};
bave::Ptr<bave::IDisplay const> m_display{};
bave::Ptr<IGamepadProvider const> m_gamepad_provider{};

Type m_type{};
Expand Down
2 changes: 1 addition & 1 deletion src/spaced/spaced/game/enemies/creep.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ void Creep::tick(Seconds const dt, bool const in_play) {
if (!in_play) { return; }

shape.transform.position.x -= x_speed * dt.count();
if (shape.transform.position.x < -0.5f * (get_layout().get_world_space().x + shape.get_shape().size.x)) { set_destroyed(); }
if (shape.transform.position.x < -0.5f * (get_layout().world_space.x + shape.get_shape().size.x)) { set_destroyed(); }
}
} // namespace spaced
2 changes: 1 addition & 1 deletion src/spaced/spaced/game/enemies/creep.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
namespace spaced {
class Creep : public Enemy {
public:
explicit Creep(Services const& services) : Enemy(services, "Creep") {}
explicit Creep(bave::Services const& services) : Enemy(services, "Creep") {}

void tick(bave::Seconds dt, bool in_play) override;

Expand Down
Loading