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
Here comes some Python code. This is a mostly stripped version of my working code. Starting at the top and working down. I am using Pillow (PIL) to import the image and read values. I think I had to install it, but I don't remember. It seems to be fairly standard, though. I forgot to delete [i]import random[/i]. I could now, but whatever. Besides, it will come in handy soon. You know, when we inject some chaos into the system. You knew something like this was eventually going to happen, didn't you? Ya'll know me well. Few more bits-n-pieces and what-not. One of favorite things to hate is type-casting. It does come in handy, but I noticed a few nuanced differences between versions of Python. So I made thresh0255 far more bloated than it needs to be. [code] float(n/255.0) [/code] How can so much redundency be written in such a short statement? Yeah, not taking any chances. And then we finally come to the meaty part. The pixel maps that I'm using are PNG and have transparency. The trans- parent parts are the parts that I do not want. However, I do want the opaque parts. So, check the transparency of all 4 pixels (2x2), and if all are opaque, read from R and do the bit mask thing. I hope that the bitwise operations that I have in there make sense. These operations are why I want all #00 and #FF. These also follow the bit order that I mentioned earlier. You know, this little fellow: [code] 1 2 4 8 [/code] Finally, at the very end, is an ouput hack. I want the output to be in parenthesis because that is what Godot uses. So... tuple it. Makes it so much easier to cut-n-paste. Let's just say that I managed to make Godot's parser freak out a few times. Man, I love breaking things. [code] #!/usr/bin/env python # -*- coding: utf-8 -*- from PIL import Image import random # 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 tilepos=[196608, 196611, 131072, 131073, 0, 131075, 196610, 65539, 196609, 65536, 1, 131074, 3, 2, 65537, 65538] # for the second digit in the sequence of 3 tresindex=0 ping = Image.open('pixelmap01a.png') fo=[] # final output def thresh0255(n): # way over-the-top, but not taking any chances return int( float(n/255.0) + 0.5 ) * 255 for y in range(height-1): for x in range(width-1): # grab transparency 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) # only move forward if all 4 # pixels are opaque if e==15: # grab values from R channel m=thresh0255(ping.getpixel((x,y))[0])&1 n=thresh0255(ping.getpixel((x+1,y))[0])&2 o=thresh0255(ping.getpixel((x,y+1))[0])&4 p=thresh0255(ping.getpixel((x+1,y+1))[0])&8 inmap = (y<<16)|x intrans = 0 | tresindex # change this over later intile=tilepos[m|n|o|p] fo.extend([inmap,intrans,intile]) # output hax print(tuple(fo)) [/code] Looking over this, I almost forgot this little guy: [code] intrans = 0 | tresindex # change this over later [/code] It is redundant, but it serves as a place-holder purpose. There are 3 numbers in the *.tscn files. And I said that the second number holds more data than the *.tres file indices. Of the 32 bits, the last 4 bits hold data for something far more sinister and interesting. Here is the sequence: [code] [0, -1610612734, 1610612736, -1073741822, 536870912, -536870910, 1073741824, -2147483646] [/code] That is the chaos that exists within the constraints that I am operating under. Constraints? I haven't said much about the contraints that I am working under. Top-down graphic, but the constraint is that there is no real directional information. No isomorphic illusions or directional lighting. This means that I can transform and things will still fit. Take a corner, rotate it, and it's another corner. So, I can draw 4 corners using my lay-out, but have mucho corners with transforms. Know what I mean? Okay, I'm starting to lose focus. I need food and another nap. Unfortunately, this time oasis is almost at an end. Not sure when I will be able to finally get to the really fun stuff. Not just all of that, but I gotta completely re-build my chaos look-up table. Not an easy task because I gotta be sober to do it. Heh. Stay tuned because it will happen eventually. [small](Edited by [url=https://ozoneasylum.com/user/351]warjournal[/url] on 10-12-2020 03:46)[/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