Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- Reldens - v4.0.0-beta.39 #269

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4ae8bae
- Reldens - v4.0.0 - Bump package version.
damian-pastorini Dec 8, 2024
7196170
- Reldens - v4.0.0 - README.
damian-pastorini Dec 15, 2024
e4e6484
- Reldens - v4.0.0 - Removed unused commented code.
damian-pastorini Dec 15, 2024
0a04086
- Reldens - v4.0.0 - Add new TODO.
damian-pastorini Dec 15, 2024
b43412c
- Reldens - v4.0.0 - Add new TODO.
damian-pastorini Dec 15, 2024
46b13ba
- Reldens - v4.0.0 - Removed unused files.
damian-pastorini Dec 15, 2024
9517910
- Reldens - v4.0.0 - Moved background image to inline style. - Fix fo…
damian-pastorini Dec 15, 2024
4283982
- Reldens - v4.0.0 - Replaced imports by use. - Fix fonts.
damian-pastorini Dec 15, 2024
add2a4d
- Reldens - v4.0.0 - Update packages.
damian-pastorini Jan 15, 2025
380b69a
- Reldens - v4.0.0 - Include missing element validation on inventory.
damian-pastorini Jan 15, 2025
81cffe3
- Reldens - v4.0.0 - Fix small maps view camera and UI resize, includ…
damian-pastorini Jan 15, 2025
1fe0aef
- Reldens - v4.0.0 - Include config updates.
damian-pastorini Jan 15, 2025
73262de
- Reldens - v4.0.0 - Include alias on config update script.
damian-pastorini Jan 15, 2025
a80003e
- Reldens - v4.0.0 - Reduce default game size.
damian-pastorini Jan 21, 2025
c2d8754
- Reldens - v4.0.0 - Include TODO.
damian-pastorini Jan 21, 2025
a1895c5
- Reldens - v4.0.0 - Refactor destroy previous scene method to make m…
damian-pastorini Jan 21, 2025
0970101
- Reldens - v4.0.0 - Fix tilesets key for broken tilemaps with multip…
damian-pastorini Jan 21, 2025
e822220
- Reldens - v4.0.0 - Remove duplicated assignment that was already in…
damian-pastorini Jan 22, 2025
524cb96
- Reldens - v4.0.0 - Fix usedTiles not been deleted issue.
damian-pastorini Jan 22, 2025
d010861
- Reldens - v4.0.0 - Fix tileset key to match multiple images case key.
damian-pastorini Jan 22, 2025
d974cc8
- Reldens - v4.0.0 - Set default minimap camera zoom out.
damian-pastorini Jan 22, 2025
0574a4c
- Reldens - v4.0.0 - Include missing body data on interpolation metho…
damian-pastorini Jan 26, 2025
5a017ec
- Reldens - v4.0.0 - Improve objects importer to import experience, a…
damian-pastorini Jan 26, 2025
73742c9
- Reldens - v4.0.0 - Include TODO.
damian-pastorini Jan 26, 2025
b4b8655
- Reldens - v4.0.0 - Improved validation.
damian-pastorini Jan 26, 2025
d94fa07
- Reldens - v4.0.0 - Fix objects animation default values.
damian-pastorini Jan 26, 2025
f615b92
- Reldens - v4.0.0 - Fix rewards default values.
damian-pastorini Jan 26, 2025
eaf027d
- Reldens - v4.0.0 - Fix default player stats keys on sample data scr…
damian-pastorini Jan 26, 2025
9394267
- Reldens - v4.0.0 - Fix default player stats keys on sample data upd…
damian-pastorini Jan 26, 2025
965d7d2
- Reldens - v4.0.0 - Include missing sample link file in maps wizard.
damian-pastorini Jan 26, 2025
0a59dd5
- Reldens - v4.0.0 - Include elements validation in ErrorsBlockHandler.
damian-pastorini Jan 26, 2025
2f1993e
- Reldens - v4.0.0 - Fix allowGuestOnRooms validation to allow every …
damian-pastorini Jan 27, 2025
471f763
- Reldens - v4.0.0 - Include info logs on objects importer.
damian-pastorini Jan 29, 2025
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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Welcome to Reldens, a platform designed to empower developers in creating multip

With a wide array of features, Reldens enables developers to craft a rich gaming experience without grappling with the complexities usually associated with making a multiplayer game secure and efficient over any network.

Built with popular development tools such as NodeJS, Parcel, Colyseus, Phaser, and Firebase, integrated with various database engines, and following robust development practices, the platform ensures security, ease of use, and high customization for developers.
Built with popular development tools such as NodeJS, Parcel, Colyseus, Phaser and more, integrated with various database engines, and following robust development practices, the platform ensures security, ease of use, and high customization for developers.

While the current stage of the platform is tailored for developers, ongoing improvements to the administration panel aim to make game creation accessible to non-developers in the future.

Expand Down Expand Up @@ -96,7 +96,6 @@ Join our Discord channel: [https://discord.gg/HuJMxUY](https://discord.gg/HuJMxU

[![Ko-fi](https://img.shields.io/badge/Reldens-Support%20us%20on%20Ko--Fi-blue?style=for-the-badge)](https://ko-fi.com/I2I81VISA)
[![Patroen](https://img.shields.io/badge/Reldens-Become%20a%20Patroen-blue?style=for-the-badge)](https://www.patreon.com/bePatron?u=18074832)
[![Paypal](https://img.shields.io/badge/Reldens-Paypal%20Donation-blue?style=for-the-badge)](https://www.paypal.com/paypalme/damianpastorini)

If you like to contribute in any way or donate to support the project please also feel free to contact me at [info@dwdeveloper.com](mailto:info@dwdeveloper.com).

Expand Down
1 change: 0 additions & 1 deletion bin/generate.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ let validCommands = {
generatedFolder,
FileHandler.joinPaths(process.cwd(), 'generated')
);
// FileHandler.removeFolder(generatedFolder);
}
};

Expand Down
58 changes: 45 additions & 13 deletions lib/game/client/game-engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,16 @@ class GameEngine extends Game
return this.TemplateEngine.render(template, view, partials, tags);
}

// @TODO - BETA - Refactor for multiple sizes and remove the manager parameter.
updateGameSize(manager)
{
let {newWidth, newHeight} = this.getCurrentScreenSize(manager);
let {newWidth, newHeight, mapWidth, mapHeight, activeScene} = this.getCurrentScreenSize(manager);
setTimeout(() => {
this.eventsManager.emit('reldens.updateGameSizeBefore', this, newWidth, newHeight);
this.scale.setGameSize(newWidth, newHeight);
if(manager.config.getWithoutLogs('client/ui/screen/updateGameSizeEnabled', false)) {
this.scale.setGameSize(newWidth, newHeight);
}
this.centerSmallMapsCamera(manager, activeScene, newWidth, mapWidth, newHeight, mapHeight);
for(let key of Object.keys(this.uiScene.elementsUi)){
let uiElement = this.uiScene.elementsUi[key];
let positionKey = sc.get(this.uiScene.userInterfaces[key], 'uiPositionKey', key);
Expand All @@ -54,9 +58,10 @@ class GameEngine extends Game
uiElement.y = uiY;
}
this.eventsManager.emit('reldens.updateGameSizeAfter', this, newWidth, newHeight);
}, manager.config.getWithoutLogs('client/general/gameEngine/updateGameSizeTimeOut', 500));
}, manager.config.getWithoutLogs('client/general/gameEngine/updateGameSizeTimeOut', 100));
}

// @TODO - BETA - Refactor to remove the manager parameter and rename.
getCurrentScreenSize(manager)
{
let gameContainer = manager.gameDom.getElement(GameConst.SELECTORS.GAME_CONTAINER);
Expand All @@ -66,17 +71,44 @@ class GameEngine extends Game
let newHeight = containerHeight;
let mapWidth = 0, mapHeight = 0;
let activeScene = manager.getActiveScene();
if(activeScene && activeScene.map){
mapWidth = activeScene.map.width * activeScene.map.tileWidth;
newWidth = Math.min(containerWidth, mapWidth);
mapHeight = activeScene.map.height * activeScene.map.tileHeight;
newHeight = Math.min(containerHeight, mapHeight);
if(activeScene){
let activeSceneMap = activeScene.map;
if(activeSceneMap){
mapWidth = activeSceneMap.width * activeSceneMap.tileWidth;
mapHeight = activeSceneMap.height * activeSceneMap.tileHeight;
if(
manager.config.getWithoutLogs('client/ui/screen/adjustUiElementsToMapSize', false)
&& 0 < mapWidth
&& 0 < mapHeight
){
newWidth = Math.min(containerWidth, mapWidth);
newHeight = Math.min(containerHeight, mapHeight);
}
}
}
if(manager.config.getWithoutLogs('client/ui/maximum/enabled', true)){
let maxUiW = Number(manager.config.get('client/ui/maximum/x'));
newWidth = Math.min(newWidth, maxUiW);
let maxUiY = Number(manager.config.get('client/ui/maximum/y'));
newHeight = Math.min(newHeight, maxUiY);
}
return {newWidth, newHeight, containerWidth, containerHeight, mapWidth, mapHeight, activeScene};
}

centerSmallMapsCamera(manager, activeScene, newWidth, mapWidth, newHeight, mapHeight)
{
if(!manager.config.getWithoutLogs('client/ui/screen/centerSmallMapsCamera', true) || !activeScene){
return;
}
let cameraX = 0;
let cameraY = 0;
if (newWidth > mapWidth) {
cameraX = (newWidth - mapWidth) / 2;
}
if (newHeight > mapHeight) {
cameraY = (newHeight - mapHeight) / 2;
}
let maxUiW = Number(manager.config.get('client/ui/maximum/x'));
newWidth = Math.min(newWidth, maxUiW);
let maxUiY = Number(manager.config.get('client/ui/maximum/y'));
newHeight = Math.min(newHeight, maxUiY);
return {newWidth, newHeight};
activeScene.cameras.main.setPosition(cameraX, cameraY);
}

showTarget(targetName, target, previousTarget)
Expand Down
12 changes: 11 additions & 1 deletion lib/game/client/handlers/errors-block-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ class ErrorsBlockHandler

static reset(form)
{
if(!form){
return false;
}
let errorBlock = form.querySelector(GameConst.SELECTORS.RESPONSE_ERROR);
form.querySelector(GameConst.SELECTORS.INPUT).addEventListener('focus', () => {
if(!errorBlock){
return false;
}
let inputElement = form.querySelector(GameConst.SELECTORS.INPUT);
if(!inputElement){
return false;
}
inputElement.addEventListener('focus', () => {
errorBlock.innerHTML = '';
let loadingContainer = form.querySelector(GameConst.SELECTORS.LOADING_CONTAINER);
if(loadingContainer){
Expand Down
10 changes: 5 additions & 5 deletions lib/game/client/room-events.js
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,10 @@ class RoomEvents
}
// this event happens once for every scene:
await this.events.emit('reldens.createEngineScene', player, room, previousScene, this);
!this.gameManager.room
? this.gameEngine.scene.start(player.state.scene)
: await this.destroyPreviousScene(previousScene, player);
if(this.gameManager.room){
await this.destroyPreviousScene(previousScene, player);
}
this.gameEngine.scene.start(player.state.scene);
this.gameManager.room = room;
let currentScene = this.gameEngine.scene.getScene(player.state.scene);
currentScene.player = this.createPlayerEngineInstance(currentScene, player, this.gameManager, room);
Expand Down Expand Up @@ -730,7 +731,7 @@ class RoomEvents
return Array.from(room.state.players.keys());
}

async destroyPreviousScene(previousScene, player)
async destroyPreviousScene(previousScene)
{
if(!previousScene){
Logger.warning('Missing previous scene data.', previousScene);
Expand All @@ -743,7 +744,6 @@ class RoomEvents
}
await previousSceneInstance.changeScene();
this.gameEngine.scene.stop(previousScene);
this.gameEngine.scene.start(player.state.scene);
}

updateSceneLabel(newLabel)
Expand Down
14 changes: 7 additions & 7 deletions lib/game/client/scene-dynamic.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ class SceneDynamic extends Scene
this.player = false;
this.interpolatePlayersPosition = {};
this.interpolateObjectsPositions = {};
this.tilesets = [];
this.generatedTilesets = [];
this.tilesetAnimations = [];
this.stopOnDeathOrDisabledSent = false;
}
Expand Down Expand Up @@ -119,7 +119,8 @@ class SceneDynamic extends Scene
{
this.map = this.make.tilemap({key: this.params.roomName});
for(let imageKey of this.params.sceneImages){
let tileset = this.map.addTilesetImage(this.params.roomName, imageKey);
let tilesetName = imageKey.replace(/\.[^.]+$/, '');
let tileset = this.map.addTilesetImage(tilesetName, imageKey);
if(!tileset){
Logger.critical(
'Tileset creation error. Check if the tileset name equals the imageKey without the extension.',
Expand All @@ -130,16 +131,15 @@ class SceneDynamic extends Scene
}
);
}
//Logger.debug('Created tileset.', imageKey, this.params.roomName);
this.tilesets.push(tileset);
this.generatedTilesets.push(tileset);
}
this.registerLayers();
this.registerTilesetAnimation();
}

registerTilesetAnimation()
{
for(let tileset of this.tilesets){
for(let tileset of this.generatedTilesets){
if(!this.hasTilesetAnimations(tileset)){
continue;
}
Expand Down Expand Up @@ -414,7 +414,7 @@ class SceneDynamic extends Scene
}
let x = sc.roundToPrecision(Phaser.Math.Linear(entity.x, entityState.x, this.interpolationSpeed), 0);
let y = sc.roundToPrecision(Phaser.Math.Linear(entity.y, entityState.y, this.interpolationSpeed), 0);
let bodyData = {x, y, inState: entityState.inState, mov: entityState.mov};
let bodyData = {x, y, inState: entityState.inState, mov: entityState.mov, dir: entityState.dir};
objectsPlugin.updateObjectsAnimations(i, bodyData, this);
if(!entityState.mov){
delete this.interpolateObjectsPositions[i];
Expand Down Expand Up @@ -453,7 +453,7 @@ class SceneDynamic extends Scene
let depthBelowPlayer = this.configManager.get('client/map/layersDepth/belowPlayer');
let depthForChangePoints = this.configManager.get('client/map/layersDepth/changePoints');
for(let layer of this.map.layers){
this.layers[idx] = this.map.createLayer(layer.name, this.tilesets);
this.layers[idx] = this.map.createLayer(layer.name, this.generatedTilesets);
if(!this.layers[idx]){
Logger.critical('Map layer could not be created.', layer.name, this.key);
continue;
Expand Down
Loading
Loading