Start work on credits menu
This commit is contained in:
parent
c4e1af45ba
commit
456efb37fa
1
Makefile
1
Makefile
|
@ -337,6 +337,7 @@ build/src/menu/text_manipulation.o: build/src/audio/subtitles.h
|
|||
build/src/scene/scene_animator.o: build/src/audio/clips.h
|
||||
build/src/menu/cheat_codes.o: build/src/audio/clips.h
|
||||
build/src/levels/intro.o: build/src/audio/clips.h build/assets/materials/images.h
|
||||
build/src/levels/credits.o: build/src/audio/clips.h build/assets/materials/ui.h
|
||||
build/src/menu/savefile_list.o: build/assets/materials/ui.h build/src/audio/clips.h
|
||||
build/src/font/dejavusans_images.o: build/assets/materials/ui.h
|
||||
build/src/player/player.o: build/assets/models/player/chell.h build/assets/materials/static.h build/src/audio/subtitles.h
|
||||
|
|
67
src/levels/credits.c
Normal file
67
src/levels/credits.c
Normal file
|
@ -0,0 +1,67 @@
|
|||
#include "credits.h"
|
||||
|
||||
#include "../util/time.h"
|
||||
#include "./levels.h"
|
||||
#include "../audio/soundplayer.h"
|
||||
#include "../build/src/audio/clips.h"
|
||||
#include "../util/memory.h"
|
||||
#include "../util/rom.h"
|
||||
#include "../graphics/image.h"
|
||||
#include "../build/assets/materials/static.h"
|
||||
#include "../build/assets/materials/ui.h"
|
||||
#include "../controls/controller.h"
|
||||
#include "../font/font.h"
|
||||
#include "../font/dejavusans.h"
|
||||
|
||||
#define FADE_IN_TIME 1.0f
|
||||
|
||||
#define VALVE_IMAGE_SIZE (sizeof(u16) * VALVE_IMAGE_WIDTH * VALVE_IMAGE_HEIGHT)
|
||||
|
||||
void creditsInit(struct Credits* credits) {
|
||||
credits->time = 0.0f;
|
||||
|
||||
soundPlayerPlay(SOUNDS_PORTAL_STILL_ALIVE, 1.0f, 0.5f, NULL, NULL, SoundTypeMusic);
|
||||
}
|
||||
|
||||
void creditsUpdate(struct Credits* credits) {
|
||||
credits->time += FIXED_DELTA_TIME;
|
||||
|
||||
if (controllerGetButtonDown(0, START_BUTTON)) {
|
||||
levelQueueLoad(MAIN_MENU, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
void creditsRender(void* data, struct RenderState* renderState, struct GraphicsTask* task) {
|
||||
struct Credits* credits = (struct Credits*)data;
|
||||
|
||||
gDPPipeSync(renderState->dl++);
|
||||
gDPSetCycleType(renderState->dl++, G_CYC_FILL);
|
||||
gDPSetFillColor(renderState->dl++, 0);
|
||||
gDPFillRectangle(renderState->dl++, 0, 0, SCREEN_WD - 1, SCREEN_HT - 1);
|
||||
|
||||
gDPPipeSync(renderState->dl++);
|
||||
gDPSetCycleType(renderState->dl++, G_CYC_1CYCLE);
|
||||
|
||||
struct Coloru8 color = gColorWhite;
|
||||
|
||||
if (credits->time < FADE_IN_TIME) {
|
||||
color.a = (u8)(credits->time * (255.0f / FADE_IN_TIME));
|
||||
}
|
||||
color.g = 200;
|
||||
color.b = 30;
|
||||
|
||||
gSPDisplayList(renderState->dl++, ui_material_list[DEFAULT_UI_INDEX]);
|
||||
|
||||
struct FontRenderer* renderer = stackMalloc(sizeof(struct FontRenderer));
|
||||
fontRendererLayout(renderer, &gDejaVuSansFont, "Thank you for playing.\nThe rest of the game is still in development.\nFollow the project on YouTube.\nSupport the project on Patreon.", SCREEN_WD);
|
||||
renderState->dl = fontRendererBuildGfx(
|
||||
renderer,
|
||||
gDejaVuSansImages,
|
||||
(SCREEN_WD - renderer->width) >> 1,
|
||||
(SCREEN_HT - renderer->height) >> 1,
|
||||
&color,
|
||||
renderState->dl
|
||||
);
|
||||
|
||||
stackMallocFree(renderer);
|
||||
}
|
14
src/levels/credits.h
Normal file
14
src/levels/credits.h
Normal file
|
@ -0,0 +1,14 @@
|
|||
#ifndef __LEVELS_CREDITS_H__
|
||||
#define __LEVELS_CREDITS_H__
|
||||
|
||||
#include "../graphics/graphics.h"
|
||||
|
||||
struct Credits {
|
||||
float time;
|
||||
};
|
||||
|
||||
void creditsInit(struct Credits* credits);
|
||||
void creditsUpdate(struct Credits* credits);
|
||||
void creditsRender(void* data, struct RenderState* renderState, struct GraphicsTask* task);
|
||||
|
||||
#endif
|
|
@ -136,7 +136,7 @@ void levelQueueLoad(int index, struct Transform* relativeExitTransform, struct V
|
|||
gQueuedLevel = gCurrentLevelIndex + 1;
|
||||
|
||||
if (gQueuedLevel == LEVEL_COUNT) {
|
||||
gQueuedLevel = MAIN_MENU;
|
||||
gQueuedLevel = CREDITS_MENU;
|
||||
}
|
||||
} else {
|
||||
gQueuedLevel = index;
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#include "physics/collision_object.h"
|
||||
#include "level_definition.h"
|
||||
|
||||
#define CREDITS_MENU -5
|
||||
#define INTRO_MENU -4
|
||||
#define MAIN_MENU -3
|
||||
#define NO_QUEUED_LEVEL -2
|
||||
|
|
13
src/main.c
13
src/main.c
|
@ -10,6 +10,7 @@
|
|||
#include "graphics/graphics.h"
|
||||
#include "levels/cutscene_runner.h"
|
||||
#include "levels/intro.h"
|
||||
#include "levels/credits.h"
|
||||
#include "menu/main_menu.h"
|
||||
#include "menu/translations.h"
|
||||
#include "savefile/savefile.h"
|
||||
|
@ -100,6 +101,7 @@ static void initProc(void* arg) {
|
|||
struct Scene gScene;
|
||||
struct GameMenu gGameMenu;
|
||||
struct Intro gIntro;
|
||||
struct Credits gCredits;
|
||||
|
||||
extern OSMesgQueue dmaMessageQ;
|
||||
|
||||
|
@ -138,10 +140,19 @@ struct SceneCallbacks gIntroCallbacks = {
|
|||
.updateCallback = (UpdateCallback)&introUpdate,
|
||||
};
|
||||
|
||||
struct SceneCallbacks gCreditsCallbacks = {
|
||||
.data = &gCredits,
|
||||
.initCallback = (InitCallback)&creditsInit,
|
||||
.graphicsCallback = (GraphicsCallback)&creditsRender,
|
||||
.updateCallback = (UpdateCallback)&creditsUpdate,
|
||||
};
|
||||
|
||||
struct SceneCallbacks* gSceneCallbacks = &gTestChamberCallbacks;
|
||||
|
||||
void levelLoadWithCallbacks(int levelIndex) {
|
||||
if (levelIndex == INTRO_MENU) {
|
||||
if (levelIndex == CREDITS_MENU) {
|
||||
gSceneCallbacks = &gCreditsCallbacks;
|
||||
} else if (levelIndex == INTRO_MENU) {
|
||||
gSceneCallbacks = &gIntroCallbacks;
|
||||
} else if (levelIndex == MAIN_MENU) {
|
||||
levelLoad(0);
|
||||
|
|
Loading…
Reference in a new issue