Advertisement
Redxone

[CC - E3] BuffPixel: Two Games In One!

Jan 31st, 2017
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.44 KB | None | 0 0
  1. os.loadAPI("buffpixel")
  2. local w, h = term.getSize()
  3. term.clear()
  4. local win_width, win_height, win_x, win_y = 20,10,5,3
  5. paintutils.drawBox(win_x, win_y, win_x+win_width+1, win_y+win_height+1, colors.gray)
  6. buff = buffpixel.new(w*4,h*4,0, 0 , win_width, win_height )
  7. paintutils.drawBox(win_x+22, win_y, win_x+win_width+23, win_y+win_height+1, colors.gray)
  8. buff2 = buffpixel.new(w*4,h*4,0, 0 , win_width, win_height )
  9. local pix = buff.newPixel
  10. buff:setRenderOffset(win_x,win_y)
  11. buff2:setRenderOffset(win_x+22,win_y)
  12. local rw, rh = math.ceil(w/2), math.ceil(h/2)
  13. buff:fillMap(pix("5D","*",false))
  14. buff2:fillMap(pix("5D"," ",false))
  15. buff:setPixel(w-1,10,pix("87","@",true))
  16. buff:newPlayer("BG","&",win_width/2,win_height/2,keys.w,keys.s,keys.a,keys.d,keys.e,1)
  17. buff2:newPlayer("BG","@",win_width/2,win_height/2,keys.up,keys.down,keys.left,keys.right,keys.e,1)
  18. buff:render()
  19. buff2:render()
  20. buff:drawPlayer()
  21. buff2:drawPlayer()
  22. while true do
  23.     local e = { os.pullEvent() }
  24.    buff:getMousePlaceBlock(e,pix("87","@",true),pix("5D","*",false))
  25.    buff2:getMousePlaceBlock(e,pix("87"," ",true),pix("5D"," ",false))
  26.     buff:updatePlayer(e,0)
  27.    buff2:updatePlayer(e,0)
  28.     local px, py = buff:getPlayerPos()
  29.     local pox, poy = buff:getOutsideViews(px,py,1,1)
  30.    buff:lerpView(pox,poy,win_width/2,win_height/2,0)
  31.  
  32.    local px, py = buff2:getPlayerPos()
  33.    local pox, poy = buff2:getOutsideViews(px,py,1,1)
  34.    buff2:lerpView(pox,poy,win_width/2,win_height/2,0)
  35. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement