Log In  

Cart #twodlineeditor-0 | 2022-11-15 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

This tool allows you to map lines on a plane and export them into any of your carts.

Each line is represented as a table with values x1,y1,x2,y2.
This is useful for raycast projects or whatever you need to map lines for.

Buttons (left-up corner of the screen, top to bottom):

Temp save: temporarily saves all line data to adresses 0x4300-0x5dff in console memory.
Load: loads data at adresses 0x4300-0x5dff. Can be used as reserve copy.
Toggle ruler: Each line displays it's length to the right of it's 2nd point.
Export: allows you to type in your desired cart's name and export line data to it's addresses 0x4300-0x5dff. This overwrites your cartridge file so make sure you don't have anything valuable in there (sprites, map, sounds and, obviously, code are safe).

Modes: (down side of the screen, left to right):

Click: right-click to select the line and distplay it's info, left-click to deselect.
Pan: left-click drag across the plane to view different parts of it.
Draw: left-click and drag to create a new line at your pointer position.
Delete: left-click near the line to delete it. Lines that will be affected are highlighted red.


Each line takes 8 bytes of space (2 bytes per 16-bit variable, 4 variables).
All memory in the aforementioed range is cleared before writing line data.

How to read line data back:

In your original cartridge, you can do something like this:

for i=0x4300,0x5dff,8 do
 local x1=peek2(i)
 local y1=peek2(i+2)
 local x2=peek2(i+4)
 local y2=peek2(i+6)
 local line={x1=x1,y1=y1,x2=x2,y2=y2}
P#120768 2022-11-15 19:44 ( Edited 2022-11-15 19:58)

Hi, @collinthenewmaker.

I was experimenting with your line tool. I think it would be better if it had a SNAP function. That is, while you can see the grid, have a sub-grid option where since you are using the mouse, when you add a point, they would SNAP to the closest grid point allowing for smoother and more accurate movements.

P#120778 2022-11-15 22:34

Hello @dw817 .
The grid is kind of a thing to show the movement when panning and an alignment tool to draw straight lines quicker. It's intersection points are 30 units away from each other. So snapping to grid of this size is not the best for every world, because, for example, in some games the player size is 3 units, and in some it's 10, and the size if the snap grid is too big or too small. Maybe if I add the snap function, I should also add resizable grid cells. Thanks for feedback!

P#120787 2022-11-16 04:54

Nono, @collinthenewmaker.

The grid would be cosmetic. Not saved with the final output lines. You can snap to any grid size and in the same line work choose a different grid size.

In no way would you be restricted to a single grid size for a project.

P#120805 2022-11-16 16:28

@dw817 No, I didn't also mean that the grid will be saved with the limes. It's the snapping your lines to a grid that wouldn't be always handy if it wasn't resizable. For example, if in your game size of an average room is 20 units, and in the tool snapping points are 10 px away from eachother, then your room could be only twice as small, and you wouldn't want to use the grid at all if you needed more precise snapping. So I said that if I bothered making a snap grid, I should also make it resizable.

P#120920 2022-11-18 17:23

Absolutely, @collinthenewmaker. This is what I meant. Look at the last program I wrote to see it already incorporates a completely resizable grid.


To SNAP to the grid in mine, just hold down the CTRL plus arrow keys. To navigate without the snap, just press the arrow keys as normal.

P#120924 2022-11-18 17:42 ( Edited 2022-11-18 18:47)

[Please log in to post a comment]