working on a better unlock system

This commit is contained in:
Return0ne 2022-10-02 15:58:18 -04:00
parent b4b53ddedd
commit bc9239174a
3 changed files with 25 additions and 17 deletions

View file

@ -193,7 +193,7 @@ void UpdateGameplayScreen(void)
if (INPUT_OPTION_PRESSED) pause = !pause;
// code to end the game
if (level > 2) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 3; }
if (CheckFireworkActivity() && level < 2) { StopMusicStream(Gameplaysong); levelunlocked++; finishfromGameplayScreen = 4; }
if (CheckFireworkActivity() && level < 2) { StopMusicStream(Gameplaysong); levelunlocked[nextlevel] = true; nextlevel++; finishfromGameplayScreen = 4; }
if (!mute) UpdateMusicStream(Gameplaysong);

View file

@ -13,10 +13,13 @@
#include "Controls.h"
#include "Gfx.h"
int finishfromLevelSelScreen = 0, levelSelected = 1, levelunlocked = 0;
int finishfromLevelSelScreen = 0, levelSelected = 0, nextlevel = 1;
bool levelunlocked[3] = {1, 0 , 0};
void InitLevelSelScreen(void)
{
nextlevel = level + 1;
feather_sprite = LoadTexture("assets/gfx/feather.png");
finishfromLevelSelScreen = 0;
}
@ -24,13 +27,13 @@ void InitLevelSelScreen(void)
void UpdateLevelSelScreen(void)
{
if (INPUT_LEFT_PRESSED) levelSelected--;
if (INPUT_RIGHT_PRESSED) if (levelunlocked >= levelSelected) levelSelected++;
if (levelSelected < 1) levelSelected++;
if (levelSelected > 3) levelSelected--;
if (INPUT_RIGHT_PRESSED) if (levelunlocked[levelSelected+1]) levelSelected++;
if (levelSelected < 0) levelSelected++;
if (levelSelected > 2) levelSelected--;
if ((levelSelected == 1) && (INPUT_OPTION_PRESSED)) { level = LEVEL1; finishfromLevelSelScreen = 1; }
if ((levelSelected == 2) && (INPUT_OPTION_PRESSED)) { level = LEVEL2; finishfromLevelSelScreen = 1; }
if ((levelSelected == 3) && (INPUT_OPTION_PRESSED)) { level = LEVEL3; finishfromLevelSelScreen = 1; }
if ((levelSelected == 0) && (INPUT_OPTION_PRESSED)) { level = LEVEL1; finishfromLevelSelScreen = 1; }
if ((levelSelected == 1) && (INPUT_OPTION_PRESSED)) { level = LEVEL2; finishfromLevelSelScreen = 1; }
if ((levelSelected == 2) && (INPUT_OPTION_PRESSED)) { level = LEVEL3; finishfromLevelSelScreen = 1; }
}
void DrawLevelSelScreen(void)
@ -44,16 +47,19 @@ void DrawLevelSelScreen(void)
if (score >= 10000) DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, (Color){ 222, 181, 0, 255 });
else DrawText(TextFormat("SCORE: %i", score), 10, 65, 30, BLUE);
if (levelSelected == 1) DrawText("1", 100, 220, 30, WHITE);
else DrawText("1", 100, 220, 30, BLUE);
if (levelSelected == 0) DrawText("1", 100, 220, 60, WHITE);
else DrawText("1", 100, 220, 60, BLUE);
if (levelSelected == 2) DrawText("2", 150, 220, 30, WHITE);
else if (levelunlocked >= 1) DrawText("2", 150, 220, 30, BLUE);
else DrawText("2", 150, 220, 30, GRAY);
if (levelSelected == 1) DrawText("2", 200, 220, 60, WHITE);
else if (levelunlocked[1]) DrawText("2", 200, 220, 60, BLUE);
else DrawText("2", 200, 220, 60, GRAY);
if (levelSelected == 3) DrawText("3", 200, 220, 30, WHITE);
else if (levelunlocked >= 2) DrawText("3", 200, 220, 30, BLUE);
else DrawText("3", 200, 220, 30, GRAY);
if (levelSelected == 2) DrawText("3", 300, 220, 60, WHITE);
else if (levelunlocked[2]) DrawText("3", 300, 220, 60, BLUE);
else DrawText("3", 300, 220, 60, GRAY);
// printf("%d, %d, %d\n", levelunlocked[0], levelunlocked[1], levelunlocked[2]);
printf("%d\n", levelunlocked[nextlevel]);
}
void UnloadLevelSelScreen(void)

View file

@ -14,7 +14,9 @@ typedef enum Levels { LEVEL1 = 0, LEVEL2, LEVEL3 } Levels;
extern GameScreen currentScreen;
extern Levels level;
extern int levelunlocked;
extern int nextlevel;
extern bool levelunlocked[3];
void InitTitleScreen(void);
void UpdateTitleScreen(void);