Skip to content

Commit

Permalink
Merge branch 'main' into 20-dialogue-box-ui-updated
Browse files Browse the repository at this point in the history
  • Loading branch information
aadityaforwork authored Oct 1, 2024
2 parents 2765234 + 93b9370 commit 61e8dd0
Show file tree
Hide file tree
Showing 5 changed files with 39 additions and 1 deletion.
Binary file added public/laptop.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions src/gameObjects/map_start/computer.gameObject.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { scaleFactor } from '../../constants';

export const computer = (k, map, spawnpoints) => {
k.loadSprite('computer', './laptop.png', {
sliceX: 4,
sliceY: 4,
anims: {
on: { from: 2, to: 3, loop: false },
off: { from: 3, to: 2, loop: false },
},
});

const [tableRoom1] = map.query({ include: 'table_room_1' });

return k.make([
k.sprite('computer', { frame: 2 }),
k.area(),
k.pos(
(tableRoom1.pos.x + 3) * scaleFactor,
(tableRoom1.pos.y + 30) * scaleFactor
),
k.body({ isStatic: true }),
'computer',
]);
};
3 changes: 2 additions & 1 deletion src/gameObjects/map_start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,14 @@ import { bruno } from './bruno.gameObject';
import { cake } from './cake.gameObject';
import { npcsOnChairs } from './npcsOnChairs.gameObject';
import { ztmTrailer } from './ztmTrailer.gameObject';
import { computer } from './computer.gameObject';

const gameObjects = [
bruno,
npcsOnChairs,
ztmTrailer,
computer,
cake,

// Add more game objects here
];

Expand Down
10 changes: 10 additions & 0 deletions src/interactions/map_start/computer.interaction.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export const interactionWithComputer = (player, k, map) => {
const [computer] = k.query({ include: 'computer' });

player.onCollide('computer', () => {
computer.play('on');
});
player.onCollideEnd('computer', () => {
computer.play('off');
});
};
2 changes: 2 additions & 0 deletions src/interactions/map_start/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ import { interactionWithBruno } from './bruno.interaction';
import { enterMapCityInteraction } from './enterMapCity.interaction';
import { interactionWithMainboxMainArea } from './mailboxMainArea.interaction';
import { restroomInteractions } from './restroom.interactions';
import { interactionWithComputer } from './computer.interaction';

const interactions = [
restroomInteractions,
interactionWithBruno,
enterMapCityInteraction,
interactionWithMainboxMainArea,
interactionWithComputer,
// Add more interactions here
];

Expand Down

0 comments on commit 61e8dd0

Please sign in to comment.