Skip to content

Commit

Permalink
debug: score path
Browse files Browse the repository at this point in the history
  • Loading branch information
TheSwiftKnight committed Jun 23, 2024
1 parent 0d95a78 commit 7020c0c
Show file tree
Hide file tree
Showing 9 changed files with 12 additions and 98 deletions.
11 changes: 0 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,6 @@ add_executable(2024_I2P2_TowerDefense_with_answer
Turret/TurretButton.hpp
Scene/WinScene.cpp
Scene/WinScene.hpp
Scene/LevelSelectScene.cpp
Scene/LevelSelectScene.hpp
# TODO: [HACKATHON-1-SCENE] (2/4) Add the new scene source files here
Scene/StartScene.cpp
Scene/StartScene.hpp
Expand All @@ -119,15 +117,6 @@ add_executable(2024_I2P2_TowerDefense_with_answer
# UI/Component/TextInput.hpp
)

# add_custom_target(update_score ALL
# COMMAND ${CMAKE_COMMAND} -E echo "Pushing score to GitHub..."
# COMMAND git add score.txt
# COMMAND git commit -m "[Auto]Update score"
# COMMAND git push origin master
# WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
# )
# add_dependencies(2024_I2P2_TowerDefense_with_answer update_score)

if(WIN32)
set(UPDATE_SCRIPT ${CMAKE_SOURCE_DIR}/update_score.bat)
else()
Expand Down
2 changes: 1 addition & 1 deletion Resource/level1.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#--b-[-----]---1-2##
##E#####G###########
#-----[]-----#######
#-----------S]-[--##
#------------]-[--##
####b-------------##
#########B###-----##
#---------######-s##
Expand Down
59 changes: 0 additions & 59 deletions Scene/LevelSelectScene.cpp

This file was deleted.

19 changes: 0 additions & 19 deletions Scene/LevelSelectScene.hpp

This file was deleted.

5 changes: 3 additions & 2 deletions Scene/LoseScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ void LoseScene::BackOnClick(int stage) {

void LoseScene::OnKeyDown(int keyCode) {
IScene::OnKeyDown(keyCode);
Engine::LOG(Engine::INFO)<<"key is "<<keyCode;
// Engine::LOG(Engine::INFO)<<"key is "<<keyCode;
if (keyCode == ALLEGRO_KEY_ENTER) {
if(!update_once)WriteNametoFile(playerName);
update_once++;
Expand All @@ -75,7 +75,8 @@ void LoseScene::OnKeyDown(int keyCode) {
}

void LoseScene::WriteNametoFile(std::string& playerName){
const std::string filepath = "C:\\I2P\\Fireboy-and-Watergirl\\score.txt";
system("echo Current: %cd%");
const std::string filepath = "../score.txt";
std::ofstream file(filepath, std::ios::app);
if (!file.is_open()) {
std::cerr << "Failed to open file for writing.\n";
Expand Down
3 changes: 2 additions & 1 deletion Scene/PlayScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -779,7 +779,8 @@ std::vector<std::vector<int>> PlayScene::CalculateBFSDistance() {
}

void PlayScene::WriteScoretoFile(int score){
const std::string filepath = "C:\\I2P\\Fireboy-and-Watergirl\\score.txt";
system("echo Current: %cd%");
const std::string filepath = "../score.txt";

// Open the file for appending using ofstream
std::ofstream file(filepath, std::ios::app);
Expand Down
5 changes: 3 additions & 2 deletions Scene/ScoreBoardScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ void ScoreBoardScene::Initialize() {
0.5, 0.5));

// Not safe if release resource while playing, however we only free while change scene, so it's fine.
bgmInstance = AudioHelper::PlaySample("select.ogg", true, AudioHelper::BGMVolume);
bgmInstance = AudioHelper::PlaySample("start.ogg", true, AudioHelper::BGMVolume);
LoadScores();
}

Expand Down Expand Up @@ -77,7 +77,8 @@ void ScoreBoardScene::NextOnClick() {

void ScoreBoardScene::LoadScores() {
scores.clear();
const char* filepath = "C:\\Users\\maggie\\Fireboy_and_Watergirl\\score.txt";
system("echo Current: %cd%");
const char* filepath = "../score.txt";
FILE* file;
freopen_s(&file, filepath, "r", stdin);
std::string line;
Expand Down
5 changes: 3 additions & 2 deletions Scene/WinScene.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ void WinScene::BackOnClick(int stage) {

void WinScene::OnKeyDown(int keyCode) {
IScene::OnKeyDown(keyCode);
Engine::LOG(Engine::INFO)<<"key is "<<keyCode;
// Engine::LOG(Engine::INFO)<<"key is "<<keyCode;
if (keyCode == ALLEGRO_KEY_ENTER) {
if(!update_once)WriteNametoFile(playerName);
update_once++;
Expand All @@ -82,7 +82,8 @@ void WinScene::OnKeyDown(int keyCode) {
}

void WinScene::WriteNametoFile(std::string& playerName){
const std::string filepath = "C:\\I2P\\Fireboy-and-Watergirl\\score.txt";
system("echo Current: %cd%");
const std::string filepath = "../score.txt";
std::ofstream file(filepath, std::ios::app);
if (!file.is_open()) {
std::cerr << "Failed to open file for writing.\n";
Expand Down
1 change: 0 additions & 1 deletion main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "Scene/StartScene.hpp"
#include "Scene/SettingsScene.hpp"
#include "Scene/ScoreBoardScene.hpp"
#include "Scene/LevelSelectScene.hpp"
int main(int argc, char **argv) {
Engine::LOG::SetConfig(true);
Engine::GameEngine& game = Engine::GameEngine::GetInstance();
Expand Down

0 comments on commit 7020c0c

Please sign in to comment.