Skip to content

Commit 0d21d27

Browse files
committed
Added NPC Jessica to city map. Plan to add a quest for her soon.
1 parent 8ed2fd1 commit 0d21d27

5 files changed

Lines changed: 66 additions & 0 deletions

File tree

src/gameObjects/map_city/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { flyingBirds } from './flyingBirds';
33
import { npcsInCityMap } from './npcsOnmap_city';
44
import { soccerBall } from './soccerBall.gameObject';
55
import { americanFootball } from './americanFootball.gameObject';
6+
import { jessica } from './jessica.gameObject';
67

78
const gameObjects = [
89
npcsInCityMap,
@@ -11,6 +12,7 @@ const gameObjects = [
1112
flyingBirds,
1213
soccerBall,
1314
americanFootball,
15+
jessica
1416
];
1517

1618
export default gameObjects;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { scaleFactor } from '../../constants';
2+
3+
const characterRow = 17;
4+
const sliceX = 10;
5+
const sliceY = 20;
6+
const spritePosition = (characterRow - 1) * sliceX;
7+
8+
export const jessica = (k, map, spawnpoints) => {
9+
k.loadSprite('jessica', './assets/sprites/characters.png', {
10+
sliceX: sliceX,
11+
sliceY: sliceY,
12+
anims: {
13+
'idle-down': spritePosition + 0,
14+
'walk-down': { from: spritePosition + 5, to: spritePosition + 6, loop: true, speed: 4 },
15+
'idle-up': spritePosition + 1,
16+
'walk-up': { from: spritePosition + 7, to: spritePosition + 8, loop: true, speed: 4 },
17+
'idle-right': spritePosition + 2,
18+
},
19+
});
20+
21+
const jessicaObj = k.make([
22+
k.sprite('jessica', { anim: 'idle-down' }),
23+
k.area({
24+
shape: new k.Rect(k.vec2(0), 16, 16),
25+
}),
26+
k.body({ isStatic: true }),
27+
k.anchor('center'),
28+
k.pos(390, 520),
29+
k.scale(scaleFactor * 0.5),
30+
k.offscreen({ hide: true, distance: 10 }),
31+
'jessica',
32+
]);
33+
34+
return jessicaObj;
35+
};

src/interactions/map_city/index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { enterMapSeasideInteraction } from './enterMapSeasideInteraction.interac
1616
import { enterMapExtendedCampus } from './enterMapExtendedCampus.interactions';
1717
import { enterMapExtendedCampusTop } from './enterMapExtendCampusTop.interactions';
1818
import { interactionWithBin } from './bin.interaction';
19+
import { jessicaInteraction } from './jessica.interation';
1920

2021
const interactions = [
2122
enterMapArcadeInteraction,
@@ -36,6 +37,7 @@ const interactions = [
3637
// Add more interactions here
3738
enterMapCampusHouse1Interaction,
3839
interactionWithBin,
40+
jessicaInteraction
3941
];
4042

4143
export default interactions;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { interactionHandler } from '../handler.interactions';
2+
import { displayDialogue } from '../../utils';
3+
4+
export const jessicaInteraction = (player, k) => {
5+
interactionHandler(player, 'jessica', k, async () => {
6+
await displayDialogue({
7+
k,
8+
player,
9+
characterName: 'Jessica',
10+
text: [
11+
"Hi, I'm Jessica! I'm learning Javascript! It's a lot of work, but I'm excited to get better at it."
12+
],
13+
});
14+
});
15+
};

src/interactions/quests/constants.quests.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,15 @@ export const map_realtor = {
3232
}
3333
),
3434
};
35+
36+
export const findFlashDriveQuest = {
37+
"Find the Flash Drive": makeQuest(
38+
"Find the Flash Drive",
39+
"Find the flash drive that Jessica has lost.",
40+
{
41+
"Has Talked to Jessica": false,
42+
"Found the Flash Drive": false,
43+
"Returned the Flash Drive": false,
44+
}
45+
)
46+
}

0 commit comments

Comments
 (0)