Game development log #2

Let start with the initial game setup!

Admin configs

Zephyros day 4


Map tiles and player sprites

One of the things I wanted to make different from the demo was to use better graphics and increase the tiles size, instead of use the demo setup (32x32), I wanted to try something bigger, like 64x64 or even 120x120, this way the details will be more visible instead of just pixel art (don't get me wrong, I love pixel art, but I wanted to try something different here).

All these specifications must be changed in Reldens basic configuration (this is going to the documentation as well).

In order to change these you can use the administration panel:

- Go to "Settings" > "Config" > and filter by the "path".

- Or run an update query in the database (which is a better approach if you like to have like a migration or setup script for your own game):

UPDATE `config` SET `value` = 64 WHERE `scope` = 'client' AND (`path` = 'map/tileData/width' OR `path` = 'map/tileData/height');

Since I've duplicated the tiles size, then I need to also duplicate the players size, for now, I will use twice the value from the demo as well (when I get the final player sprite I will set the correct size here):

UPDATE `config` SET `value` = 104 WHERE `scope` = 'client' AND `path` = 'players/size/width';
UPDATE `config` SET `value` = 142 WHERE `scope` = 'client' AND `path` = 'players/size/height';

And also I need to set the player speed (since the tiles are bigger the movement has to be faster):

UPDATE `config` SET `value` = 300 WHERE `scope` = 'client' AND `path` = 'players/physicsBody/speed';
UPDATE `config` SET `value` = 0.06 WHERE `scope` = 'server' AND `path` = 'rooms/world/timeStep';
INSERT INTO `config` (`scope`, `path`, `value`, `type`) VALUES ('server', 'rooms/world/movementSpeed', '300', 2);

UPDATE: don't use the last INSERT, in beta.30 I'm including the config so you should use an UPDATE.

As you can see these values were not matching the tiles size since this is just for the client side where the player sprite includes some empty space on the sides.

Tiled map tile row and col

Creating the initial scene

Next, was to setup the intial scene.

At this point I've realized that I had to include the tilemap.json file and the tileset image on the repository... which is not by far the expected considering we have the admin panel... so there goes the first "TODO" because I really don't want to spent the time RIGHT NOW on fighting with AdminJS.

...moving forward... Create the room record (again this is the only part that can be done from the admin or the database):

INSERT INTO `rooms` (`name`, `title`, `map_filename`, `scene_images`, `room_class_key`, `customData`) 
 VALUES ('Town1', 'Riven', 'town-001', 'town-001', '', NULL);

Then setup the scene starting point, for which you need to know the X and Y, to calculate this you can use TiledMap reference, when you click on a tile the app will show you the row and column for that tile, then you just need to multiply the tiles by the tile size, for example: for a tile in row 20 and colum 20 where the tile size is 64 x 64, we get 20 x 64 = 1280, so 1280 for X and Y since in this case it's the same amount.

INSERT INTO `rooms_return_points` (`room_id`, `direction`, `x`, `y`, `is_default`, `from_room_id`) VALUES (NULL, 'down', 1280, 1280, 1, NULL);

Another TODO was included: create a reference for the possible directions.

Then I've included the player sprite also in the repository:

theme/zephyros/assets/custom/sprites/player-test.png

Rebuild the client and reboot the server... This part of the process will be improved as well but it will be when I push the room hot-plug feature.As for now you should be able to login and start getting something like:ERROR - Classes not defined, can not populate the classes selector.

Some reminders:
- room.name can't have empty spaces, the name is used on the room server definition (it will remove everything after the first space).
- Embed your tilesets on the map editor file before export it as JSON.
- Make sure the "map_filename" is the same as the tileset name in the JSON.
- The app TiledEditor will allow you to use tilesets without verify if the amount of tiles fit the tile size, but Phaser will throw an error if the tile count multiplied by the tile size is not the same as the image size.
Create player zephyros

Setting up some basic data


Since I've edited the default template (index.html), and renamed the game container from "reldens" to "zephyros", I need to update this info on the config:

UPDATE `config` SET `value` = 'zephyros' WHERE `scope` = 'client' AND `path` = 'gameEngine/parent';
UPDATE `config` SET `value` = 'zephyros' WHERE `scope` = 'client' AND `path` = 'gameEngine/scale/parent';

So, let's populate the database with some basic data (this is where normally the sample data comes handy).

First the level set:

INSERT INTO `skills_levels_set` (`autoFillRanges`, `autoFillExperienceMultiplier`) VALUES (1, NULL);

Then the class path, for which you will need to know the level set ID, so two queries here:

SET @levelSetId = (SELECT `id` FROM `skills_levels_set` LIMIT 1);

INSERT INTO `skills_class_path` (`key`, `label`, `levels_set_id`) VALUES ('base', 'Base', @levelSetId);

Here I've hit another bug, the class path will require an additional image because it's not hitting the player fallback image, so for now I'm duplicating the file:

copy: theme/zephyros/assets/custom/sprites/player-base.png
to: theme/zephyros/assets/custom/sprites/base.png 
which is the `skill_class_path`.`key` value

Next is the initial level:

SET @levelSetId = (SELECT `id` FROM `skills_levels_set` LIMIT 1);
INSERT INTO `skills_levels` (`key`, `label`, `required_experience`, `level_set_id`) VALUES (1, '1', 0, @levelSetId);


With all this we should be ready to give it a try!

So, good progress on a single day! The game is up and running!


As for the next steps I'm going back to Reldens over the next week to fix the bugs I've found and try to include some improvements!

- Bugs found (included in the board to be fixed https://github.com/damian-pastorini/reldens/projects/2):

- [Bug] - ERROR - Configuration level 2 > "groupBaseData" not defined

- [Bug] - Error: Creation query failed error. Invalid or missing value for: autoFillRanges. Make sure checkboxes will get a default value when empty.

- [Bug] - AdminJS issue on authenticated router.

- [Bug] - Fix default fallback from class path image to player image.

- [Bug] - Make sure system config for speeds are been used properly. See rooms/world/movementSpeed and players/physicsBody/speed.

- [Core] - On admin panel include room files upload and validate the tilemap image size like Phaser does.


Total hours worked: 23hs.