Simple sprite conversion tool (Gimp, Python)
Posted: Wed Nov 01, 2023 10:47 pm
Hi,
wanted to present a small Python-script, I wrote today. Was still thinking about this sprite example. It has the sprite data right in the program (beginning from line number 3000).
So I wanted to be able to draw a sprite image in gimp, and export it to this kind of data format. Actually, into a format for Python scripts, but with a few tweaks this could be used for Commander X16 programming too, I guess (similar to the BASIC example).
My gimp version (2.10.30 on Linux) has a feature to output to "C source code": That's already close. It also can export to "HTML Table". The later I used as input for my conversion script (written in Python). So my script takes a file "file.html" (exported from the gimp) and converts it into Python code. Actually works better than expected. That's why I uploaded it. Here's the script:
https://github.com/hlubenow/converters/tree/main
This is for example the output of the medieval flag of "samples.zip" of another topic around here:
Just like that.
wanted to present a small Python-script, I wrote today. Was still thinking about this sprite example. It has the sprite data right in the program (beginning from line number 3000).
So I wanted to be able to draw a sprite image in gimp, and export it to this kind of data format. Actually, into a format for Python scripts, but with a few tweaks this could be used for Commander X16 programming too, I guess (similar to the BASIC example).
My gimp version (2.10.30 on Linux) has a feature to output to "C source code": That's already close. It also can export to "HTML Table". The later I used as input for my conversion script (written in Python). So my script takes a file "file.html" (exported from the gimp) and converts it into Python code. Actually works better than expected. That's why I uploaded it. Here's the script:
https://github.com/hlubenow/converters/tree/main
This is for example the output of the medieval flag of "samples.zip" of another topic around here:
Code: Select all
#!/usr/bin/python
spritedata = ("0000000000000000",
"0000001222200000",
"0000001222230000",
"0000001222320000",
"0000001003200000",
"0000004002222220",
"0000004002222000",
"0000001000000000",
"0000001000000000",
"0005567600000000",
"0555666770000000",
"0000565700000000")