Skip to content
This repository was archived by the owner on Jul 17, 2024. It is now read-only.
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
10 changes: 8 additions & 2 deletions Engine/Game.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,18 @@ namespace {
return SDL_Init(SDL_INIT_EVERYTHING) == 0;
}

//Improve accuracy frame limiter
double FrameLimit(double MaxFrameRate) {
double newTick = SDL_GetTicks();
double deltaTick = 1000.0 / MaxFrameRate - (newTick - lastTick);

if (floor(deltaTick) > 0) {
SDL_Delay((DWORD)floor(deltaTick));
if (deltaTick > 0.0) {
int delayTicks = (int)deltaTick;
if (delayTicks > 0) {
SDL_Delay(delayTicks);
newTick += delayTicks;
deltaTick -= delayTicks;
}
}

if (deltaTick < -30.0) {
Expand Down
6 changes: 3 additions & 3 deletions Engine/Sprite2D.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ Sprite2D::Sprite2D(std::vector<std::string> textures, float delay) {
AnchorPoint = { 0, 0 };

for (auto& it : textures) {
m_textures.push_back(new Texture2D(it));
m_textures.emplace_back(new Texture2D(it));
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any difference performance on this changes?

}
}

Expand All @@ -29,7 +29,7 @@ Sprite2D::Sprite2D(std::vector<std::filesystem::path> textures, float delay) {
AnchorPoint = { 0, 0 };

for (auto& it : textures) {
m_textures.push_back(new Texture2D(it));
m_textures.emplace_back(new Texture2D(it));
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you're loading a texture in your code, it's better to use 'emplace_back' instead of 'push_back' if you're not loading a string or a file. 'Push_back' should only be used if you want to load files like BMS, OJN, or OSU.

}
}

Expand All @@ -40,7 +40,7 @@ Sprite2D::Sprite2D(std::vector<ID3D11ShaderResourceView*> textures, float delay)
AnchorPoint = { 0, 0 };

for (auto& it : textures) {
m_textures.push_back(new Texture2D(it));
m_textures.emplace_back(new Texture2D(it));
}
}

Expand Down
4 changes: 2 additions & 2 deletions Game/Engine/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ ScoreManager::ScoreManager() {
m_maxJamCombo = 0;

m_numOfPills = 0;
m_life = 80;
m_life = 100;

m_lnCombo = 0;
m_lnMaxCombo = 0;
Expand All @@ -33,7 +33,7 @@ void ScoreManager::OnHit(NoteHitInfo info) {
switch (info.Result) {
case NoteResult::COOL: {
AddLife(1);
m_jamGauge += 5;
m_jamGauge += 4;
m_score += 100;
m_cool++;
break;
Expand Down
1 change: 1 addition & 0 deletions Game/Game.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,7 @@
<ClInclude Include="Engine\TimingLineManager.hpp" />
<ClInclude Include="Engine\TimingLine.hpp" />
<ClInclude Include="Resources\iterable_queue.hpp" />
<ResourceCompile Include="icon.rc" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
Expand Down
69 changes: 47 additions & 22 deletions Game/GameplayScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ GameplayScene::GameplayScene() : Scene::Scene() {
m_keyState = {};
m_game = nullptr;
m_drawJam = false;
m_wiggleAdd = 0;
m_lnWiggleAdd = 0;
m_wiggleTime = 0;
m_wiggleOffsets = 0;
}

void GameplayScene::Update(double delta) {
Expand Down Expand Up @@ -64,15 +64,29 @@ void GameplayScene::Render(double delta) {

if (m_drawCombo) {
if (std::get<7>(scores) > 0) {
m_comboLogo->Position2 = UDim2::fromOffset(0, m_wiggleAdd);
m_comboLogo->Draw(delta);
double m_wiggleTime = m_comboTimer * 50; // Combo animated by Frame per second
double m_wiggleOffset = std::sin(m_wiggleTime) * 25.0; // Amplitude

m_comboNum->Position2 = UDim2::fromOffset(0, m_wiggleAdd);
m_comboNum->DrawNumber(std::get<7>(scores));
if (m_wiggleTime < M_PI) {
m_comboLogo->Size = UDim2::fromScale(1.0, 1.0); // set fixed size
m_comboLogo->Position2 = UDim2::fromOffset(0, m_wiggleOffset / 2.5);
m_comboLogo->Draw(delta);

m_comboNum->Position2 = UDim2::fromOffset(0, m_wiggleOffset);
m_comboNum->DrawNumber(std::get<7>(scores));
}
else {
m_comboLogo->Size = UDim2::fromScale(1.0, 1.0); // set fixed size
m_comboLogo->Position2 = UDim2::fromOffset(0, 0);
m_comboLogo->Draw(delta);

m_comboNum->Position2 = UDim2::fromOffset(0, 0);
m_comboNum->DrawNumber(std::get<7>(scores));
}
}

m_comboTimer += delta;
if (m_comboTimer > 2.0) {
if (m_comboTimer > 1) {
m_drawCombo = false;
}
}
Expand All @@ -83,7 +97,7 @@ void GameplayScene::Render(double delta) {
m_judgement[m_judgeIndex]->Draw();

m_judgeSize = std::clamp(m_judgeSize + (delta * 3), 0.5, 1.0);
if ((m_judgeTimer += delta) > 1) {
if ((m_judgeTimer += delta) > 0.60) {
m_drawJudge = false;
}
}
Expand All @@ -94,20 +108,36 @@ void GameplayScene::Render(double delta) {
m_jamLogo->Draw(delta);
}

if ((m_jamTimer += delta) > 1) {
if ((m_jamTimer += delta) > 0.60) {
m_drawJam = false;
}
}

if (m_drawLN) {
if (std::get<9>(scores) > 0) {
m_lnComboNum->Position2 = UDim2::fromOffset(0, m_lnWiggleAdd);
m_lnComboNum->DrawNumber(std::get<9>(scores));
m_lnLogo->Position2 = UDim2::fromOffset(0, m_lnWiggleAdd);
m_lnLogo->Draw(delta);
double m_wiggleTime = m_lnTimer * 100; // LNCombo animated by Frame per second
double m_wiggleOffset = std::sin(m_wiggleTime) * 10.0; // Amplitude

if (m_wiggleTime < M_PI) {
m_lnLogo->Size = UDim2::fromScale(1.0, 1.0); // set fixed size
m_lnLogo->Position2 = UDim2::fromOffset(0, m_wiggleOffset);
m_lnLogo->Draw(delta);

m_lnComboNum->Position2 = UDim2::fromOffset(0, m_wiggleOffset);
m_lnComboNum->DrawNumber(std::get<9>(scores));
}
else {
m_lnLogo->Size = UDim2::fromScale(1.0, 1.0); // set fixed size
m_lnLogo->Position2 = UDim2::fromOffset(0, 0);
m_lnLogo->Draw(delta);

m_lnComboNum->Position2 = UDim2::fromOffset(0, 0);
m_lnComboNum->DrawNumber(std::get<9>(scores));
}
}

if ((m_lnTimer += delta) > 1) {
m_lnTimer += delta;
if (m_lnTimer > 0.60) {
m_drawLN = false;
}
}
Expand Down Expand Up @@ -153,9 +183,6 @@ void GameplayScene::Render(double delta) {
if (m_game->GetState() == GameState::PosGame) {
SceneManager::GetInstance()->StopGame();
}

m_wiggleAdd = std::clamp(m_wiggleAdd + delta * -0.5, 0.0, 10.0);
m_lnWiggleAdd = std::clamp(m_lnWiggleAdd + delta * -0.5, 0.0, 10.0);
}

void GameplayScene::Input(double delta) {
Expand All @@ -172,7 +199,7 @@ void GameplayScene::OnKeyUp(const KeyState& state) {

bool GameplayScene::Attach() {
auto SkinName = Configuration::Load("Game", "Skin");
int LaneOffset = 3;
int LaneOffset = 5;
int HitPos = 480;

try {
Expand Down Expand Up @@ -496,8 +523,8 @@ bool GameplayScene::Attach() {
m_holdEffect[i]->Repeat = true;

int pos = lanePos[i] + (laneSize[i] / 2);
m_hitEffect[i]->Position = UDim2::fromOffset(pos, 480);
m_holdEffect[i]->Position = UDim2::fromOffset(pos, 480);
m_hitEffect[i]->Position = UDim2::fromOffset(pos, 465);
m_holdEffect[i]->Position = UDim2::fromOffset(pos, 465);
m_hitEffect[i]->AnchorPoint = { .5, .45 };
m_holdEffect[i]->AnchorPoint = { .5, .45 };
}
Expand All @@ -510,7 +537,6 @@ bool GameplayScene::Attach() {

m_drawCombo = true;
m_drawJudge = true;
m_wiggleAdd = 10;

m_comboLogo->Reset();
m_judgeIndex = (int)info.Result;
Expand All @@ -523,7 +549,6 @@ bool GameplayScene::Attach() {

m_game->GetScoreManager()->ListenLongNote([&] {
m_lnTimer = 0;
m_lnWiggleAdd = 10;
m_drawLN = true;
});

Expand Down
6 changes: 4 additions & 2 deletions Game/GameplayScene.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,6 @@ class GameplayScene : public Scene {

bool m_starting;
int m_judgeIndex;
int m_wiggleAdd;
int m_lnWiggleAdd;

/* Scoring */
bool m_drawJam;
Expand All @@ -80,4 +78,8 @@ class GameplayScene : public Scene {
/* Hit/Hold Effect */
bool m_drawHold[7];
bool m_drawHit[7];

/* Fixed Animation*/
double m_wiggleTime;
double m_wiggleOffsets;
};
Binary file added Game/Icon.ico
Binary file not shown.
3 changes: 3 additions & 0 deletions Game/Icon.rc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Icon Resource Definition
#define MAIN_ICON 102
MAIN_ICON ICON "Icon.ico"
2 changes: 1 addition & 1 deletion Game/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ std::filesystem::path prompt() {
ZeroMemory(&ofn, sizeof(ofn));
ofn.lStructSize = sizeof(ofn);
ofn.hwndOwner = NULL;
ofn.lpstrFilter = L"O2-JAM files (*.ojn)\0*.ojn\0Osu files (*.osu)\0*.osu\0BMS files (*.bms|*.bme|*.bml)\0*.bms;*.bme;*.bml\0All files (*.*)\0*.*\0"; // set the file filter
ofn.lpstrFilter = L"All Supported Files (*.ojn;*.osu;*.bms;*.bme;*.bml;*)\0*.ojn;*.osu;*.bms;*.bme;*.bml\0";
ofn.lpstrFile = szFile;
ofn.nMaxFile = MAX_PATH;
ofn.Flags = OFN_PATHMUSTEXIST | OFN_FILEMUSTEXIST;
Expand Down
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,4 +38,24 @@ Written in C++ with SDL + BASS + DirectX11 (and Vulkan through DXVK)
- To able use Vulkan, download and extract D3D11.dll and DXGI.dll into vulkan folder.

# License
MIT License.
MIT License

Copyright (c) 2023 Estrol Mendex

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.