Level Editor: loading/saving custom files

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Rednib

Hello,

i am making a 2d isometric action rpg game (like Diablo) with Godot and i want to make my own level editor for it also in Godot. For that i need to load and save my own map files, character sheets and tilesets. Therefore i dont want to use Godot for creating the levels as i want to hand out the editor as well for the players so they can make there own maps with there own character sheets and tilesets. So i don’t want to create a .tres file for the tilesets and character sheets, i want to load the animation frames directly from a png file. Also i want to create/load a map file (json) and create the isometric map from there.

I thought i would use json files for the map files, a simple 2D array with the frame number of the tile in the tileset where one tile is 128x64pixels. The map has 3 layers: ground layer, wall/object layer (with depth sorting) and a top layer. The character sheet consists of 128x128 pixel tiles. Each sheet contains animation for idle, walk, attack, hit and death. Each animation consists of 4 frames. There are animations for 8 directions.

My question is, since i don’t create the levels and characters within the Godot editor, how do i load them from a file? Is is possible to do such thing?

I only want to code the core mechanics in Godot and do the visual stuff in my own editor (Map creation, placing objects/player/enemies/npc’s etc.)

I know how to do such stuff in languages/frameworks like java/libGDX or lua/love2D and so on. But i don’t know how to do it in Godot. (Im relatively new)

I switched from lua/love2D because i don’t want to write a isometric engine and stuff from scratch again and use all the nice features that are build-in the Godot engine. (Depth sorting is just a click of a button, changing from normal to iso projection is just adusting the camera parameters, there is a animated sprite feature and all that stuff)

:bust_in_silhouette: Reply From: Zylann

since i don’t create the levels and characters within the Godot editor, how do i load them from a file? Is is possible to do such thing?

It is possible to create all nodes and resources from code. Instanciate their class, set properties, add to the tree. There is is also a way to read and write files using the File class, so yes it’s possible.

For JSON you can use the JSON singleton:

For loading images, use the Image class, which supports PNG: