Log In  

I’m a random 13 Y. O. guy with a passion for retro games, programming, and math.

[ :: Read More :: ]

Cart #marching_squares-0 | 2024-04-26 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA

Basically, I’m working on a digging game and am revisiting something I have worked with in the past: marching squares. I recommend looking it up, but basically the way it works in this project is for each “tile” a table of tables is examined and depending on whether each of the tiles coordinates are on or off the algorithm figure out which sides does the line on the square intersect. Sometime marching squares also uses linear interpolation, but since my screen is stored in binary instead of floating point values I am storing intersection points in separate nested tables. The main thing is that each square is checked, and depending on stored values a specific line might be drawn through it.

This is a basic proof of concept editor, and next up I will probably start to face the horror of adding collisions to this bendy abomination. Also note that my code is probably poorly written so if you want to use it for something you may consider changing some of it to make it take up less valuable space.

Directions move the cursor
X implements the current mode
O changes the mode
0-add points of binary
1-delete points of binary
2-edit left side intercept
3-edit top intercept

P#147358 2024-04-26 07:02 ( Edited 2024-04-26 07:07)