Murga-Projects Forums
puzzle remix - Printable Version

+- Murga-Projects Forums (http://www.murga-projects.com/forum)
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: puzzle remix (/showthread.php?tid=405)


puzzle remix - mikshaw - 01-08-2011 04:17 AM

Remixed the slide puzzle into something more closely resembling a jigsaw puzzle, giving a little different gameplay, and making the code a little lighter and less complex...scrambling is less restricted, there's no swapping of images, and images don't have to be scaled to preset dimensions.

It still needs work. Some images, particularly GIFs, don't tile properly, and I had to be cautious about how scaling is done so images with prime numbers as height or width don't create a billion tiles.

The scaling especially needs work. Ideally I'd like to not scale the image at all and just scale the tiles to fit the image, but there seems to be a problem with using floating point numbers in scaling and/or tiling. So for now it scales the image only enough to fit within a grid determined by the size of the tiles. It still results in some crunchy pixels.

I'd tried cropping the image instead of scaling, by using fl_read_image, but it seems I've completely forgotten how that works.

Code:
old stuff removed


new stuff...

Code:
#!/usr/bin/env murgaLua

-- jigsaw-like puzzle for MurgaLua 0.6.4+
-- 2011 mikshaw

ts = 64 --tile size

function err(e,r)
if fltk then fltk.fl_alert(e) else print(e) end
os.exit(r)
end

if not Fl_Image.getTiles then
err("This program requires murgaLua 0.6.4 or newer.\n\n"..
    "http://www.murga-projects.com/murgaLua/index.html", 1)
end

fileName = arg[1] -- if filename given as cmdline argument
-- browse for file
fltk.fl_register_images() -- do this early so chooser can show preview
if not fileName then
fileName = fltk.fl_file_chooser("Choose an RGB image", "Image Files (*.{jpg,png,bmp,xbm,xpm,gif})", nil, nil)
end
if not fileName then
err("Please supply an image filename.\nUse: "..
    fltk.fl_filename_name(arg[0]).." \"filename\"\n"..
    "or select an image with the file chooser." , 2)
end

-- check image
img = Fl_Shared_Image.get(fileName)
if not img then err("Could not open "..fileName, 3) end
iw = img:w(); ih = img:h()

-- try to find a balance between image size and tile size
if iw % ts == 0 and ih % ts == 0 then
  tw, th = ts, ts
  cols = iw / ts
  rows = ih / ts
else
  cols = math.floor(iw / ts)
  rows = math.floor(ih / ts)
  tw = math.floor(iw / cols)
  th = math.floor(ih / rows)
  iw = cols * tw
  ih = rows * th
end

function set_tile_images()
-- take a crop of the box image
win:make_current()
imageString = fltk.fl_read_image(0, 0, iw, ih, 0)
image = fltk:Fl_RGB_Image(imageString, iw, ih, 3)

-- tile it up
imgtiles = image:getTiles(tw,th)
for i,_ in pairs(tile) do
  tile[i]:image(imgtiles[i+1])
end
box:image(image)
box:hide()
end

function scramble()
math.randomseed(os.time())
for scram = 1, 10000 do
  local a = math.random(0, rows * cols - 1)
  tile_A_x = tile[a]:x(); tile_A_y = tile[a]:y()
  local b = math.random(0, rows * cols - 1)
  tile[a]:position(tile[b]:x(), tile[b]:y())
  tile[b]:position(tile_A_x, tile_A_y)
end
end

function secondsToClock(sSeconds)
-- TJ_Tigger from http://www.indigorose.com/forums/archive/index.php/t-14669.html
local nSeconds = tonumber(sSeconds)
if nSeconds == 0 then
return "00:00:00";
else
nHours = string.format("%02.f", math.floor(nSeconds/3600));
nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60)));
nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60));
return nHours..":"..nMins..":"..nSecs
end
end

function drag_loop()
  if inplay == 1 then
    drag_box:position(Fl:event_x() - tw / 2, Fl:event_y() - th / 2)
    win:redraw()
  end
  drag_timer:doWait(.02)
end

function isitfinish()
for i = 0, rows * cols - 1 do
  if tile[i]:x() ~= pos[i].col or tile[i]:y() ~= pos[i].row then
  return end
end
for i,_ in pairs(tile) do
  tile[i]:hide()
end
preview:hide()
box:show()
if not seconds then
  seconds = os.time() - starttime
  fltk.fl_message("time: "..secondsToClock(seconds).."\n"..moves.." moves")
end
end

function move_tile(t)
if inplay == 0 then
  if not starttime then starttime = os.time()  end
  inplay = 1
  drag_box:show()
  from_t, from_x, from_y = t, t:x(), t:y()
  drag_box:image(t:image())
  t:labeltype(fltk.FL_NO_LABEL)
  t:box(fltk.FL_DOWN_BOX)
else
  inplay = 0
  from_t:labeltype(fltk.FL_NORMAL_LABEL)
  from_t:box(fltk.FL_NO_BOX)
  if from_t:x() ~= t:x() or from_t:y() ~= t:y() then
    from_t:position(t:x(),t:y())
    t:position(from_x, from_y)
    moves = moves + 1
  end
  drag_box:hide()
  win:redraw()
  isitfinish()
end
end

fs, moves, starttime, seconds = 0, 0, nil, nil
Fl:visible_focus(0)
timer = murgaLua.createFltkTimer()
timer:callback(set_tile_images)


win = fltk:Fl_Double_Window(iw,ih, fltk.fl_filename_name(fileName))

tile = {}; pos = {}
row = 0; col = 0
-- -1 is used because the number of tiles starts at 1
-- but table starts at 0 (easier to position them from zero)
for i = 0, rows * cols - 1 do
  tile[i] = fltk:Fl_Button(col,row,tw,th)
  tile[i]:box(fltk.FL_NO_BOX)
  tile[i]:align(80)
  tile[i]:callback(move_tile)
  pos[i]={col=col, row=row}
  col = col + tw
  -- start the next row
  if col == iw then col = 0; row = row + th end
end

drag_box = fltk:Fl_Box(0,0,tw,th)
drag_box:hide()
drag_timer = murgaLua.createFltkTimer()
drag_timer:callback(drag_loop)
drag_timer:do_callback()
inplay = 0

preview = fltk:Fl_Button(-10,-10,1,1)
preview:shortcut("p")
preview:callback(
function()
if box:visible() == 1 then box:hide() else box:show() end
end
)

if iw <= Fl:w() and ih <= Fl:h() then
fullscr = fltk:Fl_Button(-10,-10,1,1)
fullscr:shortcut("f")
fullscr:callback(
function()
if fs == 0 then
  fs = 1
  wx, wy = win:x(), win:y()
  win:fullscreen()
else
  fs = 0
  win:resize(wx,wy,iw,ih)
end
end
)
end

box = fltk:Fl_Box(0,0,iw,ih)
box:image(img)
win:show()
timer:doWait(1)
scramble()
Fl:run()




RE: puzzle remix - mikshaw - 01-08-2011 04:37 AM

odd...it seems using a relative file path such as "../filename.jpg" doesn't work.

Does anyone know what fl_filename_absolute (char *to, const char *from) means? Also, it returns an integer, so I dunno how that function could help?

EDIT:
Making some progress....fltk.fl_filename_absolute(fileName,fileName) apparently works to an extent, by replacing the contents of the fileName buffer with an absolute version of itself. Unfortunately, the buffer size remains static, so the filename gets truncated. Now I have to figure out how to create a new buffer...

EDIT2:
Well I don't think this is going to work, even if I figure out a better way to create a buffer rather than to make a long string. It seems fl_filename_absolute (or Fltk in general) gets confused by symlinks. So if i'm in /home/me/dir, with dir being a symlink to /home/shared/dir, and I try ../filename to reach a file in /home/me, the absolute filename becomes /home/shared/filename, which doesn't exist. That may explain why the relative path wasn't working in the first place.


RE: puzzle remix - mikshaw - 01-09-2011 04:16 AM

I got the tiling-without-scaling-the-image part sorta working. It now crops the original image to dimensions that are as close to the original as I know how to get them, rather than scaling the image and crunching the pixels. Unfortunately this only works properly for images that are no larger than the screen. It seems fl_read_image, when applied to an on-screen image, only reads what's visible onscreen (including any external windows that might be in front of it), and leaves the rest of the area black.

So I guess I do need to learn how to use fl_read_image with an off-screen buffer. This might be tricky, since fl_create_offscreen doesn't exist in murgaLua. I think I'm going to need help learning how murgaLua.createOffscreenBuffer works.


RE: puzzle remix - mikshaw - 01-09-2011 01:09 PM

A little progress. I can now use RGB images of any dimensions without having to scale them into the tile grid, so no more crunchy pixels. Unfortunately I don't know how to make it work for GIF images yet, so for now they're broken. At least I stopped it from crashing with GIFs anyway, which was a really annoying thing to figure out. Between this version and the first one I had GIFs working by scaling them into the grid, but I no longer have the brain power to put that back in as a conditional. At one point I had the GIF working again in the preview/cheat frame by scaling it, but it was getting mangled by the tiling.

Code:
broken stuff removed




RE: puzzle remix - mikshaw - 01-10-2011 05:04 AM

Weird things mess up your logic when you stay up too late pulling your hair out.

After a restful sleep I spent 5 minutes looking at this, and almost immediately found what I think is a solution. Original post is updated. Odd thing is I was sure I had already tried this same thing without success. But maybe it was different enough to break something the first time.


RE: puzzle remix - mikshaw - 01-10-2011 05:17 AM

Oh yeah...maybe i'm not as awake as I thought.

This version doesn't work either, since it tries to grab onscreen data from a window that may be partly offscreen, resulting in blank tiles (or in the present case, a segfault).

EDIT:
Everything I try seems to have at least one issue...some things break, some things cause blank tiles, some things cause the image to be skewed (that seems to be an issue with fl_draw_image when you set dimensions smaller than the original image), and some things seem to work fine for RGB images but not for indexed, such as the following:

Code:
function set_tile_images()
--[[
-- crop the image to iw,ih
win:make_current()
imageString = fltk.fl_read_image(0, 0, iw, ih)
image = fltk:Fl_RGB_Image(imageString, iw, ih, 3)
--]]

  img_data = img:data()
  collectgarbage()
--  offScreenBuffer = murgaLua.createOffscreenBuffer(img:w(), img:h())
  offScreenBuffer = murgaLua.createOffscreenBuffer(iw, ih)
  offScreenBuffer:startOffScreenDrawing()
  -- On Linux we have to clear the buffer (not on Mac or Win32)
  fltk.fl_color(0)
  -- Linux will segfault unless we set the font before using fl_draw
  fltk.fl_font(0)

  if img:count() > 2 then data = img_data else data = img_data[1] end
  fltk.fl_draw_image(data, 0, 0, img:w(), img:h(), 3)
--[[
  imageString = fltk.fl_read_image(offScreenBuffer, 0, 0, iw, ih)
  image = fltk:Fl_RGB_Image(imageString, iw, ih, 3, 0)
--]]
  image = offScreenBuffer:getOffScreenImage()
  offScreenBuffer:endOffScreenDrawing()

-- tile it up
imgtiles = image:getTiles(tw,th)
for i,_ in pairs(tile) do
  tile[i]:image(imgtiles[i+1])
end
box:image(image)
box:hide()
end


These lines are probably a good place to find the GIF problem, but I've run out of ideas:

Code:
if img:count() > 2 then data = img_data else data = img_data[1] end
  fltk.fl_draw_image(data, 0, 0, img:w(), img:h(), 3)




RE: puzzle remix - mikshaw - 01-10-2011 08:28 AM

I replaced the Fl_Image:getTiles() with a loop that draws a section of the buffer at a time, according to the coordinates I had already created when laying out the tile buttons. It still doesn't work for GIFs, but there's no pixel shift that you see from getTiles()

John...you may want to look at your tile function some day when you're not doing more important stuff. I think whatever algeryth...algorri...I think whatever is creating them is off by a pixel with each iteration (is that a murgaLua/Fltk mix, or is it a Fltk bug?). Even when using a tile size that divides evenly into height and width of the image, you end up with a pixel shift that increases with each row of tiles. I don't know C++, so I'm not sure what it's doing yet, but "verticalOffset" has me wondering.

EDIT:
Getting a weird line in the top left of some images, at the bottom of the first two tiles. It's not severe, but still means it's not as good as i'd hoped.

Code:
function set_tile_images()
  -- crop the image to iw,ih
  img_data = img:data()
  collectgarbage()
  offScreenBuffer = murgaLua.createOffscreenBuffer(iw, ih)
  offScreenBuffer:startOffScreenDrawing()
  -- On Linux we have to clear the buffer (not on Mac or Win32)
  fltk.fl_color(0)
  -- Linux will segfault unless we set the font before using fl_draw
  fltk.fl_font(0)
  if img:count() > 2 then data = img_data else data = img_data[1] end
  fltk.fl_draw_image(data, 0, 0, img:w(), img:h(), 3)
  image = offScreenBuffer:getOffScreenImage()
  -- tile it up
  for i,_ in pairs(tile) do
    fltk.fl_draw_image(pos[i].col, pos[i].row, tw, th, 3)
    tileString = fltk.fl_read_image(pos[i].col, pos[i].row, tw, th)
    tile[i]:image(fltk:Fl_RGB_Image(tileString, tw, th, 3, 0))
  end
  offScreenBuffer:endOffScreenDrawing()
  box:image(image)
  box:hide()
end




RE: puzzle remix - mikshaw - 01-11-2011 01:02 AM

After spending an hour or so on a big puzzle, I realized that a feature to save/load the current state of the puzzle would be a handy thing, so I put aside my image reading troubles for now and added that feature. It saves the position of all tiles, the amount of time that has elapsed, and the number of pieces that have been moved. Other than that, the script is the same as above.

The save file is created in os.getenv("HOME").."/.luapuzzle/" in Linux and OSX, and os.getenv("USERPROFILE").."\\.luapuzzle\\" in Windows. Each puzzle has its own save file, based on the image filename (overwrites a file with the same name). It would have been simpler, and probably quicker, to make each save file a lua script, so I could just dofile() on it, but the format it uses minimizes the file size, and removes or lessens the potential for a rogue script to get into the mix.

This script hasn't yet been tested outside my own Linux box.

EDIT Jan 11: took out an apparently redundant fl_draw_image in the tile loop. It got rid of the weird line...maybe it helped elsewhere. In any case, I'm currently working with a version that accepts only JPEG images. That's far from ideal, but I'll have to take this debugging thing slowly.

Code:
#!/usr/bin/env murgaLua

-- jigsaw-like puzzle for MurgaLua 0.6.4+
-- 2011 mikshaw

ts = 64 --tile size

function err(e,r)
if fltk then fltk.fl_alert(e) else print(e) end
os.exit(r)
end

if not Fl_Image.getTiles then
err("This program requires murgaLua 0.6.4 or newer.\n\n"..
    "http://www.murga-projects.com/murgaLua/index.html", 1)
end

fileName = arg[1] -- if filename given as cmdline argument
-- browse for file
fltk.fl_register_images() -- do this early so chooser can show preview
if not fileName then
fileName = fltk.fl_file_chooser("Choose an RGB image", "Image Files (*.{jpg,png,bmp,xbm,xpm,gif})", nil, nil)
end
if not fileName then
err("Please supply an image filename.\nUse: "..
    fltk.fl_filename_name(arg[0]).." \"filename\"\n"..
    "or select an image with the file chooser." , 2)
end

-- check image
img = Fl_Shared_Image.get(fileName)
if not img then err("Could not open "..fileName, 3) end
iw = img:w(); ih = img:h()

-- try to find a balance between image size and tile size
if iw % ts == 0 and ih % ts == 0 then
  tw, th = ts, ts
  cols = iw / ts
  rows = ih / ts
else
  cols = math.floor(iw / ts)
  rows = math.floor(ih / ts)
  tw = math.floor(iw / cols)
  th = math.floor(ih / rows)
  iw = cols * tw
  ih = rows * th
end

if murgaLua.getHostOsName() =="windows" then
  save_dir = os.getenv("USERPROFILE").."\\.luapuzzle\\"
else
  save_dir = os.getenv("HOME").."/.luapuzzle/"
end
save_file = save_dir..fltk.fl_filename_name(fileName)..".save"

function save_me()
local confirm = fltk.fl_choice("Do you want to save this puzzle?", "no", "yes", NULL)
if confirm == 1 then
  lfs.mkdir(save_dir)
  local outpoot = io.open(save_file,"w")
  if outpoot then
    pausetime = os.time() - starttime
    outpoot:write("m"..moves.."\np"..pausetime.."\n")
    for i,_ in pairs(tile) do
      outpoot:write("t"..i.." ".."x"..tile[i]:x().." ".."y"..tile[i]:y().."\n")
      --outpoot:write("tile["..i.."]:position("..tile[i]:x()..","..tile[i]:y()..")\n")
    end
    outpoot:close()
    fltk.fl_message("puzzle saved to\n"..save_file)
  else fltk.fl_message("sorry I can't write to "..save_file)
  end
end
end

function load_me()
local confirm = fltk.fl_choice("Try to retrieve saved puzzle?", "no", "yes", NULL)
if confirm == 1 then
  local test = io.open(save_file,"r")
  if test then
    test:close()
    for line in io.lines(save_file) do
      if string.find(line, "^t%d+%sx%d+%sy%d+$") then
        local t = string.gsub(line,".*t(%d+).*","%1")
        local x = string.gsub(line,".*x(%d+).*","%1")
        local y = string.gsub(line,".*y(%d+).*","%1")
        tile[tonumber(t)]:position(tonumber(x),tonumber(y))
      elseif string.find(line, "^m%d+$") then
        local m = string.gsub(line, "^m", "")
        moves = tonumber(m)
      elseif string.find(line, "^p%d+$") then
        local p = string.gsub(line, "^p", "")
        if not starttime then starttime = os.time() end
        starttime = starttime - p
      end
    end
    win:redraw()
  else fltk.fl_message("no save file available")
  end
end
end

function set_tile_images()
  -- crop the image to iw,ih
  img_data = img:data()
  collectgarbage()
  offScreenBuffer = murgaLua.createOffscreenBuffer(iw, ih)
  offScreenBuffer:startOffScreenDrawing()
  -- On Linux we have to clear the buffer (not on Mac or Win32)
  fltk.fl_color(0)
  -- Linux will segfault unless we set the font before using fl_draw
  fltk.fl_font(0)
  if img:count() > 2 then data = img_data else data = img_data[1] end
  fltk.fl_draw_image(data, 0, 0, img:w(), img:h(), 3)
  image = offScreenBuffer:getOffScreenImage()
  -- tile it up
  for i,_ in pairs(tile) do
    tileString = fltk.fl_read_image(pos[i].col, pos[i].row, tw, th)
    tile[i]:image(fltk:Fl_RGB_Image(tileString, tw, th, 3, 0))
  end
  offScreenBuffer:endOffScreenDrawing()
  please_wait:hide()
  box:image(image)
  box:hide()
save_puzzle:shortcut("s")
load_puzzle:shortcut("l")
preview:shortcut("p")
end

function scramble()
math.randomseed(os.time())
for scram = 1, 10000 do
  local a = math.random(0, rows * cols - 1)
  tile_A_x = tile[a]:x(); tile_A_y = tile[a]:y()
  local b = math.random(0, rows * cols - 1)
  tile[a]:position(tile[b]:x(), tile[b]:y())
  tile[b]:position(tile_A_x, tile_A_y)
end
end

function secondsToClock(sSeconds)
-- TJ_Tigger from http://www.indigorose.com/forums/archive/index.php/t-14669.html
local nSeconds = tonumber(sSeconds)
if nSeconds == 0 then
return "00:00:00";
else
nHours = string.format("%02.f", math.floor(nSeconds/3600));
nMins = string.format("%02.f", math.floor(nSeconds/60 - (nHours*60)));
nSecs = string.format("%02.f", math.floor(nSeconds - nHours*3600 - nMins *60));
return nHours..":"..nMins..":"..nSecs
end
end

function drag_loop()
  if inplay == 1 then
    drag_box:position(Fl:event_x() - tw / 2, Fl:event_y() - th / 2)
    win:redraw()
  end
  drag_timer:doWait(.02)
end

function isitfinish()
for i = 0, rows * cols - 1 do
  if tile[i]:x() ~= pos[i].col or tile[i]:y() ~= pos[i].row then
  return end
end
for i,_ in pairs(tile) do
  tile[i]:hide()
end
preview:hide()
box:show()
if not seconds then
  seconds = os.time() - starttime
  fltk.fl_message("time: "..secondsToClock(seconds).."\n"..moves.." moves")
end
end

function move_tile(t)
if inplay == 0 then
  if not starttime then
    starttime = os.time()
  end
  inplay = 1
  drag_box:show()
  from_t, from_x, from_y = t, t:x(), t:y()
  drag_box:image(t:image())
  t:labeltype(fltk.FL_NO_LABEL)
  t:box(fltk.FL_DOWN_BOX)
else
  inplay = 0
  from_t:labeltype(fltk.FL_NORMAL_LABEL)
  from_t:box(fltk.FL_NO_BOX)
  if from_t:x() ~= t:x() or from_t:y() ~= t:y() then
    from_t:position(t:x(),t:y())
    t:position(from_x, from_y)
    moves = moves + 1
  end
  drag_box:hide()
  win:redraw()
  isitfinish()
end
end

fs, moves, starttime, seconds = 0, 0, nil, nil
Fl:visible_focus(0)
timer = murgaLua.createFltkTimer()
timer:callback(set_tile_images)


win = fltk:Fl_Double_Window(iw,ih, fltk.fl_filename_name(fileName))

tile = {}; pos = {}
row = 0; col = 0
-- -1 is used because the number of tiles starts at 1
-- but table starts at 0 (easier to position them from zero)
for i = 0, rows * cols - 1 do
  tile[i] = fltk:Fl_Button(col,row,tw,th)
  tile[i]:box(fltk.FL_NO_BOX)
  tile[i]:align(80)
  tile[i]:callback(move_tile)
  pos[i]={col=col, row=row}
  col = col + tw
  -- start the next row
  if col == iw then col = 0; row = row + th end
end

drag_box = fltk:Fl_Box(0,0,tw,th)
drag_box:hide()
drag_timer = murgaLua.createFltkTimer()
drag_timer:callback(drag_loop)
drag_timer:do_callback()
inplay = 0

save_puzzle = fltk:Fl_Button(-10, -10, 1, 1)
save_puzzle:callback(save_me)
load_puzzle = fltk:Fl_Button(-10, -10, 1, 1)
load_puzzle:callback(load_me)
preview = fltk:Fl_Button(-10,-10,1,1)
preview:callback(
function()
if box:visible() == 1 then box:hide() else box:show() end
end
)

if iw <= Fl:w() and ih <= Fl:h() then
fullscr = fltk:Fl_Button(-10,-10,1,1)
fullscr:shortcut("f")
fullscr:callback(
function()
if fs == 0 then
  fs = 1
  wx, wy = win:x(), win:y()
  win:fullscreen()
else
  fs = 0
  win:resize(wx,wy,iw,ih)
end
end
)
end

box = fltk:Fl_Box(0,0,iw,ih)
box:image(img)
fltk.fl_define_FL_EMBOSSED_LABEL()
please_wait = fltk:Fl_Box(0,0,iw,ih, "SCRAMBLE IN PROGRESS.\nplease wait...")
please_wait:align(149)
please_wait:labeltype(4)
please_wait:labelfont(1)
please_wait:labelsize(20)
win:show()
timer:doWait(1)
scramble()
Fl:run()




RE: puzzle remix - jpjacobs - 01-11-2011 01:28 AM

well, not entirely sure of what happens, but it segfaults here after loading, and briefly displaying a png file.
A second png file ends up in some sort of rasterized, decolorized version of the original.
Loading a gif file didn't segfault the hell out of it, but resulted in a puzzle with totally scrambled images on the tiles (as in a corrupted file scrambled).
Loading a JPG works though.

Every file initially shows OK, but is damaged after scrambling, so I guess there is something seriously wrong with the tiling code or something.


RE: puzzle remix - mikshaw - 01-11-2011 05:18 AM

The initial file is the image that is loaded directly, so it makes sense that it would be okay. I'm wondering if the PNG might have an alpha channel...I haven't tested that. I've had one or two tests that resulted in the preview image (hotkey "p") displaying fine, but the tiles not. That also kinda makes sense because the tiles are created with fl_read_image and the preview is created with getOffScreenImage. If one of those is coded correctly and the other is not, one will work and the other won't.

I have been getting variations of the same problems you listed, depending on how the image reading and tiling code is done, and I still don't fully understand why some images break while similar images do not. On my system, the most recent version seems to work for every image I've tried except for GIFs. But I haven't tried any large files except for JPGs. I suppose there's a good chance that fl_read_image may be influenced by the user's windowing system. I wouldn't be surprised if even a difference in Xorg/Xfree version or configuration could have an impact.

Unfortunately the only thing that so far seems to work without these problems is scaling an image down to fit within the screen size. But that is not acceptible to me...the main reason I started this project was that the slide puzzle image size restriction was annoying me.

It won't be long before I get back to messing with the image code again, but for now I want to wear it in for a while and try to find specific types of images that are causing trouble.

Also, the save button was activated in the wrong place, making it impossible to save again after loading a saved puzzle. It's hopefully been fixed now, but I didn't notice the bug until after I'd worked on a saved puzzle for a couple of hours =op


RE: puzzle remix - iGame3D - 02-04-2011 11:51 AM

The final code listing is working nicely here on os x.