Added cheat to unlock portal gun
This commit is contained in:
parent
6367c299ab
commit
3ee77ffc71
1
Makefile
1
Makefile
|
@ -333,6 +333,7 @@ build/src/menu/new_game_menu.o: build/src/audio/clips.h build/assets/materials/u
|
|||
build/src/menu/options_menu.o: build/assets/materials/ui.h
|
||||
build/src/menu/save_game_menu.o: build/src/audio/clips.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/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
|
||||
|
|
|
@ -211,6 +211,8 @@ That will generate the rom at `/build/portal64.z64`
|
|||
<br />
|
||||
|
||||
## Current New Feature TODO List
|
||||
- [ ] add translations to menus
|
||||
- [ ] check if display list is long enough
|
||||
- [ ] pausing while glados is speaking can end her speech early
|
||||
- [x] jump animation
|
||||
- [x] optimize static culling
|
||||
|
|
48
src/menu/cheat_codes.c
Normal file
48
src/menu/cheat_codes.c
Normal file
|
@ -0,0 +1,48 @@
|
|||
#include "cheat_codes.h"
|
||||
|
||||
#include "../build/src/audio/clips.h"
|
||||
#include "../audio/soundplayer.h"
|
||||
#include "../scene/scene.h"
|
||||
|
||||
struct CheatCodePattern gCheatCodes[CheatCodeCount] = {
|
||||
[CheatCodeUnlockGun] = {
|
||||
{'u', 'u', 'd', 'd', 'l', 'r', 'l', 'r'},
|
||||
SOUNDS_01_PART1_GET_PORTAL_GUN_1,
|
||||
},
|
||||
};
|
||||
|
||||
unsigned char gCheatProgress[CheatCodeCount];
|
||||
|
||||
void cheatCodeReset() {
|
||||
for (int i = 0; i < CheatCodeCount; ++i) {
|
||||
gCheatProgress[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void cheatCodeApply(enum CheatCode cheat) {
|
||||
switch (cheat) {
|
||||
case CheatCodeUnlockGun:
|
||||
playerGivePortalGun(&gScene.player, PlayerHasFirstPortalGun | PlayerHasSecondPortalGun);
|
||||
break;
|
||||
case CheatCodeCount:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void cheatCodeEnterDirection(enum CheatCodeDir dir) {
|
||||
for (int i = 0; i < CheatCodeCount; ++i) {
|
||||
if (gCheatCodes[i].pattern[gCheatProgress[i]] == dir) {
|
||||
++gCheatProgress[i];
|
||||
|
||||
if (gCheatProgress[i] == CHEAT_CODE_LENGTH) {
|
||||
cheatCodeApply(i);
|
||||
soundPlayerPlay(gCheatCodes[i].soundId, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
|
||||
gCheatProgress[i] = 0;
|
||||
}
|
||||
} else if (gCheatCodes[i].pattern[0] == dir) {
|
||||
gCheatProgress[i] = 1;
|
||||
} else {
|
||||
gCheatProgress[i] = 0;
|
||||
}
|
||||
}
|
||||
}
|
26
src/menu/cheat_codes.h
Normal file
26
src/menu/cheat_codes.h
Normal file
|
@ -0,0 +1,26 @@
|
|||
#ifndef __MENU_CHEAT_CODES_H__
|
||||
#define __MENU_CHEAT_CODES_H__
|
||||
|
||||
#define CHEAT_CODE_LENGTH 8
|
||||
|
||||
enum CheatCode {
|
||||
CheatCodeUnlockGun,
|
||||
CheatCodeCount,
|
||||
};
|
||||
|
||||
enum CheatCodeDir {
|
||||
CheatCodeDirUp = 'u',
|
||||
CheatCodeDirRight = 'r',
|
||||
CheatCodeDirDown = 'd',
|
||||
CheatCodeDirLeft = 'l',
|
||||
};
|
||||
|
||||
struct CheatCodePattern {
|
||||
char pattern[CHEAT_CODE_LENGTH];
|
||||
short soundId;
|
||||
};
|
||||
|
||||
void cheatCodeReset();
|
||||
void cheatCodeEnterDirection(enum CheatCodeDir dir);
|
||||
|
||||
#endif
|
|
@ -8,6 +8,7 @@
|
|||
|
||||
#include "../build/assets/materials/ui.h"
|
||||
#include "../build/src/audio/clips.h"
|
||||
#include "cheat_codes.h"
|
||||
|
||||
#define PORTAL_LOGO_X 30
|
||||
#define PORTAL_LOGO_Y 74
|
||||
|
@ -71,22 +72,36 @@ void landingMenuInit(struct LandingMenu* landingMenu, struct LandingMenuOption*
|
|||
}
|
||||
|
||||
struct LandingMenuOption* landingMenuUpdate(struct LandingMenu* landingMenu) {
|
||||
if ((controllerGetDirectionDown(0) & ControllerDirectionUp) != 0) {
|
||||
enum ControllerDirection dir = controllerGetDirectionDown(0);
|
||||
|
||||
if (dir & ControllerDirectionUp) {
|
||||
if (landingMenu->selectedItem > 0) {
|
||||
--landingMenu->selectedItem;
|
||||
} else {
|
||||
landingMenu->selectedItem = landingMenu->optionCount - 1;
|
||||
}
|
||||
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
|
||||
|
||||
cheatCodeEnterDirection(CheatCodeDirUp);
|
||||
}
|
||||
|
||||
if ((controllerGetDirectionDown(0) & ControllerDirectionDown) != 0) {
|
||||
if (dir & ControllerDirectionDown) {
|
||||
if (landingMenu->selectedItem + 1 < landingMenu->optionCount) {
|
||||
++landingMenu->selectedItem;
|
||||
} else {
|
||||
landingMenu->selectedItem = 0;
|
||||
}
|
||||
soundPlayerPlay(SOUNDS_BUTTONROLLOVER, 1.0f, 0.5f, NULL, NULL, SoundTypeAll);
|
||||
|
||||
cheatCodeEnterDirection(CheatCodeDirDown);
|
||||
}
|
||||
|
||||
if (dir & ControllerDirectionLeft) {
|
||||
cheatCodeEnterDirection(CheatCodeDirLeft);
|
||||
}
|
||||
|
||||
if (dir & ControllerDirectionRight) {
|
||||
cheatCodeEnterDirection(CheatCodeDirRight);
|
||||
}
|
||||
|
||||
if (controllerGetButtonDown(0, A_BUTTON)) {
|
||||
|
|
|
@ -50,8 +50,6 @@ Lights1 gSceneLights = gdSPDefLights1(128, 128, 128, 128, 128, 128, 0, 127, 0);
|
|||
#define LEVEL_INDEX_WITH_GUN_0 2
|
||||
#define LEVEL_INDEX_WITH_GUN_1 8
|
||||
|
||||
#define FADE_IN_
|
||||
|
||||
void sceneUpdateListeners(struct Scene* scene);
|
||||
|
||||
void sceneInitDynamicColliders(struct Scene* scene) {
|
||||
|
|
Loading…
Reference in a new issue