Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function love.load()
- b1 = {}
- b2 = {}
- b3 = {}
- b4 = {}
- b5 = {}
- b6 = {}
- col = {}
- well = false
- f = 0
- mouse = false
- b1.type = "button"
- b1.sx = 100
- b1.sy = 50
- b1.oncr = 255
- b1.oncg = 255
- b1.oncb = 255
- b1.ofcr = 180
- b1.ofcg = 180
- b1.ofcb = 180
- b1.posx = 100
- b1.posy = 100
- b1.funct = b1s
- b1.text = "On"
- b2.type = "button"
- b2.sx = 100
- b2.sy = 50
- b2.oncr = 255
- b2.oncg = 255
- b2.oncb = 255
- b2.ofcr = 180
- b2.ofcg = 180
- b2.ofcb = 180
- b2.posx = 100
- b2.posy = 200
- b2.funct = b2s
- b2.text = "Off"
- b3.type = "button"
- b3.sx = 50
- b3.sy = 50
- b3.oncr = 255
- b3.oncg = 0
- b3.oncb = 0
- b3.ofcr = 180
- b3.ofcg = 180
- b3.ofcb = 180
- b3.posx = 200
- b3.posy = 150
- b3.funct = quit
- b3.text = "Quit"
- b4.type = "slider"
- b4.barr = 255
- b4.barg = 0
- b4.barb = 0
- b4.sliderr = 180
- b4.sliderg = 180
- b4.sliderb = 180
- b4.posx = 1
- b4.posy = 300
- b4.value = 63
- b4.max = 63
- b4.ind = "r"
- b5.type = "slider"
- b5.barr = 0
- b5.barg = 255
- b5.barb = 0
- b5.sliderr = 180
- b5.sliderg = 180
- b5.sliderb = 180
- b5.posx = 1
- b5.posy = 340
- b5.value = 63
- b5.max = 63
- b5.ind = "g"
- b6.type = "slider"
- b6.barr = 0
- b6.barg = 0
- b6.barb = 255
- b6.sliderr = 180
- b6.sliderg = 180
- b6.sliderb = 180
- b6.posx = 1
- b6.posy = 380
- b6.value = 63
- b6.max = 63
- b6.ind = "b"
- buttons = {b1,b2,b3,b4,b5,b6}
- end
- function b1s()
- mouse = true
- love.mouse.setVisible(false)
- mr = math.random(0,255)
- mg = math.random(0,255)
- mb = math.random(0,255)
- end
- function b2s()
- mouse = false
- love.mouse.setVisible(true)
- end
- function quit()
- love.event.push("quit")
- end
- function love.draw()
- mx,my = love.mouse.getPosition()
- f = 0
- for i = 1,#buttons do
- if buttons[i].type == "button" then
- if mx > buttons[i].posx and mx < buttons[i].sx + buttons[i].posx and my > buttons[i].posy and my < buttons[i].sy + buttons[i].posy then
- love.graphics.setColor(buttons[i].oncr,buttons[i].oncg,buttons[i].oncb)
- love.graphics.rectangle("fill",buttons[i].posx,buttons[i].posy,buttons[i].sx,buttons[i].sy)
- love.graphics.setColor(0,0,0)
- love.graphics.print(buttons[i].text,buttons[i].posx,buttons[i].posy)
- else
- love.graphics.setColor(buttons[i].ofcr,buttons[i].ofcg,buttons[i].ofcb)
- love.graphics.rectangle("fill",buttons[i].posx,buttons[i].posy,buttons[i].sx,buttons[i].sy)
- end
- end
- if buttons[i].type == "slider" then
- if love.mouse.isDown("l") and mx >= buttons[i].posx and mx <= buttons[i].posx + buttons[i].max * 10 and my >= buttons[i].posy and my <= buttons[i].posy + 10 then
- love.graphics.setColor(buttons[i].sliderr,buttons[i].sliderg,buttons[i].sliderb)
- love.graphics.rectangle("fill",buttons[i].posx,buttons[i].posy + 4,buttons[i].max * 10,2)
- love.graphics.setColor(buttons[i].barr,buttons[i].barg,buttons[i].barb)
- love.graphics.rectangle("fill",mx,buttons[i].posy,2,10)
- buttons[i].value = (mx - buttons[i].posx) / 10
- else
- love.graphics.setColor(buttons[i].sliderr,buttons[i].sliderg,buttons[i].sliderb)
- love.graphics.rectangle("fill",buttons[i].posx,buttons[i].posy + 4,buttons[i].max * 10,2)
- love.graphics.setColor(buttons[i].barr,buttons[i].barg,buttons[i].barb)
- love.graphics.rectangle("fill",buttons[i].posx + buttons[i].value * 10,buttons[i].posy,2,10)
- end
- love.graphics.setColor(255,255,255)
- love.graphics.print(buttons[i].value,buttons[i].posx + buttons[i].max * 10 / 2,buttons[i].posy + 15)
- col[buttons[i].ind] = buttons[i].value
- well = true
- end
- end
- if mouse == true then
- love.graphics.setColor(mr,mg,mb)
- love.graphics.circle("fill",mx,my,3)
- end
- love.graphics.setColor(col["r"] * 4,col["g"] * 4,col["b"] * 4)
- love.graphics.rectangle("fill",300,100,10,10)
- end
- function love.update()
- if well == true then
- b4.sliderr = col["r"] * 4
- b4.sliderg = col["g"] * 4
- b4.sliderb = col["b"] * 4
- b5.sliderr = col["r"] * 4
- b5.sliderg = col["g"] * 4
- b5.sliderb = col["b"] * 4
- b6.sliderr = col["r"] * 4
- b6.sliderg = col["g"] * 4
- b6.sliderb = col["b"] * 4
- end
- end
- function love.mousepressed(x,y,button)
- mx = x
- my = y
- for i = 1,#buttons do
- if buttons[i].type == "button" then
- if mx > buttons[i].posx and mx < buttons[i].sx + buttons[i].posx and my > buttons[i].posy and my < buttons[i].sy + buttons[i].posy and button == "l" then
- buttons[i].funct()
- end
- end
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment