Guest User

Untitled

a guest
Oct 19th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.37 KB | None | 0 0
  1. function blocks.makeDirtWallsSlink()
  2.     local leftWall = display.newImage("Art/slinko/left wall.png")
  3.     leftWall.x = leftWall.width*(0.5)
  4.     leftWall.y = leftWall.height*(-0.5)
  5.  
  6.     local rightWall = display.newImage("Art/slinko/left wall.png")
  7.     rightWall.xScale = -1
  8.     rightWall.x = stageWidth - rightWall.width*(0.5)
  9.     rightWall.y = rightWall.height*(-0.5)
  10.     physics.addBody(rightWall, "static", levelMat)
  11.  
  12.  
  13.     -- Here be hardcoded block size values. EUGH!
  14.     local CSleftWall = display.newRect(0, -50, 48, 52)
  15.     CSleftWall.isVisible = false
  16.     physics.addBody(CSleftWall, "static", levelMat)
  17.  
  18.     local CSrightWall = display.newRect(stageWidth - 48, -50, 48, 52)
  19.     CSrightWall.isVisible = false
  20.     physics.addBody(CSrightWall, "static", levelMat)
  21.  
  22.  
  23.     return {leftWall, rightWall, CSleftWall, CSrightWall}
  24. end
  25.  
  26.  
  27. function blocks.makeDirtHangSlink(length, direction)
  28.     direction = direction or "left"
  29.  
  30.    
  31.     -- This function generates dirthangs of the desired length
  32.     local dirtHangParts = {}
  33.  
  34.     -- Add the base
  35.     dirtHangParts[1] = display.newImage("Art/slinko/left wall merge.png")
  36.     dirtHangParts[1].y = -50
  37.  
  38.     -- Add the desired number of segments
  39.     for i = 1, length-1 do
  40.         dirtHangParts[#dirtHangParts+1] = display.newImage("Art/slinko/left wall tile.png")
  41.         dirtHangParts[#dirtHangParts].x = 50*i
  42.         dirtHangParts[#dirtHangParts].y = -50
  43.     end
  44.  
  45.     -- Add the end
  46.     dirtHangParts[#dirtHangParts+1] = display.newImage("Art/slinko/left wall end.png")
  47.     dirtHangParts[#dirtHangParts].x = 50*length
  48.     dirtHangParts[#dirtHangParts].y = -50
  49.  
  50.     -- CollisionShape
  51.     local CSdirtHang = display.newRect(0, -75, #dirtHangParts*50, 50)
  52.     CSdirtHang.isVisible = false
  53.  
  54.  
  55.     if (direction == "left") then
  56.         for index, block in ipairs(dirtHangParts) do
  57.             block.x = block.width*0.5 + (50*(index - 1))
  58.         end
  59.  
  60.         CSdirtHang.x = CSdirtHang.width*(0.5)
  61.     else
  62.         for index, block in ipairs(dirtHangParts) do
  63.             block.x = stageWidth - (block.width*0.5 + (50*(index - 1)))
  64.             block.xScale = -1
  65.         end
  66.  
  67.         CSdirtHang.x = stageWidth - CSdirtHang.width*(0.5)
  68.     end
  69.  
  70.     physics.addBody(CSdirtHang, "static", levelMat)
  71.  
  72.     -- Add CS to the return table
  73.     CSdirtHang = dirtHangParts[#dirtHangParts+1]
  74.  
  75.     return dirtHangParts
  76. end
Add Comment
Please, Sign In to add comment