Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,14 @@
"M"/Map Button - Toggle Map
</li>
<li class="alert-text">
"O"/Credits Button - Open Credits
"O"/Credits Button - Toggle Credits screen
</li>
<li class="alert-text">
"I"/Bagpack Icon - Toggle Inventory
</li>
<li class="alert-text">
"F8"/Debug Button - Toggle Debug mode
</li>
</ul>
<p class="alert-heading">Main Mechanics</p>
<ul>
Expand Down Expand Up @@ -623,7 +626,7 @@ <h3>Controls</h3>
<button id="new-game-button" class="setting-btn">
New Game
</button>
<button id="debug-button" class="setting-btn">DEBUG</button>
<button id="debug-button" class="setting-btn">Debug</button>
<button id="audio-button" class="setting-btn">
<img
id="audio-icon"
Expand Down
17 changes: 17 additions & 0 deletions src/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,3 +110,20 @@ export const conversationRico = [
'So go in there, have fun — and make it epic!',
],
];

export const playerScenes = [
'start',
'city',
'arcade',
'forest',
'forest_junction',
'campus_house_1',
'classroom',
'seaside',
'downtown',
'extended_campus',
'orange_house',
'red_house',
'realtor',
'company_interior',
];
2 changes: 1 addition & 1 deletion src/gameObjects/map_start/library.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const library = (k, map, spawnpoints) => {
const librarySpawnY = 100;

const libraryObj = k.make([
k.sprite('library', { frame: 0, anim: 'laying' }),
k.sprite('library', { frame: 0 }),
k.area(),
k.pos(map.pos.x + librarySpawnX, map.pos.y + librarySpawnY),
k.scale(0.15),
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/map_city/jessica.interation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { displayDialogue } from '../../utils';
import {
completeQuestObjective,
playerHasQuest,
recieveQuest,
receiveQuest,
completeQuest,
isObjectiveComplete,
} from '../../utils/questHandler';
Expand Down Expand Up @@ -48,7 +48,7 @@ export const jessicaInteraction = async (player, k) => {
text: [generateJessicaDialogue(player)],
onDisplayEnd: async () => {
if (!playerHasQuest(player, 'Find the Flash Drive')) {
await recieveQuest(
await receiveQuest(
player,
jessicaQuests.findTheFlashDriveQuest
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
import {
completeQuest,
completeQuestObjective,
recieveQuest,
receiveQuest,
} from '../../utils/questHandler';
import { takeAwayCoins } from '../../utils/coinsUpdate';
import { map_realtor } from '../quests/constants.quests';
Expand All @@ -26,7 +26,7 @@ export const counterClerkInteraction = (player, k) => {
'Would you like to purchase a house?',
],
});
await recieveQuest(player, map_realtor['Buy a house!']);
await receiveQuest(player, map_realtor['Buy a house!']);
await completeQuestObjective(
player,
'Buy a house!',
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/map_start/bruno.interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
completeQuestObjective,
completeQuest,
playerHasQuest,
recieveQuest,
receiveQuest,
} from '../../utils/questHandler';
import { map_start_quests } from '../quests/constants.quests';

Expand All @@ -18,7 +18,7 @@ export const interactionWithBruno = (player, k, map) => {
text: conversationBruno,
onDisplayEnd: async () => {
if (!playerHasQuest(player, 'Start Interacting!')) {
await recieveQuest(
await receiveQuest(
player,
map_start_quests['Start Interacting!']
);
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/map_start/enterMapCityLeft.interaction.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { displayDialogue } from '../../utils';
import {
recieveQuest,
receiveQuest,
retrieveQuestObjectiveStatus,
} from '../../utils/questHandler';
import { map_start_quests } from '../quests/constants.quests';
Expand Down Expand Up @@ -31,7 +31,7 @@ export const enterMapCityLeftInteraction = (player, k, map) => {
) {
k.go('city', 'spawn_office_left');
} else {
await recieveQuest(player, map_start_quests['Start Interacting!']);
await receiveQuest(player, map_start_quests['Start Interacting!']);
if (!hasTalkedToBruno) {
displayDialogue({
k,
Expand Down
4 changes: 2 additions & 2 deletions src/interactions/map_start/enterMapCityRight.interactions.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { displayDialogue } from '../../utils';
import {
recieveQuest,
receiveQuest,
retrieveQuestObjectiveStatus,
} from '../../utils/questHandler';
import { map_start_quests } from '../quests/constants.quests';
Expand Down Expand Up @@ -32,7 +32,7 @@ export const enterMapCityRightInteraction = (player, k, map) => {
) {
k.go('city', 'spawn_office_right'); // City spawn point
} else {
await recieveQuest(player, map_start_quests['Start Interacting!']);
await receiveQuest(player, map_start_quests['Start Interacting!']);
if (!hasTalkedToBruno) {
displayDialogue({
k,
Expand Down
10 changes: 6 additions & 4 deletions src/interactions/map_start/restroom.interactions.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,20 @@ export const restroomInteractions = (player, k, map) => {
questName,
'hasTalkedToBruno'
);
player.onCollide('restroom_toilet', async () => {
await completeQuestObjective(player, questName, 'wasInRestroom');
await completeQuest(player, questName);
player.onCollide('restroom_toilet', () => {
const dialogue = ['You feel refreshed now.', 'Ready for the ride.'];

if (!hasTalkedToBruno) {
dialogue.push('You should talk to Bruno first.');
}
displayDialogue({
k,
player,
text: [dialogue.join(' ')],
onDisplayEnd: async () => {
await completeQuestObjective(player, questName, 'wasInRestroom');
await completeQuest(player, questName);
}
});
});

Expand Down
1 change: 1 addition & 0 deletions src/kplayCtx.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export const k = kaplay({
right: { keyboard: ['d', 'right'], gamepad: 'east' },
map: { keyboard: ['m'] },
backpack: { keyboard: ['i'] },
credits: { keyboard: ['o'] },
},
loadingScreen: false,
background: [15, 15, 35],
Expand Down
10 changes: 9 additions & 1 deletion src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { setupPauseMenu } from './utils/pauseMenu';
import { setupMenuModals } from './utils/menuModals';

import { Backpack } from './backpack';
import { playerScenes } from './constants';

k.scene('loadingScreen', () => loadingScreen(k));
k.scene('start', (enter_tag) => bootstrap(start, { enter_tag }));
Expand Down Expand Up @@ -131,7 +132,14 @@ if (creditsButton) {
const leftPanel = document.getElementById('left-panel');
leftPanel.classList.toggle('show-misc-menu');

k.go('gameOver');
const gameState = getGameState();
const playerScene = gameState.player.scene;
if (playerScenes.includes(playerScene)) {
k.go('gameOver');
} else if (playerScene === 'gameOver') {
k.go('start');
}
k.canvas.focus();
});
}

Expand Down
12 changes: 11 additions & 1 deletion src/player.controls.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { scaleFactor } from './constants';
import { playerScenes, scaleFactor } from './constants';
import { animations, stopCharacterAnims } from './utils/animation';
import { getCamScale } from './utils';
import { k } from './kplayCtx';
import { drawMinimap, toggleMinimap } from './utils/miniMap';
import { getGameState } from './utils/gameState';

// Manage multiple pressed buttons
const pressed = new Set();
Expand Down Expand Up @@ -185,6 +186,15 @@ export const addPlayerControls = (player) => {
toggleMinimap(k);
});

// Set up the button press event to toggle credits screen
k.onButtonPress('credits', () => {
const gameState = getGameState();
const playerScene = gameState.player.scene;
if (playerScenes.includes(playerScene)) {
k.go('gameOver');
}
});

// Only stop animations if no buttons are pressed
k.onMouseRelease(() => pressed.size || stopCharacterAnims(player));

Expand Down
6 changes: 3 additions & 3 deletions src/scenes/gameOver.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ Thank you for playing!
]);

const crossButton = k.add([
k.rect(65, 35),
k.rect(120, 35),
k.color(255, 0, 0),
k.anchor('topright'),
k.z(101),
Expand All @@ -69,7 +69,7 @@ Thank you for playing!
]);

const exitText = k.add([
k.text('Exit', { size: 26 / camScale }),
k.text('Exit (O)', { size: 26 / camScale }),
k.color(255, 255, 255),
k.anchor('topright'),
k.z(102),
Expand Down Expand Up @@ -159,7 +159,7 @@ Thank you for playing!
});

// key bindings, again for added functionality
k.onKeyPress('x', () => {
k.onKeyPress('o', () => {
k.go('start');
});
});
7 changes: 4 additions & 3 deletions src/scenes/loadingScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ export function loadingScreen(k) {

const walkingNPCs = [];
for (let i = 0; i < 3; i++) {
const randomChar =
characters[Math.floor(Math.random() * characters.length)];
const charIdx = Math.floor(Math.random() * characters.length);
const randomChar = characters[charIdx];
characters.splice(charIdx,1); // This ensures characters are unique
walkingNPCs.push({
character: randomChar,
startX: -100 - i * 150,
Expand Down Expand Up @@ -176,7 +177,7 @@ export function loadingScreen(k) {
}

const walkCycle = Math.floor((time * 4) % 2);
const frameIndex = npc.character.frames[walkCycle === 0 ? 1 : 0];
const frameIndex = npc.character.frames[walkCycle === 0 ? 3 : 2];

k.drawSprite({
sprite: 'characters',
Expand Down
4 changes: 0 additions & 4 deletions src/scenes/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,5 @@ export async function start() {
// Immediately apply the selected character
changePlayerSprite(charName, 'idle-down', k, player);

k.onKeyPress('o', () => {
k.go('gameOver');
});

return [map, spawnpoint, gameObjects, interactions, sounds];
}
1 change: 1 addition & 0 deletions src/styles/dialogs.css
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@
}

#textbox #dialog {
max-height: 100px;
overflow-y: auto;
width: 100%;
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils/jobHandler.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// jobHandler.js
import { playerHasQuest, recieveQuest, completeQuest } from './questHandler.js';
import { playerHasQuest, receiveQuest, completeQuest } from './questHandler.js';

export const JOB_QUEST_NAME = 'company_job';

Expand All @@ -18,7 +18,7 @@ export const playerHasJob = (player) => {
*/
export const startJobQuest = async (player) => {
if (!playerHasQuest(player, JOB_QUEST_NAME)) {
await recieveQuest(player, {
await receiveQuest(player, {
[JOB_QUEST_NAME]: {
done: false,
objectives: {},
Expand Down
4 changes: 2 additions & 2 deletions src/utils/questHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ export const retrieveQuestObjectiveStatus = (player, questName, objective) => {
return player.state.quests[questName].objectives[objective];
};

export const recieveQuest = async (player, quest) => {
export const receiveQuest = async (player, quest) => {
if (!playerHasQuest(player, Object.keys(quest)[0])) {
// Triggers set handler in Proxy state object
player.state.quests = { ...player.state.quests, ...quest };
Expand Down Expand Up @@ -160,4 +160,4 @@ export const isObjectiveComplete = (player, questName, objective) => {
};

// If you want to add quests, you can recieve them through interactions.
// Use recieveQuest to get the quest via the player's state object.
// Use receiveQuest to get the quest via the player's state object.