level unlocking and title music
This commit is contained in:
parent
2a84b5ae3e
commit
3537a6d37e
9 changed files with 2328 additions and 22 deletions
2296
asset-src/bgm/04-Distant-Misadventure.json
Normal file
2296
asset-src/bgm/04-Distant-Misadventure.json
Normal file
File diff suppressed because it is too large
Load diff
BIN
assets/bgm/04-Distant-Misadventure.ogg
Normal file
BIN
assets/bgm/04-Distant-Misadventure.ogg
Normal file
Binary file not shown.
|
@ -42,9 +42,10 @@ void InitGameplayScreen(void)
|
|||
|
||||
globalTimer = 0;
|
||||
|
||||
if (player.hp < 1) player.hp = 1;
|
||||
|
||||
player.currentframe = 0;
|
||||
player.speed = 300.0f;
|
||||
player.hp = PLAYER_HP;
|
||||
if (GI_callcount < 1) {
|
||||
player.frameRec = (Rectangle) {
|
||||
player.hitbox.x,
|
||||
|
@ -116,7 +117,6 @@ void InitGameplayScreen(void)
|
|||
shoot[i].active = false;
|
||||
shoot[i].color = RED;
|
||||
}
|
||||
ammo = 10;
|
||||
fireworkAmount = 100;
|
||||
|
||||
pause = 0;
|
||||
|
@ -174,7 +174,7 @@ void UpdateGameplayScreen(void)
|
|||
if (INPUT_OPTION_PRESSED) pause = !pause;
|
||||
// code to end the game
|
||||
if (level > 2) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 3; }
|
||||
if (fireworkAmount < 1 && level < 2) { StopMusicStream(Gameplaysong); finishfromGameplayScreen = 4; }
|
||||
if (fireworkAmount < 1 && level < 2) { StopMusicStream(Gameplaysong); levelunlocked++; finishfromGameplayScreen = 4; }
|
||||
|
||||
if (!mute) UpdateMusicStream(Gameplaysong);
|
||||
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#define GAMEPLAY_HEADER
|
||||
|
||||
#define MAX_FIREWORKS 10
|
||||
#define PLAYER_HP 3
|
||||
#define MAX_SHOOTS 3
|
||||
|
||||
struct Actor {
|
||||
|
|
|
@ -12,38 +12,39 @@
|
|||
#include "Controls.h"
|
||||
#include "Gfx.h"
|
||||
|
||||
int finishfromLevelSelScreen = 0, levelSelected = 0;
|
||||
int finishfromLevelSelScreen = 0, levelSelected = 1, levelunlocked = 0;
|
||||
|
||||
void InitLevelSelScreen(void)
|
||||
{
|
||||
levelSelected = 0;
|
||||
finishfromLevelSelScreen = 0;
|
||||
}
|
||||
|
||||
void UpdateLevelSelScreen(void)
|
||||
{
|
||||
if (INPUT_LEFT_PRESSED) levelSelected++;
|
||||
if (INPUT_RIGHT_PRESSED) levelSelected--;
|
||||
if (levelSelected > 0) levelSelected--;
|
||||
if (levelSelected < -2) levelSelected++;
|
||||
if (INPUT_LEFT_PRESSED) levelSelected--;
|
||||
if (INPUT_RIGHT_PRESSED) if (levelunlocked >= levelSelected) levelSelected++;
|
||||
if (levelSelected < 1) levelSelected++;
|
||||
if (levelSelected > 3) levelSelected--;
|
||||
|
||||
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; }
|
||||
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; }
|
||||
}
|
||||
|
||||
void DrawLevelSelScreen(void)
|
||||
{
|
||||
DrawTexture(background, 0, 0, GRAY);
|
||||
|
||||
if (levelSelected == 0) DrawText("1", 100, 220, 30, WHITE);
|
||||
if (levelSelected == 1) DrawText("1", 100, 220, 30, WHITE);
|
||||
else DrawText("1", 100, 220, 30, BLUE);
|
||||
|
||||
if (levelSelected == -1) DrawText("2", 150, 220, 30, WHITE);
|
||||
else DrawText("2", 150, 220, 30, 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 == -2) DrawText("3", 200, 220, 30, WHITE);
|
||||
else DrawText("3", 200, 220, 30, BLUE);
|
||||
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);
|
||||
}
|
||||
|
||||
void UnloadLevelSelScreen(void)
|
||||
|
|
|
@ -77,6 +77,7 @@ void gameSetup(void)
|
|||
level = LEVEL1;
|
||||
background = LoadTexture("assets/gfx/background.png");
|
||||
ZadoBold = LoadFontEx("assets/fonts/ZadoBold.ttf", 96, 0, 110);
|
||||
InitTitleScreen();
|
||||
|
||||
SetMasterVolume(0.5);
|
||||
}
|
||||
|
|
|
@ -12,5 +12,6 @@
|
|||
extern Music Endingsong;
|
||||
extern Music Gameoversong;
|
||||
extern Music Gameplaysong;
|
||||
extern Music Titlesong;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -14,6 +14,7 @@ typedef enum Levels { LEVEL1 = 0, LEVEL2, LEVEL3 } Levels;
|
|||
|
||||
extern GameScreen currentScreen;
|
||||
extern Levels level;
|
||||
extern int levelunlocked;
|
||||
|
||||
void InitTitleScreen(void);
|
||||
void UpdateTitleScreen(void);
|
||||
|
|
15
src/Title.c
15
src/Title.c
|
@ -10,10 +10,14 @@
|
|||
|
||||
#include "Screens.h"
|
||||
#include "Controls.h"
|
||||
#include "Music.h"
|
||||
#include "Options.h"
|
||||
#include "Score.h"
|
||||
#include "Gfx.h"
|
||||
|
||||
int titleSelected = 0, finishfromTitleScreen = 0;
|
||||
Music Titlesong = { 0 };
|
||||
|
||||
|
||||
void DrawScore(void)
|
||||
{
|
||||
|
@ -32,18 +36,21 @@ void InitTitleScreen(void)
|
|||
{
|
||||
titleSelected = 0;
|
||||
finishfromTitleScreen = 0;
|
||||
Titlesong = LoadMusicStream("assets/bgm/04-Distant-Misadventure.ogg");
|
||||
PlayMusicStream(Titlesong);
|
||||
}
|
||||
|
||||
void UpdateTitleScreen(void)
|
||||
{
|
||||
if (!mute) UpdateMusicStream(Titlesong);
|
||||
if (INPUT_UP_PRESSED) titleSelected++;
|
||||
if (INPUT_DOWN_PRESSED) titleSelected--;
|
||||
if (titleSelected > 0) titleSelected--;
|
||||
if (titleSelected < -2) titleSelected++;
|
||||
|
||||
if ((titleSelected == 0) && (INPUT_OPTION_PRESSED)) finishfromTitleScreen = 2;
|
||||
if ((titleSelected == -1) && (INPUT_OPTION_PRESSED)) finishfromTitleScreen = 1;
|
||||
if ((titleSelected == -2) && (INPUT_OPTION_PRESSED)) finishfromTitleScreen = 3;
|
||||
if ((titleSelected == 0) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 2; }
|
||||
if ((titleSelected == -1) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 1; }
|
||||
if ((titleSelected == -2) && (INPUT_OPTION_PRESSED)) { StopMusicStream(Titlesong); finishfromTitleScreen = 3; }
|
||||
}
|
||||
|
||||
void DrawTitleScreen(void)
|
||||
|
@ -72,7 +79,7 @@ void DrawTitleScreen(void)
|
|||
|
||||
void UnloadTitleScreen(void)
|
||||
{
|
||||
|
||||
UnloadMusicStream(Titlesong);
|
||||
}
|
||||
|
||||
int FinishTitleScreen(void)
|
||||
|
|
Loading…
Reference in a new issue