Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | Download | RSS feed

  1. --PICTURE (part of): 2 Isometric v0.1b
  2. --by Richard Fhager
  3. --http://hem.fyristorg.com/dawnbringer/
  4. -- Email: dawnbringer@hem.utfors.se
  5. -- MSN:   annassar@hotmail.com
  6. --
  7. -- Copyright 2010 Richard Fhager
  8. --
  9. -- This program is free software; you can redistribute it and/or
  10. -- modify it under the terms of the GNU General Public License
  11. -- as published by the Free Software Foundation; version 2
  12. -- of the License. See <http://www.gnu.org/licenses/>
  13.  
  14.  
  15. -- Color 0 is assumed to be the background
  16. --
  17.  
  18. iso = {{0, 0, 1, 1, 1, 1, 0, 0},
  19.        {1, 1, 1, 1, 1, 1, 1, 1},
  20.        {2, 2, 1, 1, 1, 1, 3, 3},
  21.        {2, 2, 2, 2, 3, 3, 3, 3},
  22.        {2, 2, 2, 2, 3, 3, 3, 3},
  23.        {2, 2, 2, 2, 3, 3, 3, 3},
  24.        {0, 0, 2, 2, 3, 3, 0, 0}}
  25.  
  26. isowidth  = 8
  27. isoheight = 7
  28.  
  29. xoff = 0.5
  30. yoff = 0
  31.  
  32. xstep = 4
  33. ystep = 2
  34. zstep = 4
  35.  
  36. -- Part of screen from top-left (4 = 1/4)
  37. xsize = 5
  38. ysize = 4
  39.  
  40.  
  41. w, h = getpicturesize()
  42.  
  43. xo = math.floor(w * xoff)
  44.  
  45. -- just don't render more than can be fittted right now
  46. w = math.floor(w / xsize)
  47. h = math.floor(h / ysize)
  48.  
  49.  
  50.  
  51. for y = 0, h - 1, 1 do
  52.   for x = 0, w - 1, 1 do
  53.  
  54.     isox = x * xstep - y * xstep
  55.     isoy = y * ystep + x * ystep
  56.    
  57.     cb = getbackuppixel(x,y)
  58.  
  59.     --
  60.     if cb ~= 0 then
  61.  
  62.       r,g,b = getbackupcolor(cb);
  63.       c1 = matchcolor(r,g,b);
  64.       c2 = matchcolor(r+64, g+64, b+64);
  65.       c3 = matchcolor(r-64, g-64, b-64);
  66.      
  67.       cols = {0,c1,c2,c3}
  68.  
  69.       for iy = 1, isoheight, 1 do
  70.        for ix = 1, isowidth, 1 do
  71.  
  72.          i = iso[iy][ix]
  73.          c = cols[i+1]  
  74.          if i ~= 0 then putpicturepixel(xo + isox+ix-1, isoy+iy-1, c); end
  75.          
  76.        end
  77.       end
  78.  
  79.     end
  80.     --
  81.  
  82.   end
  83. end
  84.  
  85.  
  86.  
  87.  
  88.