From 401e4319f7c9f7d27babed8be18b4cee795848b4 Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Tue, 7 Oct 2025 14:01:08 +0100 Subject: [PATCH] Update room reception assets and implement table collision logic: Modify JSON and TMJ files to adjust object IDs and image paths for tables. Enhance room.js to add collision detection for tables, ensuring proper interaction with player characters. Update tileset version for improved asset management. --- assets/rooms/room_reception2.json | 106 +++++++++++++++--------------- assets/rooms/room_reception2.tmj | 94 +++++++++++++------------- assets/rooms/tables.tsx | 14 ++-- js/core/rooms.js | 59 +++++++++++++++++ 4 files changed, 166 insertions(+), 107 deletions(-) diff --git a/assets/rooms/room_reception2.json b/assets/rooms/room_reception2.json index a3056f2..a6120cd 100644 --- a/assets/rooms/room_reception2.json +++ b/assets/rooms/room_reception2.json @@ -26,12 +26,12 @@ { "data":[0, 101, 0, 0, 0, 0, 0, 0, 101, 0, 0, 107, 0, 0, 0, 0, 0, 0, 107, 0, - 380, 0, 0, 0, 0, 0, 0, 0, 0, 380, + 383, 0, 0, 0, 0, 0, 0, 0, 0, 383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 380, 0, 0, 0, 0, 0, 0, 0, 0, 380, + 383, 0, 0, 0, 0, 0, 0, 0, 0, 383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "height":10, @@ -50,16 +50,16 @@ "name":"tables", "objects":[ { - "gid":115, + "gid":118, "height":47, - "id":15, + "id":71, "name":"", "rotation":0, "type":"", "visible":true, "width":174, - "x":76, - "y":90 + "x":75.6666666666667, + "y":89.6666666666667 }], "opacity":1, "type":"objectgroup", @@ -73,7 +73,7 @@ "name":"table_items", "objects":[ { - "gid":351, + "gid":354, "height":23, "id":27, "name":"", @@ -85,7 +85,7 @@ "y":64.5 }, { - "gid":351, + "gid":354, "height":23, "id":28, "name":"", @@ -97,7 +97,7 @@ "y":65 }, { - "gid":156, + "gid":159, "height":23, "id":33, "name":"", @@ -109,7 +109,7 @@ "y":54.6666666666667 }, { - "gid":159, + "gid":162, "height":20, "id":34, "name":"", @@ -121,7 +121,7 @@ "y":54.6666666666667 }, { - "gid":223, + "gid":226, "height":17, "id":47, "name":"", @@ -144,7 +144,7 @@ "name":"conditional_table_items", "objects":[ { - "gid":182, + "gid":185, "height":14, "id":45, "name":"", @@ -156,7 +156,7 @@ "y":65.25 }, { - "gid":213, + "gid":216, "height":11, "id":46, "name":"", @@ -168,7 +168,7 @@ "y":65.75 }, { - "gid":220, + "gid":223, "height":16, "id":48, "name":"", @@ -180,7 +180,7 @@ "y":51 }, { - "gid":305, + "gid":308, "height":16, "id":54, "name":"", @@ -192,7 +192,7 @@ "y":69.5 }, { - "gid":331, + "gid":334, "height":12, "id":55, "name":"", @@ -204,7 +204,7 @@ "y":62.1666666666667 }, { - "gid":336, + "gid":339, "height":18, "id":56, "name":"", @@ -216,7 +216,7 @@ "y":66 }, { - "gid":371, + "gid":374, "height":28, "id":69, "name":"", @@ -239,7 +239,7 @@ "name":"items", "objects":[ { - "gid":352, + "gid":355, "height":37, "id":16, "name":"", @@ -251,7 +251,7 @@ "y":219 }, { - "gid":352, + "gid":355, "height":37, "id":17, "name":"", @@ -263,7 +263,7 @@ "y":248 }, { - "gid":353, + "gid":356, "height":37, "id":18, "name":"", @@ -275,7 +275,7 @@ "y":218 }, { - "gid":353, + "gid":356, "height":37, "id":19, "name":"", @@ -287,7 +287,7 @@ "y":250 }, { - "gid":354, + "gid":357, "height":79, "id":20, "name":"", @@ -299,7 +299,7 @@ "y":304 }, { - "gid":355, + "gid":358, "height":76, "id":21, "name":"", @@ -311,7 +311,7 @@ "y":302 }, { - "gid":166, + "gid":169, "height":17, "id":35, "name":"", @@ -323,7 +323,7 @@ "y":156.333333333333 }, { - "gid":166, + "gid":169, "height":17, "id":36, "name":"", @@ -335,7 +335,7 @@ "y":185 }, { - "gid":166, + "gid":169, "height":17, "id":37, "name":"", @@ -347,7 +347,7 @@ "y":152.333333333333 }, { - "gid":166, + "gid":169, "height":17, "id":38, "name":"", @@ -360,7 +360,7 @@ }, { - "gid":354, + "gid":357, "height":79, "id":57, "name":"", @@ -372,7 +372,7 @@ "y":276.5 }, { - "gid":355, + "gid":358, "height":76, "id":58, "name":"", @@ -384,7 +384,7 @@ "y":276 }, { - "gid":355, + "gid":358, "height":76, "id":59, "name":"", @@ -396,7 +396,7 @@ "y":244.5 }, { - "gid":354, + "gid":357, "height":79, "id":60, "name":"", @@ -408,7 +408,7 @@ "y":242.5 }, { - "gid":169, + "gid":172, "height":21, "id":64, "name":"", @@ -420,7 +420,7 @@ "y":45.6666666666667 }, { - "gid":171, + "gid":174, "height":17, "id":65, "name":"", @@ -432,7 +432,7 @@ "y":34.6666666666666 }, { - "gid":170, + "gid":173, "height":21, "id":66, "name":"", @@ -444,7 +444,7 @@ "y":44.6666666666667 }, { - "gid":179, + "gid":182, "height":21, "id":67, "name":"", @@ -467,7 +467,7 @@ "name":"conditional_items", "objects":[ { - "gid":116, + "gid":119, "height":24, "id":39, "name":"", @@ -479,7 +479,7 @@ "y":300 }, { - "gid":126, + "gid":129, "height":21, "id":40, "name":"", @@ -491,7 +491,7 @@ "y":77 }, { - "gid":237, + "gid":240, "height":21, "id":49, "name":"", @@ -503,7 +503,7 @@ "y":256 }, { - "gid":231, + "gid":234, "height":21, "id":50, "name":"", @@ -515,7 +515,7 @@ "y":255.5 }, { - "gid":225, + "gid":228, "height":21, "id":51, "name":"", @@ -527,7 +527,7 @@ "y":220.75 }, { - "gid":254, + "gid":257, "height":17, "id":52, "name":"", @@ -539,7 +539,7 @@ "y":221.5 }, { - "gid":303, + "gid":306, "height":30, "id":62, "name":"", @@ -551,7 +551,7 @@ "y":97.5 }, { - "gid":302, + "gid":305, "height":33, "id":63, "name":"", @@ -580,7 +580,7 @@ "y":0 }], "nextlayerid":10, - "nextobjectid":70, + "nextobjectid":72, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.11.2", @@ -628,20 +628,20 @@ "tileheight":74, "tiles":[ { - "id":0, - "image":"..\/..\/..\/..\/PixelArt\/AI\/tables\/desk-ceo1.png", + "id":3, + "image":"..\/tables\/desk-ceo1.png", "imageheight":74, "imagewidth":78 }, { - "id":1, - "image":"..\/..\/..\/..\/PixelArt\/AI\/tables\/desk1.png", + "id":4, + "image":"..\/tables\/desk1.png", "imageheight":39, "imagewidth":78 }, { - "id":2, - "image":"..\/..\/..\/..\/PixelArt\/AI\/tables\/reception_table1.png", + "id":5, + "image":"..\/tables\/reception_table1.png", "imageheight":47, "imagewidth":174 }], @@ -649,7 +649,7 @@ }, { "columns":0, - "firstgid":116, + "firstgid":119, "grid": { "height":1, @@ -2160,7 +2160,7 @@ }, { "columns":6, - "firstgid":380, + "firstgid":383, "image":"..\/tiles\/door_side_sheet_32.png", "imageheight":32, "imagewidth":192, diff --git a/assets/rooms/room_reception2.tmj b/assets/rooms/room_reception2.tmj index 39f3422..df4afe8 100644 --- a/assets/rooms/room_reception2.tmj +++ b/assets/rooms/room_reception2.tmj @@ -34,12 +34,12 @@ { "data":[0, 101, 0, 0, 0, 0, 0, 0, 101, 0, 0, 107, 0, 0, 0, 0, 0, 0, 107, 0, - 380, 0, 0, 0, 0, 0, 0, 0, 0, 380, + 383, 0, 0, 0, 0, 0, 0, 0, 0, 383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, - 380, 0, 0, 0, 0, 0, 0, 0, 0, 380, + 383, 0, 0, 0, 0, 0, 0, 0, 0, 383, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0], "height":10, @@ -58,16 +58,16 @@ "name":"tables", "objects":[ { - "gid":115, + "gid":118, "height":47, - "id":15, + "id":71, "name":"", "rotation":0, "type":"", "visible":true, "width":174, - "x":76, - "y":90 + "x":75.6666666666667, + "y":89.6666666666667 }], "opacity":1, "type":"objectgroup", @@ -81,7 +81,7 @@ "name":"table_items", "objects":[ { - "gid":351, + "gid":354, "height":23, "id":27, "name":"", @@ -93,7 +93,7 @@ "y":64.5 }, { - "gid":351, + "gid":354, "height":23, "id":28, "name":"", @@ -105,7 +105,7 @@ "y":65 }, { - "gid":156, + "gid":159, "height":23, "id":33, "name":"", @@ -117,7 +117,7 @@ "y":54.6666666666667 }, { - "gid":159, + "gid":162, "height":20, "id":34, "name":"", @@ -129,7 +129,7 @@ "y":54.6666666666667 }, { - "gid":223, + "gid":226, "height":17, "id":47, "name":"", @@ -152,7 +152,7 @@ "name":"conditional_table_items", "objects":[ { - "gid":182, + "gid":185, "height":14, "id":45, "name":"", @@ -164,7 +164,7 @@ "y":65.25 }, { - "gid":213, + "gid":216, "height":11, "id":46, "name":"", @@ -176,7 +176,7 @@ "y":65.75 }, { - "gid":220, + "gid":223, "height":16, "id":48, "name":"", @@ -188,7 +188,7 @@ "y":51 }, { - "gid":305, + "gid":308, "height":16, "id":54, "name":"", @@ -200,7 +200,7 @@ "y":69.5 }, { - "gid":331, + "gid":334, "height":12, "id":55, "name":"", @@ -212,7 +212,7 @@ "y":62.1666666666667 }, { - "gid":336, + "gid":339, "height":18, "id":56, "name":"", @@ -224,7 +224,7 @@ "y":66 }, { - "gid":371, + "gid":374, "height":28, "id":69, "name":"", @@ -247,7 +247,7 @@ "name":"items", "objects":[ { - "gid":352, + "gid":355, "height":37, "id":16, "name":"", @@ -259,7 +259,7 @@ "y":219 }, { - "gid":352, + "gid":355, "height":37, "id":17, "name":"", @@ -271,7 +271,7 @@ "y":248 }, { - "gid":353, + "gid":356, "height":37, "id":18, "name":"", @@ -283,7 +283,7 @@ "y":218 }, { - "gid":353, + "gid":356, "height":37, "id":19, "name":"", @@ -295,7 +295,7 @@ "y":250 }, { - "gid":354, + "gid":357, "height":79, "id":20, "name":"", @@ -307,7 +307,7 @@ "y":304 }, { - "gid":355, + "gid":358, "height":76, "id":21, "name":"", @@ -319,7 +319,7 @@ "y":302 }, { - "gid":166, + "gid":169, "height":17, "id":35, "name":"", @@ -331,7 +331,7 @@ "y":156.333333333333 }, { - "gid":166, + "gid":169, "height":17, "id":36, "name":"", @@ -343,7 +343,7 @@ "y":185 }, { - "gid":166, + "gid":169, "height":17, "id":37, "name":"", @@ -355,7 +355,7 @@ "y":152.333333333333 }, { - "gid":166, + "gid":169, "height":17, "id":38, "name":"", @@ -368,7 +368,7 @@ }, { - "gid":354, + "gid":357, "height":79, "id":57, "name":"", @@ -380,7 +380,7 @@ "y":276.5 }, { - "gid":355, + "gid":358, "height":76, "id":58, "name":"", @@ -392,7 +392,7 @@ "y":276 }, { - "gid":355, + "gid":358, "height":76, "id":59, "name":"", @@ -404,7 +404,7 @@ "y":244.5 }, { - "gid":354, + "gid":357, "height":79, "id":60, "name":"", @@ -416,7 +416,7 @@ "y":242.5 }, { - "gid":169, + "gid":172, "height":21, "id":64, "name":"", @@ -428,7 +428,7 @@ "y":45.6666666666667 }, { - "gid":171, + "gid":174, "height":17, "id":65, "name":"", @@ -440,7 +440,7 @@ "y":34.6666666666666 }, { - "gid":170, + "gid":173, "height":21, "id":66, "name":"", @@ -452,7 +452,7 @@ "y":44.6666666666667 }, { - "gid":179, + "gid":182, "height":21, "id":67, "name":"", @@ -475,7 +475,7 @@ "name":"conditional_items", "objects":[ { - "gid":116, + "gid":119, "height":24, "id":39, "name":"", @@ -487,7 +487,7 @@ "y":300 }, { - "gid":126, + "gid":129, "height":21, "id":40, "name":"", @@ -499,7 +499,7 @@ "y":77 }, { - "gid":237, + "gid":240, "height":21, "id":49, "name":"", @@ -511,7 +511,7 @@ "y":256 }, { - "gid":231, + "gid":234, "height":21, "id":50, "name":"", @@ -523,7 +523,7 @@ "y":255.5 }, { - "gid":225, + "gid":228, "height":21, "id":51, "name":"", @@ -535,7 +535,7 @@ "y":220.75 }, { - "gid":254, + "gid":257, "height":17, "id":52, "name":"", @@ -547,7 +547,7 @@ "y":221.5 }, { - "gid":303, + "gid":306, "height":30, "id":62, "name":"", @@ -559,7 +559,7 @@ "y":97.5 }, { - "gid":302, + "gid":305, "height":33, "id":63, "name":"", @@ -588,7 +588,7 @@ "y":0 }], "nextlayerid":10, - "nextobjectid":70, + "nextobjectid":72, "orientation":"orthogonal", "renderorder":"right-down", "tiledversion":"1.11.2", @@ -617,7 +617,7 @@ }, { "columns":0, - "firstgid":116, + "firstgid":119, "grid": { "height":1, @@ -2127,7 +2127,7 @@ "tilewidth":251 }, { - "firstgid":380, + "firstgid":383, "source":"..\/..\/..\/assets\/rooms\/door_side_sheet_32.tsx" }], "tilewidth":32, diff --git a/assets/rooms/tables.tsx b/assets/rooms/tables.tsx index 786b2ac..fbfc086 100644 --- a/assets/rooms/tables.tsx +++ b/assets/rooms/tables.tsx @@ -1,13 +1,13 @@ - + - - + + - - + + - - + + diff --git a/js/core/rooms.js b/js/core/rooms.js index a5e9819..798421e 100644 --- a/js/core/rooms.js +++ b/js/core/rooms.js @@ -1978,6 +1978,65 @@ export function createRoom(roomId, roomData, position) { // Initially hide the object sprite.setVisible(false); + // Set up collision for tables + if (type === 'table') { + // Add physics body to table (static body) + gameRef.physics.add.existing(sprite, true); + + // Wait for the next frame to ensure body is fully initialized + gameRef.time.delayedCall(0, () => { + if (sprite.body && typeof sprite.body.setImmovable === 'function') { + sprite.body.setImmovable(true); + + // Set custom collision box - bottom third of height, inset 10px from sides + const tableWidth = sprite.width; + const tableHeight = sprite.height; + const collisionWidth = tableWidth - 20; // 10px inset on each side + const collisionHeight = tableHeight / 3; // Bottom third + const offsetX = 10; // 10px inset from left + const offsetY = tableHeight - collisionHeight; // Bottom third + + sprite.body.setSize(collisionWidth, collisionHeight); + sprite.body.setOffset(offsetX, offsetY); + + console.log(`Set table ${imageName} collision box: ${collisionWidth}x${collisionHeight} at offset (${offsetX}, ${offsetY})`); + + // Add collision with player + const player = window.player; + if (player && player.body) { + gameRef.physics.add.collider(player, sprite); + console.log(`Added collision between player and table: ${imageName}`); + } + } else { + console.warn(`Table ${imageName} body not ready or setImmovable not available:`, sprite.body); + // Try alternative approach - set immovable property directly + if (sprite.body) { + sprite.body.immovable = true; + + // Set custom collision box - bottom third of height, inset 10px from sides + const tableWidth = sprite.width; + const tableHeight = sprite.height; + const collisionWidth = tableWidth - 20; // 10px inset on each side + const collisionHeight = tableHeight / 3; // Bottom third + const offsetX = 10; // 10px inset from left + const offsetY = tableHeight - collisionHeight; // Bottom third + + sprite.body.setSize(collisionWidth, collisionHeight); + sprite.body.setOffset(offsetX, offsetY); + + console.log(`Set table ${imageName} collision box (fallback): ${collisionWidth}x${collisionHeight} at offset (${offsetX}, ${offsetY})`); + + // Add collision with player + const player = window.player; + if (player && player.body) { + gameRef.physics.add.collider(player, sprite); + console.log(`Added collision between player and table: ${imageName}`); + } + } + } + }); + } + // Store the object in the room if (!rooms[roomId].objects) { rooms[roomId].objects = {};