Skip to content

moscout/moeditor

Repository files navigation

This is worlds (maps) editor for my space game mospace and mouniverse. It can be used for adding entities, edit their components & tags, and set some general world properties.

Screenshot

For installing/cloning this project you should also clone mospace project beside it. Editor uses assets and database files from this game. You don't have to compile the editor to run it, all the necessary release files (for windows) are located in the folder bin.

I am using MSYS2 for managing libraries that I use for development in C.

Dependencies:

~ raylib: for graphics and user events;
~ raygui: for immediate-mode gui;
~ flecs: fast entity component system;
~ sqlite: for reading/writing to database;
~ json-c: for reading/writing settings;
~ hashmap: hash map implementation in C;
~ string: for easy string manipulation;

It has four tool windows inside:

WORLD. X & Y coordinate of the top left corner in the global world (map) space. Use this sliders to move your map (maybe sometimes I will implement mini map). Also you can move the world using mouse, left click on free space and drag it. NAME is a world label, stored in the db and used for its selection. WIDTH & HEIGHT is the world size in pixels. Button SAVE inserts (updates) current world in the db. Button CREATE NEW creates new world. All unsaved changes will be lost. This operation does not affect the world data stored in the database. Button CLEAR WORLD just clear all entities from the current world. It does not remove anything in the db, you can roll back with loading this world.

ENTITY. ADDING SPRITE check box switch editor to adding mode when you will add current sprite to the world by left click. KEYWORD filters list of sprites bellow to simplify selection and prevent UI overflow. When you select sprite from drop down you will see it and its width & height. This is your current sprite for adding.

COMPONENTS. The corresponding components and tags for the current entity. Select the entity by left click (to make it active) and change its components. The current ROTATION angle and tags will also be used for newly added entities.

CONTROL. Displays current world (not window) mouse X & Y position. AUTO LAYOUT check box allows to move tool windows to the left automatically on window resize. Drop down with all world saved in the database used for buttons bellow. Button LOAD WORLD loads selected world to the editor. All unsaved changes in the current world will be lost. Button DELETE WORLD removes selected world from the database.

The editor has three mode:

Silent. This is an intermediate mode where you cannot edit, add, or delete entities. But you can move the map with the mouse - left click and drag. To enter this mode press ESC or right click.

Adding. Activates by ADDING SPRITE check box in the ENTITY tool window. Current entity sprite will be moved near mouse pointer, if you can't add it in the particular world position (due to its intersection with other sprites), it will be tinted by red color.

Editing. Select entity by left click (it starts tinted by purple). Such entity is active. If the are active entity editor is in the editing mode. You can edit entity components through COMPONENTS tool window. Also you can move the entity by mouse, rotate by LEFT & RIGHT keys, and rotate fast by angle 10 using CTRL+(LEFT/RIGHT) keys pressed. To delete entity press DEL key.

Use CTRL+F keys to turn on/off full screen mode.

All worlds are stored in SQLite database. Here the structure diagram:

Database diagram

Table sprite is just dictionary of sprites and according filenames in the assets folder.
Table tags is a dictionary of all possible tags.
Table tag is set of tags for particular entity. Its field names must repeat values from tags table.
Table world is collection of all existing worlds.
Tables position and rotation designed for corresponding components.
Table entity unites all components together for an entity instance in the world (world_id).

Diagram (for Navicat Data Modeler), creating and default data sql scripts located in the db folder of the game.

settings.json file.

{
	"db-path":	"../mospace/db/space.db",
	"assets-path":	"../mospace/assets/"
}

The editor counts on it being located next to the mospace game, so relative paths should work.

Hits

About

Worlds editor for space game [~ mirror ~].

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages