Skip to content

Commit

Permalink
Run Prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
actions-user committed Oct 10, 2024
1 parent c8f3004 commit 0ab7abb
Show file tree
Hide file tree
Showing 35 changed files with 77 additions and 92 deletions.
21 changes: 10 additions & 11 deletions src/core/kaplay/gameObjects/index.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,16 @@
import { k } from '../../../kplayCtx';


export const addGameObjects = (gameObjects, map, spawnpoints) => {
return gameObjects.reduce((gameObjAcc, cb) => {
const temp = cb(k, map, spawnpoints);
return gameObjects.reduce((gameObjAcc, cb) => {
const temp = cb(k, map, spawnpoints);

if (Array.isArray(temp)) {
gameObjAcc.push(...temp);
return gameObjAcc;
}
if (Array.isArray(temp)) {
gameObjAcc.push(...temp);
return gameObjAcc;
}

gameObjAcc.push(temp);
gameObjAcc.push(temp);

return gameObjAcc;
}, []);
};
return gameObjAcc;
}, []);
};
6 changes: 3 additions & 3 deletions src/core/kaplay/interactions/index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { k } from '../../../kplayCtx';

export const attachInteractions = (interactions, gameObjTag) => {
const map = k.get('main_map')[0];
const gameObj = k.get(gameObjTag)[0];
const map = k.get('main_map')[0];
const gameObj = k.get(gameObjTag)[0];

interactions.forEach((cb) => cb(gameObj, k, map));
interactions.forEach((cb) => cb(gameObj, k, map));
};
2 changes: 1 addition & 1 deletion src/factories/player.factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ export function makePlayer(playerProps = {}, customScale = scaleFactor) {
changePlayer,
},
k.layer('player'),
'player'
'player',
]);

return player;
Expand Down
2 changes: 1 addition & 1 deletion src/gameObjects/map_arcade/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ const gameObjects = [
jessie,
];

export default gameObjects;
export default gameObjects;
4 changes: 2 additions & 2 deletions src/gameObjects/map_arcade/jessie.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const jessie = (k, map, spawnpoints) => {
k.body({ isStatic: true }),
k.anchor('center'),
k.pos(
map.pos.x + (spawnpoints.player.x / scaleFactor) - 60,
map.pos.y + (spawnpoints.player.y / scaleFactor) - 20
map.pos.x + spawnpoints.player.x / scaleFactor - 60,
map.pos.y + spawnpoints.player.y / scaleFactor - 20
),
k.offscreen({ hide: true, distance: 10 }),
'jessie',
Expand Down
12 changes: 7 additions & 5 deletions src/gameObjects/map_arcade/npcsOnmap.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export const npcsInArcadeMap = (k, map, spawnpoints) => {
const npc = makeNpc(
obj.name,
k.vec2(
(map.pos.x + obj.pos.x + xAdjust),
(map.pos.y + obj.pos.y + yAdjust)
map.pos.x + obj.pos.x + xAdjust,
map.pos.y + obj.pos.y + yAdjust
),
npcDirection,
'map_arcade'
Expand Down Expand Up @@ -66,9 +66,11 @@ export const npcsInArcadeMap = (k, map, spawnpoints) => {
];

// Generate NPCs
npcPatterns.forEach(({ patterns, adjustments, direction, flipX = false }) => {
createNpcsForPattern(patterns, adjustments, direction, flipX);
});
npcPatterns.forEach(
({ patterns, adjustments, direction, flipX = false }) => {
createNpcsForPattern(patterns, adjustments, direction, flipX);
}
);

return npcStore;
};
3 changes: 1 addition & 2 deletions src/gameObjects/map_campus_house_1/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@

const gameObjects = [
// Add more game objects here
];

export default gameObjects;
export default gameObjects;
4 changes: 1 addition & 3 deletions src/gameObjects/map_city/index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@

import { npcsInCityMap } from './npcsOnmap_city';
const gameObjects = [
npcsInCityMap,
// Add more game objects here

];

export default gameObjects;
export default gameObjects;
7 changes: 4 additions & 3 deletions src/gameObjects/map_city/npcsOnmap_city.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ export const npcsInCityMap = (k, map, spawnpoints) => {
patterns.some((pattern) =>
obj.tags.some((tag) => pattern.test(tag))
)
).splice(0, 1);
)
.splice(0, 1);

objects.forEach((obj) => {
const { xAdjust, yAdjust } = adjustments;
Expand All @@ -24,8 +25,8 @@ export const npcsInCityMap = (k, map, spawnpoints) => {
const npc = makeNpc(
obj.name,
k.vec2(
(map.pos.x + obj.pos.x + xAdjust),
(map.pos.y + obj.pos.y + yAdjust)
map.pos.x + obj.pos.x + xAdjust,
map.pos.y + obj.pos.y + yAdjust
),
npcDirection,
'map_city'
Expand Down
1 change: 0 additions & 1 deletion src/gameObjects/map_forest/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { butterfly } from './butterfly.gameObject';

const gameObjects = [butterfly];
Expand Down
3 changes: 1 addition & 2 deletions src/gameObjects/map_forest_junction/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
const gameObjects = [];


export default gameObjects;
export default gameObjects;
5 changes: 4 additions & 1 deletion src/gameObjects/map_start/bruno.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ export const bruno = (k, map, spawnpoints) => {
}),
k.body({ isStatic: true }),
k.anchor('center'),
k.pos(spawnpoints.bruno.x / scaleFactor, spawnpoints.bruno.y / scaleFactor),
k.pos(
spawnpoints.bruno.x / scaleFactor,
spawnpoints.bruno.y / scaleFactor
),
k.scale(1.1),
k.offscreen({ hide: true, distance: 10 }),
'bruno',
Expand Down
1 change: 0 additions & 1 deletion src/gameObjects/map_start/cake.gameObject.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

export const cake = (k, map, spawnpoints) => {
k.loadSprite('cake', './assets/sprites/cake.png');

Expand Down
5 changes: 1 addition & 4 deletions src/gameObjects/map_start/computer.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,7 @@ export const computer = (k, map, spawnpoints) => {
return k.make([
k.sprite('computer', { frame: 2 }),
k.area(),
k.pos(
(tableRoom1.pos.x + 3),
(tableRoom1.pos.y + 23)
),
k.pos(tableRoom1.pos.x + 3, tableRoom1.pos.y + 23),
k.scale(0.7),
k.body({ isStatic: true }),
k.offscreen({ hide: true, distance: 10 }),
Expand Down
4 changes: 2 additions & 2 deletions src/gameObjects/map_start/misterFu.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ export const misterFu = (k, map, spawnpoints) => {
k.body({ isStatic: true }),
k.anchor('center'),
k.pos(
map.pos.x + (spawnpoints.player.x / scaleFactor) + 25,
map.pos.y + (spawnpoints.player.y / scaleFactor) - 20
map.pos.x + spawnpoints.player.x / scaleFactor + 25,
map.pos.y + spawnpoints.player.y / scaleFactor - 20
),
k.offscreen({ hide: true, distance: 10 }),
'misterFu',
Expand Down
5 changes: 1 addition & 4 deletions src/gameObjects/map_start/npcsOnChairs.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export const npcsOnChairs = (k, map, spawnpoints) => {
// createa npc for each chair
const npc = makeNpc(
chair.name,
k.vec2(
(map.pos.x + chair.pos.x + 8),
(map.pos.y + chair.pos.y + 12)
),
k.vec2(map.pos.x + chair.pos.x + 8, map.pos.y + chair.pos.y + 12),
'idle-side',
'map_start'
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ const createNpcs = (k, map, pattern, positionAdjustments, npcStore) => {
const npc = makeNpc(
obj.name,
k.vec2(
(map.pos.x + obj.pos.x + adjustX),
(map.pos.y + obj.pos.y + adjustY)
map.pos.x + obj.pos.x + adjustX,
map.pos.y + obj.pos.y + adjustY
),
'idle-side',
'map_start'
Expand Down Expand Up @@ -49,10 +49,7 @@ export const randNpcsOnRestroomSinkCounch = (k, map, spawnpoints) => {
for (const restroom of selectedRestrooms) {
const npc = makeNpc(
restroom.name,
k.vec2(
(map.pos.x + restroom.pos.x),
(map.pos.y + restroom.pos.y)
),
k.vec2(map.pos.x + restroom.pos.x, map.pos.y + restroom.pos.y),
'idle-down',
'map_start'
);
Expand Down
5 changes: 1 addition & 4 deletions src/gameObjects/map_start/tv_main_room_video.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ export const tvVideo = (k, map, spawnpoints) => {
),
}),
k.body(),
k.pos(
(tv_main_room.pos.x + 2),
(tv_main_room.pos.y + 13)
),
k.pos(tv_main_room.pos.x + 2, tv_main_room.pos.y + 13),
k.scale(0.7),
k.body({ isStatic: true }),
`tv_video`,
Expand Down
5 changes: 1 addition & 4 deletions src/gameObjects/map_start/ztmTrailer.gameObject.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,7 @@ export const ztmTrailer = (k, map, spawnpoints) => {
),
}),
k.body(),
k.pos(
(monitorLobby.pos.x + 2),
(monitorLobby.pos.y + 9)
),
k.pos(monitorLobby.pos.x + 2, monitorLobby.pos.y + 9),
k.scale(0.8),
k.body({ isStatic: true }),
`anim_monitor_lobby`,
Expand Down
2 changes: 1 addition & 1 deletion src/interactions/map_arcade/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,4 @@ const interactions = [
interactionWithGameMachine11,
];

export default interactions;
export default interactions;
2 changes: 1 addition & 1 deletion src/interactions/map_campus_house_1/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ const interactions = [
bedInteractions,
];

export default interactions;
export default interactions;
2 changes: 1 addition & 1 deletion src/interactions/map_city/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const interactions = [
enterMapCampusHouse1Interaction,
];

export default interactions;
export default interactions;
3 changes: 1 addition & 2 deletions src/interactions/map_forest/index.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import { enterMapForestJunctionInteraction } from './enterMapForestJunction.interactions';
import { interactionWithTree } from './tree.interactions';
import { interactionWithSwampyLog } from './swampyLog.interactions';
Expand All @@ -21,4 +20,4 @@ const interactions = [
interactionWithFirepit,
];

export default interactions;
export default interactions;
2 changes: 1 addition & 1 deletion src/interactions/map_forest_junction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ const interactions = [
interactionWithMushroom,
];

export default interactions;
export default interactions;
2 changes: 1 addition & 1 deletion src/interactions/map_start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ const interactions = [
interactionWithLocker,
];

export default interactions;
export default interactions;
10 changes: 6 additions & 4 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@ import { forestJunction } from './scenes/forest_junction';
import { campusHouse1 } from './scenes/campus_house_1';
import { bootstrap } from './scenes/bootstrap';


k.scene('start', (enter_tag) => bootstrap(start, { enter_tag }));
k.scene('city', (enter_tag) => bootstrap(city, { enter_tag }));
k.scene('arcade', (enter_tag) => bootstrap(arcade, { enter_tag }));
k.scene('forest', (enter_tag) => bootstrap(forest, { enter_tag }));
k.scene('forest_junction', (enter_tag) => bootstrap(forestJunction, { enter_tag }));
k.scene('campus_house_1', (enter_tag) => bootstrap(campusHouse1, { enter_tag }));

k.scene('forest_junction', (enter_tag) =>
bootstrap(forestJunction, { enter_tag })
);
k.scene('campus_house_1', (enter_tag) =>
bootstrap(campusHouse1, { enter_tag })
);

k.go('start');

Expand Down
2 changes: 1 addition & 1 deletion src/player.controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ export const addPlayerControls = (player) => {
pressed.size === 1
? player.speed
: // Dot product for diagonal movement 45%
player.speed * 0.707106781188095; // 1 / sqrt(2)
player.speed * 0.707106781188095; // 1 / sqrt(2)

player.move(moveDir.unit().scale(speed));
});
Expand Down
2 changes: 1 addition & 1 deletion src/scenes/arcade.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ export async function arcade() {
k.vec2(29, 11)
);

return [map, spawnpoint, gameObjects, interactions]
return [map, spawnpoint, gameObjects, interactions];
}
23 changes: 12 additions & 11 deletions src/scenes/bootstrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,20 @@ import { getGameState } from '../utils/gameState';
import { addPlayerControls } from './../player.controls';

export async function bootstrap(bootMapCb, mapArgs) {
const gameState = getGameState();
const player = makePlayer(gameState.player);

const gameState = getGameState();
const player = makePlayer(gameState.player);
const [map, spawnpoint, gameObjects, interactions] = await bootMapCb();

const [map, spawnpoint, gameObjects, interactions] = await bootMapCb();
player.pos =
(mapArgs?.enter_tag && spawnpoint[mapArgs?.enter_tag]) ||
spawnpoint.player;

player.pos = (mapArgs?.enter_tag && spawnpoint[mapArgs?.enter_tag]) || spawnpoint.player;
k.add(map);
k.add(player);
k.canvas.focus();

k.add(map);
k.add(player);
k.canvas.focus();

addPlayerControls(player);
addGameObjects(gameObjects, map, spawnpoint).forEach((obj) => map.add(obj));
attachInteractions(interactions, 'player');
addPlayerControls(player);
addGameObjects(gameObjects, map, spawnpoint).forEach((obj) => map.add(obj));
attachInteractions(interactions, 'player');
}
2 changes: 1 addition & 1 deletion src/scenes/campus_house_1.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export async function campusHouse1() {
'./maps/map_campus_house_1.json'
);

return [map, spawnpoint, gameObjects, interactions]
return [map, spawnpoint, gameObjects, interactions];
}
2 changes: 1 addition & 1 deletion src/scenes/city.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,5 @@ export async function city() {
'./maps/map_city.json'
);

return [map, spawnpoint, gameObjects, interactions]
return [map, spawnpoint, gameObjects, interactions];
}
2 changes: 1 addition & 1 deletion src/scenes/forest.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export async function forest() {
'./maps/map_forest.json'
);

return [map, spawnpoint, gameObjects, interactions]
return [map, spawnpoint, gameObjects, interactions];
}
2 changes: 1 addition & 1 deletion src/scenes/forest_junction.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ export async function forestJunction() {
'./maps/map_forest_junction.json'
);

return [map, spawnpoint, gameObjects, interactions]
return [map, spawnpoint, gameObjects, interactions];
}
Loading

0 comments on commit 0ab7abb

Please sign in to comment.