Skip to content

Commit

Permalink
v0.21b
Browse files Browse the repository at this point in the history
Known bugs:

- Blocks that are out of screen draws in the opposite side (up->down)
- Colors doesn't match the PNGs attached in gfx folder

Changes:

- Fixed exit bug
- Fixed writing high scores in highScores.bin
- Removed some debugging text that I forgot to remove
  • Loading branch information
UltiNaruto committed Sep 25, 2015
1 parent 3bbd1ec commit a2a82b8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
26 changes: 19 additions & 7 deletions include/Functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ double FirstFlipTime;
double ctrticks;
struct HIGH_SCORE {
char Name[11];
u64 Score;
u8 Level;
int Score;
int Level;
};

vector<HIGH_SCORE> highScores;
Expand Down Expand Up @@ -55,8 +55,8 @@ char** split(char* a_str, const char a_delim)
*(result + idx++) = strdup(token);
token = strtok(0, delim);
}
printf("idx = %d\n", idx);
printf("count = %d", count);
/*printf("idx = %d\n", idx);
printf("count = %d", count);*/
assert(idx == count - 1);
*(result + idx) = 0;
}
Expand Down Expand Up @@ -111,7 +111,10 @@ void saveHighScores(bool def=false)
}
for(int i=0;i<10;i++)
{
fprintf(file, "%s|%d|%d\n", highScores.at(i).Name, highScores.at(i).Score, highScores.at(i).Level);
fprintf(file, "%s|", highScores.at(i).Name);
fprintf(file, "%d|", highScores.at(i).Score);
fprintf(file, "%d", highScores.at(i).Level);
fprintf(file, "\n");
}
fclose(file);
}
Expand All @@ -126,7 +129,10 @@ void saveHighScores(bool def=false)
}
for(int i=0;i<10;i++)
{
fprintf(file, "%s|%d|%d\n", highScores.at(i).Name, highScores.at(i).Score, highScores.at(i).Level);
fprintf(file, "%s|", highScores.at(i).Name);
fprintf(file, "%d|", highScores.at(i).Score);
fprintf(file, "%d", highScores.at(i).Level);
fprintf(file, "\n");
}
fclose(file);
}
Expand Down Expand Up @@ -156,11 +162,17 @@ void loadHighScores()
}
}while(c != EOF && c != '\n');
buffer[pos] = 0;
if(strlen(buffer) == 0)
break;
char ** params = split(buffer, '|');
HIGH_SCORE newHighScore;
strcpy(newHighScore.Name, params[0]);
newHighScore.Score = atoi(params[1]);
newHighScore.Score = atol(params[1]);
newHighScore.Level = atoi(params[2]);
/*printf("Name : %s\n", newHighScore.Name);
printf("Score : %d\n", newHighScore.Score);
printf("Level : %d\n", newHighScore.Level);
while(1) {}*/
highScores.push_back(newHighScore);
} while(c != EOF);
std::sort(highScores.begin(), highScores.end(), compareScore);
Expand Down
28 changes: 18 additions & 10 deletions source/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ int g_FocusBlockSpeed = INITIAL_SPEED; // Speed of the focus block
bool started = true;
bool paused = false;
bool quit = false;
bool down_pressed = false;

int main(int argc, char **argv)
{
Expand All @@ -82,10 +83,9 @@ int main(int argc, char **argv)
{
Game();
if(quit)
goto quitGame;
break;
}

quitGame:

Shutdown();
exitCfgu();
gfxExit();
Expand All @@ -97,6 +97,7 @@ void Init()
{
srand(time(NULL));

down_pressed = false;
g_Score = 0; // Players current score
g_Level = 1; // Current level player is on
g_FocusBlockSpeed = INITIAL_SPEED; // Speed of the focus block
Expand All @@ -107,6 +108,8 @@ void Init()

void Game()
{
if(quit)
return;
if(!started)
return;
static int force_down_counter = 0;
Expand Down Expand Up @@ -145,6 +148,8 @@ void Game()
{
slide_counter = SLIDE_TIME;
HandleBottomCollision();
if(quit)
return;
}
}
drawBackground(GFX_TOP, background_bgr, background_bgr_size);
Expand All @@ -167,7 +172,12 @@ void Game()
printf("Needed Score : %d\n", g_Level*POINTS_PER_LEVEL);
printf("\n#### High Scores ####\n\n");
for(int i=0;i<10;i++)
printf("%d | %s : %d (%d)\n", (i+1), getHighScores().at(i).Name, getHighScores().at(i).Score, getHighScores().at(i).Level);
{
if(i<9)
printf("%d | %s | %d | %d\n", (i+1), getHighScores().at(i).Name, getHighScores().at(i).Score, getHighScores().at(i).Level);
else
printf("%d | %s | %d | %d\n", (i+1), getHighScores().at(i).Name, getHighScores().at(i).Score, getHighScores().at(i).Level);
}
if(paused)
printf("\nGame is paused");
g_Timer = svcGetSystemTick();
Expand Down Expand Up @@ -200,26 +210,24 @@ void Shutdown()
cSquare** temp_array_1 = g_FocusBlock->GetSquares();
cSquare** temp_array_2 = g_NextBlock->GetSquares();

// Delete our blocks
delete g_FocusBlock;
delete g_NextBlock;

// Delete the temporary arrays of squares
for (int i=0; i<4; i++)
{
delete temp_array_1[i];
delete temp_array_2[i];
}

// Delete our blocks
delete g_FocusBlock;
delete g_NextBlock;

// Delete the squares that are in the game area
for (int i=0; i<g_OldSquares.size(); i++)
{
delete g_OldSquares[i];
}
}

bool down_pressed = false;

void HandleGameInput()
{
hidScanInput();
Expand Down

0 comments on commit a2a82b8

Please sign in to comment.