OZONE Asylum
Forums
Server-Side Scripting - Oh my!
Godot and Auto-Tiling WJ-style
This page's ID:
33334
Search
QuickChanges
Forums
FAQ
Archives
Register
Edit Post
Who can edit a post?
The poster and administrators may edit a post. The poster can only edit it for a short while after the initial post.
Your User Name:
Your Password:
Login Options:
Remember Me On This Computer
Your Text:
Insert Slimies »
Insert UBB Code »
Close
Last Tag
|
All Tags
UBB Help
Towards the end of quarantine in my area, I was finally getting my mojo back. I was getting into Godot, Krita, and Blender to make a game. Little did I know that I would be heading off into a vastly wild direction. I just wanted to make a little thing for myself, but ended up digging down yet another hole. Now I'm back to my regular job and don't have much time for these things. And yet I still try my damnest to find an oasis of time to play with the things that I love and adore. I love manipulating data. I will look at data in multiple ways until I see something that makes sense to me. I will then understand it and manipulate it to my will. Mixing dimensions and all that. I also love chaos vs. order. So many different flavors of chaos can be introduced into an ordered system - a rogue-like hint of randomness. You know, Loki's smirk. Like sand through my fingers. Data is data. Chaos is chaos. As things go, no telling when I will get to the next installment.s --------- For many years I've been wanting to make a very specific top-down tank game. So, not too long ago, I grabbed Godot, Krita, and Blender. Then I got to work playing around just to see. With some mock graphics and a dual analog controller, I was making some decent progress. Then I got side-tracked with Godot's auto-tiling. Like, seriously side- tracked. Why do I always seem to find an irresistible rabbit hole? So, what's the deal with auto-tiling? Well, once you have it set up, you can "paint" maps and levels. Here is one that comes to mind: https://michagamedev.wordpress.com/2018/02/24/181/ That link shows the 2x2 version of auto-tiling. As it turns out, there is a more intensive 3x3 version. Check this out: https://kidscancode.org/godot_recipes/2d/autotile_intro/ Surely, 3x3 is the way to go. You've got to make 47 tiles, but worth it, right? It's got to be better than 2x2 with 16 tiles. Right?! I set about making my first 3x3 w/ 47 tiles. I grabbed some graph paper, some coloured pencils, and got to work. I never made it past one piece of graph paper. On this graph paper, I used purple and orange to colour in a single bit mask. Then I would perm it. Then another bit mask with more purple and orange, and perm it. Absolutely beautiful. I had set this paper on a table near my front door. Something about it kept nagging at me. Something about it looked odd, or familiar... rather, oddly familiar. One day, when I came home, I glanced at it and it hit me. Turns out that each 3x3 is actually the sum of 4 2x2's. To use a certain kind of notation, this: [code] ### #.# ### [/code] Is equal to this: [code] ## ## #. .# #. .# ## ## [/code] Every single 3x3 purple and orange tile that I looked at really is the sum of 4 2x2's. It's just a matter of changing scale a tad and changing your thinking a tad more. (A few days later I did find a web page that has the same observation on it, but I can't seem to find it again. :sigh:) For my uses, 3x3 is over-kill. A simple 2x2 will serve my purposes just fine. But how to "paint" in a simple way that uses 2x2? After two days of doing the Zen thing, I finally saw it in my head. After another day, I understood it enough to do the code thing. I suddenly knew how to paint a pixel map and output a 2x2 map that is indistinguishable from a 3x3 map. The trick is in overlapping the scanning. In pretty much all systems, a 2x2 chunk is a 2x2 chunk and you move on to the next. A 3x3 chunk is a 3x3 chunk and you move on to the next. But there needs to be overlap. Take this: [code] ### #.# ### [/code] The first 2x2 scan looks like this: [code] ## #. [/code] Moving along the x, the next scan looks like this: [code] ## .# [/code] Add 1 to the y, reset x, and the scan looks like this: [code] #. ## [/code] And the final scan looks like this: [code] .# ## [/code] Here is a crazy bit of code that shows the basic interation: [code] for y in range(height-1): for x in range(width-1): a=thresh0255(ping.getpixel((x,y))[3])&1 b=thresh0255(ping.getpixel((x+1,y))[3])&2 c=thresh0255(ping.getpixel((x,y+1))[3])&4 d=thresh0255(ping.getpixel((x+1,y+1))[3])&8 e=(a|b|c|d) [/code] That bit of code is a bit further along than what I wanted to show, but it does illustrate that there is overlap. Instead of stepping in absolute chunks, it really does overlap. (One of these days I'll put together an animation that is far more visual than text/ascii.) Even though I can see the algorithm in my head and can code it, I don't know about the output. That is, how does Godot read resource files? Time to look into Godot's file formatting. Unfortunately, the files that I am interested in are simply "human readable" text files - no real details. Ugh. Time to reverse-engineer some files. Yeah, I'm built for this. Bring on the rabbit hole! Let's dig, understand, and manipulate!
Loading...
Options:
Enable Slimies
Enable Linkwords
« Backwards
—
Onwards »
Maximum Security
OZONE
DHTML/Javascript
Server-Side Scripting - Oh my!
CSS - DOM - XHTML - XML - XSL - XSLT
Stupid Basic HTML
Visual Therapy
Photoshop
Photoshop Pong, Anyone?
***WARNING*** BIG SIG APPROACHING
Photography
3D Modelling & Rendering
Multimedia/Animation
Print Graphics
Holding Pens
Philosophy and other Silliness
Outpatient Counseling
Site reviews!
Mad Scientists' Laboratory
Getting to know the Grail