home *** CD-ROM | disk | FTP | other *** search
/ GameStar Special 2004 August / GSSH0804.iso / Geschicklichkeit / Enigma / Enigma-081.exe / data / levels / ralf02.lua < prev    next >
Text File  |  2003-03-21  |  5KB  |  194 lines

  1. -- A level for Enigma
  2. -- Name:     Ibiza!
  3. -- Filename:     ralf02.lua
  4. -- Copyright:     (c) Feb 2003 Ralf Westram
  5. -- Contact:     amgine@reallysoft.de
  6. -- License:     GPL v2.0 or above
  7.  
  8. randomseed(enigma.GetTicks())
  9.  
  10. floortile1 = "fl-space"
  11. floortile2 = "fl-metal"
  12. floortile3 = "fl-gradient"
  13. floortile4 = "fl-inverse"
  14.  
  15.  
  16. walltile   = "st-rock5"
  17. walltile2  = "st-glass"
  18.  
  19. xw = 5
  20. yw = 5
  21.  
  22. levelw = (xw*6)+3
  23. levelh = (yw*6)+2
  24. tiles = (xw*yw+1)/2
  25.  
  26.                        mask = "1001100101010"
  27. if random(1,3)==1 then mask = "0101010100101" end
  28. if random(1,3)==1 then mask = "0101010100110" end
  29. if random(1,3)==1 then mask = "0100101010101" end
  30.  
  31. create_world(levelw,levelh)
  32.  
  33. fill_floor("fl-water")
  34. draw_border(walltile)
  35.  
  36. display.SetFollowMode(display.FOLLOW_SCROLLING)
  37.  
  38. ftilew = 10
  39. ftileh = 12
  40. stilew = 5
  41. stileh = 6
  42. floorw = (ftilew+2)*2
  43. floorh = 4*ftileh
  44. stonew = (stilew+1)*2
  45. stoneh = 4*stileh
  46.  
  47. function set_floor_repeated(ftile,x,y)
  48.     local ly = y
  49.     while (ly < levelh) do
  50.         local lx = x
  51.         while (lx < levelw) do
  52.             if lx >= 0 and ly >= 0 then
  53.                 if ftile == "fl-gradient" then
  54.                     set_floor(ftile,lx,ly,{type=random(1,8)})
  55.                 else
  56.                     set_floor(ftile,lx,ly)
  57.                 end
  58.             end
  59.             lx = lx + floorw
  60.         end
  61.         ly = ly + floorh
  62.     end
  63. end
  64. function set_stone_repeated(stile,x,y)
  65.     local ly = y
  66.     while (ly < (levelh-1)) do
  67.         local lx = x
  68.         while (lx < (levelw-1)) do
  69.             if lx > 0 and ly > 0 then
  70.                 set_stone(stile,lx,ly)
  71.             end
  72.             lx = lx + stonew
  73.         end
  74.         ly = ly + stoneh
  75.     end
  76. end
  77.  
  78. function fill_floor_repeated(ftile,x1,y1,x2,y2)
  79.     for x=x1, x2 do
  80.         for y=y1, y2 do
  81.             set_floor_repeated(ftile,x,y)
  82.         end
  83.     end
  84. end
  85. function fill_stone_repeated(stile,x1,y1,x2,y2)
  86.     for x=x1, x2 do
  87.         for y=y1, y2 do
  88.             set_stone_repeated(stile,x,y)
  89.         end
  90.     end
  91. end
  92.  
  93. function draw_floor_tile(ftile,x,y,xt,yt)
  94.     set_floor_repeated(ftile,x+xt,           y+yt)
  95.     set_floor_repeated(ftile,x+(ftilew-xt-1),y+yt)
  96.     set_floor_repeated(ftile,x+(ftilew-xt-1),y+(ftileh-yt-1))
  97.     set_floor_repeated(ftile,x+xt,           y+(ftileh-yt-1))
  98. end
  99. function draw_floor_tiles(ftile,x,y,xt1,yt1,xt2,yt2)
  100.     for xt=xt1, xt2 do
  101.         for yt=yt1, yt2 do
  102.             draw_floor_tile(ftile,x,y,xt,yt)
  103.         end
  104.     end
  105. end
  106.  
  107. function draw_stone_tile(stile,x,y,xt,yt)
  108.     set_stone_repeated(stile,x+xt,           y+yt)
  109.     set_stone_repeated(stile,x+(stilew-xt-1),y+yt)
  110.     set_stone_repeated(stile,x+(stilew-xt-1),y+(stileh-yt-1))
  111.     set_stone_repeated(stile,x+xt,           y+(stileh-yt-1))
  112. end
  113.  
  114. count = 0
  115.  
  116. function draw_oxyd_tile(x,y,xt,yt)
  117.     draw_stone_tile("st-fakeoxyd",x,y,xt,yt)
  118.     count = count+1
  119.     if (strsub(mask,count,count)=="1") then
  120.         local d = random(1,4)
  121.         if     (d == 1) then oxyd(x+xt,y+yt)
  122.         elseif (d == 2) then oxyd(x+(stilew-xt-1),y+yt)
  123.         elseif (d == 3) then oxyd(x+(stilew-xt-1),y+(stileh-yt-1))
  124.         elseif (d == 4) then oxyd(x+xt,           y+(stileh-yt-1))
  125.         end
  126.     end
  127. end
  128. function draw_oxyd_tile_repeated(x,y,xt,yt)
  129.     local ly = y
  130.     while (ly < (levelh-1)) do
  131.         local lx = x
  132.         while (lx < (levelw-1)) do
  133.             if lx > 0 and ly > 0 then
  134.                 draw_oxyd_tile(lx,ly,xt,yt)
  135.             end
  136.             lx = lx + stonew
  137.         end
  138.         ly = ly + stoneh
  139.     end
  140. end
  141.  
  142. -- grobes Muster
  143. function draw_floor_i(ftile,x,y)
  144.     draw_floor_tiles(ftile,x,y,0,0,1,3)
  145.     draw_floor_tiles(ftile,x,y,2,0,3,1)
  146.     fill_floor_repeated(ftile,x+ftilew/2-1,y,x+ftilew/2,y+ftileh-1)
  147. end
  148.  
  149. -- feines Muster
  150. function draw_floor_i_fein(ftile,x,y)
  151.     draw_floor_tile(ftile,x,y,0,0)
  152.     draw_floor_tile(ftile,x,y,0,1)
  153.     draw_floor_tile(ftile,x,y,1,0)
  154.     fill_floor_repeated(ftile,x+ftilew/2,y,x+ftilew/2,y+ftileh-1)
  155. end
  156.  
  157. function draw_stone_i(stile,x,y)
  158.     draw_stone_tile(stile,x,y,0,0)
  159.     draw_stone_tile(stile,x,y,0,1)
  160.     draw_stone_tile(stile,x,y,1,0)
  161.     draw_oxyd_tile_repeated(x,y,1,1)
  162.     fill_stone_repeated(stile,x+2,y,x+2,y+5)
  163. end
  164.  
  165. function draw_floor_column(ftile1,ftile2,ftile3,ftile4,x,y)
  166.     draw_floor_i(ftile1,x, y)
  167.     draw_floor_i(ftile2,x, y+ftileh)
  168.     draw_floor_i(ftile3,x, y+ftileh*2)
  169.     draw_floor_i(ftile4,x, y+ftileh*3)
  170. end
  171.  
  172. -- starting positions of floor
  173. x1 = -3
  174. x2 = x1+(floorw/4)
  175. y1 = -4
  176. y2 = y1-(ftileh/2)
  177.  
  178. draw_floor_column(floortile1,floortile2,floortile3,floortile4,x1,y1)
  179. draw_floor_column(floortile2,floortile3,floortile4,floortile1,x2,y2)
  180. draw_floor_column(floortile1,floortile2,floortile3,floortile4,x1+floorw/2,y1)
  181. draw_floor_column(floortile3,floortile4,floortile1,floortile2,x2+floorw/2,y2)
  182.  
  183. x3 = 2
  184. y3 = 1
  185.  
  186. draw_stone_i(walltile2,x3,         y3)
  187. draw_stone_i(walltile2,x3,         y3+stoneh/2)
  188. draw_stone_i(walltile2,x3+stonew/2,y3+stoneh/4)
  189. draw_stone_i(walltile2,x3+stonew/2,y3-stoneh/4)
  190.  
  191. oxyd_shuffle()
  192. set_actor("ac-blackball", levelw/2+6, levelh/2+0.5, {player=0})
  193.  
  194.