Thread Rating:
  • 1 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Repurposed Sprite Editor
#6
If you're having problems implementing the save thing, I tried writing such a function for you:

Code:
function storefile()
    fn = savefiledialog("txt")
    if not typeof(fn)  return
    f = createfile(fn)
    for chary = 0 to gridsize - 1
        for charx = 0 to gridsize - 1
            select pixeli(charx * gsize + 1, chary*gsize + 1)
                case blacki  write file f, "0"
                case orangei  write file f, "1"
                case yellowi  write file f, "2"
                case bluei  write file f, "6"
                case greeni  write file f, "7"
                case whitei  write file f, "8"
                case cyani  write file f, "9"
                default
                    assert false, "Bad colour"
            endsel
        next
        wln file f
    next
    free file f
endfunc

It assumes you have also defined single number versions of the colors:

Code:
visible gridcolouri = toRGB(64, 64, 64)
visible bgridcolouri = toRGB(96, 96, 96)
visible redi = toRGB(255, 0, 0)
visible darkredi = toRGB(160, 0, 0)
visible dgreeni = toRGB(0, 128, 0)
visible bluei = toRGB(0, 0, 255)
visible greeni = toRGB(0, 255, 0)
visible yellowi = toRGB(255, 255, 0)
visible blacki = toRGB(0, 0, 0)
visible whitei = toRGB(255, 255, 255)
visible orangei = toRGB(255, 128, 0)
visible cyani = toRGB(0, 255, 255)

The toRGB function looks like this:

Code:
function toRGB(r, g, b)
    return 255*16777216 + r*65536 + g*256 + b
endfunc

Do you really need the array versions of the colors? If you use the single number versions of the colors you can use 'set colori' instead of 'set color'. When you use single numbers it's much easier to compare colors (if pixeli(x, y) = blacki ...).

The program looks great, simple to use!

I've attached the modified source code, changes are marked with Marcus.


Edit The window size was too large for my computer (mini laptop, 1366x768 pixels), but I changed to fullscreen mode, which actually downscales in this case Smile I forgot to change it back, I think ...


Attached Files
.n7   wolfEd.n7 (Size: 16.14 KB / Downloads: 4)
Reply


Messages In This Thread
Repurposed Sprite Editor - by johnno56 - 01-23-2025, 07:57 PM
RE: Repurposed Sprite Editor - by Marcus - 01-24-2025, 06:21 AM
RE: Repurposed Sprite Editor - by johnno56 - 01-24-2025, 09:13 AM
RE: Repurposed Sprite Editor - by johnno56 - 01-24-2025, 11:59 AM
RE: Repurposed Sprite Editor - by kevin - 01-24-2025, 03:49 PM
RE: Repurposed Sprite Editor - by Marcus - 01-24-2025, 05:27 PM
RE: Repurposed Sprite Editor - by johnno56 - 01-24-2025, 09:56 PM
RE: Repurposed Sprite Editor - by johnno56 - 01-25-2025, 10:14 PM
RE: Repurposed Sprite Editor - by johnno56 - 01-25-2025, 11:24 PM
RE: Repurposed Sprite Editor - by 1micha.elok - 01-26-2025, 01:22 AM
RE: Repurposed Sprite Editor - by johnno56 - 01-26-2025, 05:58 AM
RE: Repurposed Sprite Editor - by johnno56 - 01-26-2025, 10:46 AM
RE: Repurposed Sprite Editor - by 1micha.elok - 01-27-2025, 11:58 AM
RE: Repurposed Sprite Editor - by 1micha.elok - 01-27-2025, 04:23 AM

Forum Jump:


Users browsing this thread: 3 Guest(s)