|
1 | 1 | # 2DMapEditor
|
2 | 2 |
|
3 | 3 | A minimalist 2D map editor.
|
| 4 | + |
4 | 5 | Create single layer 2D maps from a .png tileset.
|
| 6 | + |
5 | 7 | Export maps to txt, json, lua format.
|
6 | 8 |
|
| 9 | +Made with [love2d](https://love2d.org/). |
| 10 | + |
7 | 11 | ## Preview
|
8 |
| -img |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | +Tileset from https://ansimuz.itch.io/grotto-escape-game-art-pack |
9 | 16 |
|
10 | 17 | ## Features
|
11 | 18 |
|
@@ -41,52 +48,83 @@ This minimalist software does not provide any integrated tips or documentation,
|
41 | 48 |
|
42 | 49 | ### Get started
|
43 | 50 |
|
| 51 | +- Linux/MacOS install [love2d v11](https://love2d.org). |
44 | 52 | - Download the map editor.
|
45 | 53 | - Unzip it.
|
46 | 54 | - Add at least one tileset in the tileset/ directory.
|
47 | 55 | - Edit the "editor.txt" file next to the map editor and change some settings to fit your need.
|
48 |
| -- Run the map editor. |
| 56 | +- Run the map editor (on Linux/MacOS either double click on the .love file or use `$ love 2d_map_editor.love` from the command prompt). |
49 | 57 | - Create a map.
|
50 | 58 | - Export your map.
|
51 | 59 | - Your exported map should now appear in the map/ directory.
|
52 | 60 |
|
53 | 61 | ### Shortcuts
|
54 | 62 |
|
55 |
| -- Draw: d |
56 |
| -- Erase: e |
57 |
| -- Fill: f |
58 |
| -- Tile picker: alt |
59 |
| -- Move: |
60 |
| - - arrow |
61 |
| - - space (keep pressed until done) + mouse left |
62 |
| -- Zoom: scroll |
| 63 | +| Keys | Description | |
| 64 | +|--- |--- |
| 65 | +| <kbd>D</kbd> | Draw | |
| 66 | +| <kbd>E</kbd> | Erase | |
| 67 | +| <kbd>F</kbd> | Fill | |
| 68 | +| <kbd>Alt</kbd> | Tile picker | |
| 69 | +| Mouse Right | Tile picker | |
| 70 | +| <kbd>←</kbd><kbd>↑</kbd><kbd>→</kbd><kbd>↓</kbd> | Move | |
| 71 | +| <kbd>Spacebar</kbd> + Mouse Left | Move | |
| 72 | +| Mouse Wheel | Zoom | |
63 | 73 |
|
64 | 74 | ---
|
65 | 75 |
|
66 | 76 | ## Input/Output Format
|
67 | 77 |
|
68 |
| -A 2d map is encoded as a 2d array of numbers. Each number matches a tileset tile. |
| 78 | +A 2d map is encoded as a 2d array of numbers. Each number matches a tile from the tileset. |
| 79 | + |
| 80 | +Considering the following tileset: |
| 81 | + |
| 82 | + |
69 | 83 |
|
70 |
| -tileset\_to\_number\_img |
| 84 | +And this 2d array of number: |
| 85 | + |
| 86 | +```lua |
| 87 | +{ |
| 88 | + {19, 19, 1, 4, 19}, |
| 89 | + {21, 19, 9, 19, 19}, |
| 90 | + {19, 19, 19, 19, 19}, |
| 91 | + {16, 16, 6, 15, 16}, |
| 92 | + {13, 13, 13, 13, 13} |
| 93 | +} |
| 94 | +``` |
| 95 | + |
| 96 | +We get the following map: |
| 97 | + |
| 98 | + |
71 | 99 |
|
72 |
| -txt\_img |
73 |
| -json\_img |
74 |
| -lua\_img |
75 | 100 |
|
76 | 101 | ## Importing a Map to Your Project
|
77 | 102 |
|
78 | 103 | ### With Lua (5.1)
|
79 | 104 |
|
80 |
| -If your using the lua programming language you can use this piece of code(TODO link) to parse it (lua 5.1 is used for the project, it may not work with other version). |
| 105 | +If your using the lua programming language, just require the map in your project: |
| 106 | +```lua |
| 107 | +local map = require("path/to/my/map") |
| 108 | +``` |
81 | 109 |
|
82 | 110 | ### Without Lua
|
83 | 111 |
|
84 |
| -Find a parser corresponding to the file format you want your map to be into, or create one (you can use this code(TODO link) as an example) |
| 112 | +Create/find a parser for the file format you want your map to be in. |
85 | 113 |
|
86 | 114 | ---
|
87 | 115 |
|
88 | 116 | ## Project Status
|
89 |
| -The project is currently almost finished, however feel free to open an issue if you encounter one. No features will be added. |
90 | 117 |
|
91 |
| -## Why this project ? |
92 |
| -TODO |
| 118 | +The project is currently finished, however feel free to open an issue if you encounter one. No features will be added. |
| 119 | + |
| 120 | +## Why this Project & more... |
| 121 | + |
| 122 | +Initialy I wanted to be able to create maps for my 2d games, I tried [tiled](https://www.mapeditor.org/) but it's a big editor with tons of features and it was exporting maps in the json format, so I should have learned how to use the editor and use a library to parse json files. |
| 123 | + |
| 124 | +Since I only needed single layers maps I started this little project. |
| 125 | +It was one of my first desktop application so it was very interesting on many points. |
| 126 | + |
| 127 | +I created the map editor 2+ years ago but I never finished some features/polish but used it in multiple projects like [It Alive](https://mathurin.itch.io/italive). It's why I came back on it with the desire to make the initial idea come true. |
| 128 | +I find the project/code structure really bad now and that's a good thing, it means that my programming practices/skills have improved since. |
| 129 | +If I had to do it again now, I would do it in a much different maner. |
| 130 | +Thanks for reading. |
0 commit comments