Source code
Executable (Windows 32bits)
Before you try to compile the code go to the "Projects" tab on the left menu, select the "Run" settings for your kit,
and set the "Working directory" to the path of "editor/data".
As we work we will have more and more source files and datas and it will be very difficult to retrieve them if we keep them all in the same folder.
Additionnaly, we will not only have the map editor project, but also another project for the game itself. And some files will be common to the two projects.
So we will reorganize the files a little bit.
First we will have a "common" folder that will contain:
- The Map.* files that now contains only the map description and the functions to access the tiles.
I removed the drawing function to put it somewhere else because this drawing is only for the editor, we won't need it in the game.
- The cmaths.* files as we also will use 2D coordinates in the game.
- The cgraphics2d.* files as we will use them to draw the game graphics.
I put the cmaths.* and the cgraphics2d.* files in a "system" subfolder because these are common functions which could have their place in a more generic engine
that could be used for others types of games.
Then we will have an "editor" folder with:
- MapEditor.pro, qml.qrc and the other files that Qt uses for the project.
- A "sources" folder with all the ".cpp" and ".h" files. There is now 2 new files named "editor.*" that contains the functions that I removed from the Map.* files.
That is to say the drawing function and the "tools" functions to change the tiles.
- A "qml" folder that contains all the qml files.
- A "gfx" folder that contains graphics that will be included in the executable file.
You will see that there are buttons inside. I will explain them later.
- A "data" folder with the datas that will be loaded by the program at runtime. At the moment there is only a "tiles" folder inside,
with the graphics that we use to draw the map.
In the future, there will be a 3rd folder for the game.
I added tools buttons on the right. They do not work yet, but I wanted to see how much size they would take.
From top to bottom we can see:
- The draw tool. It's the only one that works now as we can draw tiles in the map.
- The select tool. It will allow us to select a tile or a wall so that we can add data to it.
It will also allow us to select a rectangle of tiles to be copied or cut
- The copy tool.
- The cut tool.
- The paste tool.
You can see that the functions at the end of "editor.cpp" begins to take into account that there will be several tools.
And now we can draw walls. To achieve that I had to modify drawImage() so that it can draw a rotated tile.
The image of the wall is "Wall.png" in "editor\data\tiles"