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
Things are going to get a tricky with the representations. Oh, my love for graph paper and ascii art. I adore low-tech. While I do want to eventually do all of this with graphics and animations, I have absolutely no desire to secure some space. Plus my current time constraints. Just gonna work with what I got. So, the actual tile map graphic. My tiles are 64x64. Using 2x2 bitmasking, so 4x4 tiles. My actual graphic will be 256x256 with a total of 16 tiles. The lay-out that I am using is in one of the links above. It's a good lay-out with some interesting properties(!). Using a certain kind of notation, it looks like this: [code] ###..### .##..... .##..... #......# #......# #####..# #####..# ###..### [/code] Period is walkable and pound sign (or hashtag for those late to the party) is non-walkable. (I really wish I could find those particular symbols for map-making again. It was something like ascii for RPG maps or something. From what little I can recall, it's a standard amoung the people that make such games.) And my favorite using X and ., but with a little extra spacing: [code] X X X . . X X X . X X . . . . . . X X . . . . . X . . . . . . X X . . . . . . X X X X X X . . X X X X X X . . X X X X . . X X X [/code] Another look using 1=true=walkable=yes, and 0=NO! [code] 00011000 10011111 10011111 01111110 01111110 00000110 00000110 00011000 [/code] Since my tiles are 64x64 and I'm using bitmask 2x2, each one of those symbols is 32x32. Time for some base(2). This is my bit order: [code] 1 2 4 8 [/code] The first time I did this, I used a different bit order. But I decided to switch because this is kind of how Godot does it. Kind of. Okay, let's fill it in: [code] . . . 2 1 . . . 4 . . 8 4 8 4 8 1 . . 2 1 2 1 2 . 8 4 8 4 8 4 . . 2 1 2 1 2 1 . . . . . . 8 4 . . . . . . 2 1 . . . . 8 4 . . . [/code] How about this: [code] +--+--+--+--+ |..|.2|1.|..| |4.|.8|48|48| +--+--+--+--+ |1.|.2|12|12| |.8|48|48|4.| +--+--+--+--+ |.2|12|12|1.| |..|..|.8|4.| +--+--+--+--+ |..|..|.2|1.| |..|.8|4.|..| +--+--+--+--+ [/code] Heh. Man, editing ascii to this extent is definitely interesting. Now let's add it all up and get our index array: [code] 4 10 13 12 9 14 15 7 2 3 11 5 0 8 6 1 [/code] If everything went well, should have 0-15, and it looks like we do. So why do this? Because we need to know the positions in the tile map for the bit indices. Hopping over to Python and plugging that in we do this: [code] #!/usr/bin/env python # -*- coding: utf-8 -*- tind=[[ 4, 10, 13, 12], [ 9, 14, 15, 7], [ 2, 3, 11, 5], [ 0, 8, 6, 1]] tpos=[] for col in range(4): for row in range(4): a=tind[row][col] b=(row<<16)|col tpos.append([a,b]) tpos.sort() for i in tpos: print (i) [/code] And the output should look something like this: [code] [0, 196608] [1, 196611] [2, 131072] [3, 131073] [4, 0] [5, 131075] [6, 196610] [7, 65539] [8, 196609] [9, 65536] [10, 1] [11, 131074] [12, 3] [13, 2] [14, 65537] [15, 65538] [/code] What exactly does that give us? When we scan the pixel map for #00 and #FF, that will give us the position of the tile in the tile map. For example, 0 is: [code] 196608 = 0000 0000 0000 0011 0000 0000 0000 0000 = (0,3) [/code] And 1 is: [code] 196611 = 0000 0000 0000 0011 0000 0000 0000 0011 = (3,3) [/code] And so on. Switching back and forth between Screen(X,Y) and Python[Row][Col] can throw me for a loop sometimes. To me it's all the same, especially after having worked with latin squares and orthos for so long. But it looks like I got it right. Now, when we scan the pixel map, we know which tile it is in the tile map. All we need is this from the above: [code] tilepos=[ 196608, 196611, 131072, 131073, 0, 131075, 196610, 65539, 196609, 65536, 1, 131074, 3, 2, 65537, 65538] [/code] Knowing where we are when generating the map itself is easy because it is a part of the interation during scanning. Tile pos is a little trickier, but there is all is. OMG I've been on a rampage. All of this stuff has been sitting in me for several months because of RL. It feels good to start getting most of it out. And I still have yet to get to the fun part: Chaos! Of course I have to introduce chaos into the system. But it is under certain constrains that fit my current needs. I'm gonna take a break and nap for a bit. When I get up, hopefully I'll have the strength to strip some code for ya'll to look at. I'm a bit toasty on cinnamon whiskey right now. Toasty and I can still write like a beast. nerd_rampage_mode = ON [small](Edited by [url=https://ozoneasylum.com/user/351]warjournal[/url] on 10-11-2020 17:27)[/small]
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