Skip to content
Open
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
2 changes: 2 additions & 0 deletions include/game/components.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include "components/battle/battlestate.h"
#include "components/battle/bullet_data.h"
#include "components/battle/pattern_container.h"
#include "components/battle/transition_data.h"

#include "components/bullethell/booming.h"
#include "components/bullethell/bullet.h"
#include "components/bullethell/bullet_clearer.h"
#include "components/bullethell/delay.h"
#include "components/bullethell/input.h"
#include "components/bullethell/laser.h"
Expand Down
20 changes: 1 addition & 19 deletions include/game/components/battle/battlestate.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,22 +86,6 @@ namespace Game::Battle
explicit BpmInfo(const unsigned int idx) : idx(idx)
{}
};

struct PhaseInfo
{
struct InfoPair
{
int timing;
CurrentPhase phase;
};
std::vector<InfoPair> phase_list;
unsigned int idx;
PhaseInfo() : idx(0)
{}
explicit PhaseInfo(const unsigned int idx) : idx(idx)
{}
};

// use these structures

struct BattleState
Expand Down Expand Up @@ -159,7 +143,6 @@ namespace Game::Battle
std::string genre_name;
float main_bpm;
BpmInfo bpm_info;
PhaseInfo phase_info;
std::vector<Difficulty> difficulties;
LevelData() : main_bpm(0)
{}
Expand All @@ -169,10 +152,9 @@ namespace Game::Battle
std::string genre_name,
const float main_bpm,
BpmInfo bpm_info,
PhaseInfo phase_info,
std::vector<Difficulty> difficulties) :
title(std::move(title)), artist_name(std::move(artist_name)), genre_name(std::move(genre_name)), main_bpm(main_bpm),
bpm_info(std::move(bpm_info)), phase_info(std::move(phase_info)), difficulties(std::move(difficulties))
bpm_info(std::move(bpm_info)), difficulties(std::move(difficulties))
{}
};
}
16 changes: 16 additions & 0 deletions include/game/components/battle/transition_data.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
#pragma once

namespace Game::Battle
{
struct TransitionData
{
int timing_start;
int duration;
CurrentPhase phase;

// State
uint8_t state = 4;
TransitionData(const int timing_start, const int duration, const CurrentPhase phase) : timing_start(timing_start), duration(duration), phase(phase)
{}
};
}
14 changes: 14 additions & 0 deletions include/game/components/bullethell/bullet_clearer.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#pragma once
#include "game/utils/physics_util.h"

namespace Game::BulletHell
{
struct BulletClearer
{
float max_size;
int speed;
int lifetime = static_cast<int>(UNASSIGNED);
BulletClearer() : max_size(10), speed(1) {}
BulletClearer(const float size, const int speed) : max_size(size), speed(speed) {}
};
} // namespace Game::BulletHell
2 changes: 1 addition & 1 deletion include/game/systems.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
// Bullet Hell Part
#include "game/systems/bullethell/bullet_collision.h"
#include "game/systems/bullethell/bullet_system.h"
#include "game/systems/bullethell/bullet_clearer_system.h"
#include "game/systems/bullethell/input_to_velocity.h"
#include "game/systems/bullethell/movement_system.h"
#include "game/systems/bullethell/bullet_collision.h"
Expand All @@ -24,7 +25,6 @@
#include "game/systems/rhythm/handle_miss_note.h"
#include "game/systems/rhythm/handle_bpm.h"
#include "game/systems/rhythm/load_notes.h"
#include "game/systems/rhythm/test_rhythm.h"
// General Battle Part
#include "game/systems/phase_change.h"
#include "game/systems/global_clock.h"
Expand Down
44 changes: 44 additions & 0 deletions include/game/systems/bullethell/bullet_clearer_system.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#pragma once

#include "game/components.h"
#include "game/systems/global_clock.h"

namespace Game::BulletHell
{
template<typename T>
void bullet_clearer_system(
[[maybe_unused]] T &syscall,
System::ECS::Query<BulletClearer, Render::Material, Physics::Position, Physics::Scale, Particle> &query,
System::ECS::Query<Bullet, Physics::Position> &bullet_query,
System::ECS::Query<Battle::BattleState> &query2)
{
if (query2.begin() == query2.end())
return;

for (auto &[id, comps] : query)
{
auto &bullet_clearer = comps.get<BulletClearer>();
auto &scale = comps.get<Physics::Scale>();
auto &material = comps.get<Render::Material>();

if (bullet_clearer.lifetime == UNASSIGNED) bullet_clearer.lifetime = comps.get<Particle>().lifetime;

// Growing
scale.scaleX = scale.scaleY = Physics::clamp(static_cast<float>(scale.scaleX + bullet_clearer.speed * get_delta_time()),0.f,bullet_clearer.max_size);
material.color.a = static_cast<float>(comps.get<Particle>().lifetime/bullet_clearer.lifetime);

//Check Bullet in Range
for (auto &[id2, comps2] : bullet_query)
{
const float dx = comps2.get<Physics::Position>().x - comps.get<Physics::Position>().x;
const float dy = comps2.get<Physics::Position>().y - comps.get<Physics::Position>().y;
const float distance_squared = dx * dx + dy * dy;
if (distance_squared <= scale.scaleX*scale.scaleX)
{
syscall.remove_entity(id2);
}
}

}
}
} // namespace Game::BulletHell
11 changes: 7 additions & 4 deletions include/game/systems/bullethell/bullet_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@ namespace Game::BulletHell
if (query2.begin() == query2.end())
return;

if (query2.front().get<Battle::BattleState>().current_phase != Battle::CurrentPhase::BULLET_HELL)
{
return;
}


for (auto &[id, comps] : query)
{
if (query2.front().get<Battle::BattleState>().current_phase != Battle::CurrentPhase::BULLET_HELL)
{
syscall.remove_entity(id);
return;
}

auto &bullet = comps.get<Bullet>();
const auto &delay = comps.get<Delay>();

Expand Down
3 changes: 3 additions & 0 deletions include/game/systems/bullethell/logging_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,12 @@ namespace Game::BulletHell
if (battle_state.current_phase != Battle::CurrentPhase::BULLET_HELL)
return;

if (battle_state.clock_time/1000 % 250 > 2) return;

LOG_INFO("----------------------------------");

// const auto &bullet_loader = query.front().get<Battle::BulletLoader>();

LOG_INFO("Time : %d.%d%d", battle_state.clock_time/1000000, battle_state.clock_time/10000 - (battle_state.clock_time/1000000)*100);

LOG_INFO("Hp : %d, iFrame : %d, Graze : %d, Bullet Pointer : %d", battle_state.hp, query.front().get<Battle::BulletHellState>().iframe_time, query.front().get<Battle::BulletHellState>().graze, query.front().get<Battle::BulletLoader>().pointer);//bullet_loader.pointer);
Expand Down
2 changes: 1 addition & 1 deletion include/game/systems/global_clock.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ namespace Game::Battle
battle_query.front().get<BattleState>().clock_time += static_cast<int>(get_delta_time() * 1000);

auto time = battle_query.front().get<BattleState>().clock_time / 1000;
if (time % 1000 < 10)
if (time % 1000 < 3)
LOG_INFO("Time: %d s", time / 1000);
}
}
43 changes: 34 additions & 9 deletions include/game/systems/phase_change.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,47 @@ namespace Game::Battle
{
template<typename T>
void phase_change(
[[maybe_unused]] T &syscall, System::ECS::Query<LevelData> &query, System::ECS::Query<BattleState> &query2)
[[maybe_unused]] T &syscall, System::ECS::Query<TransitionData> &query, System::ECS::Query<BattleState> &query2)
{
if (query.begin() == query.end())
return;
if (query2.begin() == query2.end())
return;

auto &battle_state = query2.front().get<BattleState>();
auto &level_data = query.front().get<LevelData>();
auto &phase_info = level_data.phase_info;

while (phase_info.idx < phase_info.phase_list.size() &&
phase_info.phase_list.at(phase_info.idx).timing <= battle_state.clock_time)
for (auto &[id, comps] : query)
{
battle_state.current_phase = phase_info.phase_list.at(phase_info.idx).phase;
phase_info.idx++;
auto &transition_data = comps.get<TransitionData>();
if (transition_data.timing_start > battle_state.clock_time/1000)
{
continue;
}

if (transition_data.state == 4 && transition_data.timing_start < battle_state.clock_time/1000)
{
LOG_INFO("Scene changing in 3");
transition_data.state = 3;
}
else if (transition_data.state == 3 && transition_data.timing_start + transition_data.duration/3 < battle_state.clock_time/1000)
{
LOG_INFO("Scene changing in 2");
transition_data.state = 2;
}
else if (transition_data.state == 2 && transition_data.timing_start + transition_data.duration*2/3 < battle_state.clock_time/1000)
{
LOG_INFO("Scene changing in 1");
transition_data.state = 1;
}
else if (transition_data.state == 1 && transition_data.timing_start + transition_data.duration < battle_state.clock_time/1000)
{
if (transition_data.phase == BULLET_HELL)
LOG_INFO("Scene has changed to CALL")
else if (transition_data.phase == RHYTHM)
LOG_INFO("Scene has changed to RESPONSE")
battle_state.current_phase = transition_data.phase;
syscall.remove_entity(id);
}
}


}
} // namespace Game::Battle
4 changes: 4 additions & 0 deletions include/game/systems/rhythm/handle_miss_note.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,16 @@ namespace Game::Rhythm
{
battle_query.front().get<Battle::BattleState>().judgement_count.miss_count += 1;
LOG_INFO("Timing %d Lane %d: Tap Miss", note_time, comps.get<Lane>().lane);
LOG_INFO("Miss Count = %d", battle_query.front().get<Battle::BattleState>().judgement_count.miss_count);
}
else if (comps.get<HoldActive>().hold_active == false) // hold note miss (not held at all)
{
battle_query.front().get<Battle::BattleState>().judgement_count.miss_count += 2;
LOG_INFO("Timing %d Lane %d: Hold Miss", note_time, comps.get<Lane>().lane);
LOG_INFO("Miss Count = %d", battle_query.front().get<Battle::BattleState>().judgement_count.miss_count);
}
else continue; // for hold notes that are still active

syscall.remove_entity(id);
}
// Handle miss for an entire hold note, which counts as two misses (start and end)
Expand Down
Loading