local Screen = require("screen") local redball, greenblue, blueball local redbox, greenbox, bluebox local scrn function _init() redball = image.load(_DIR .. "images/red_ball.gif")[1] greenball = image.load(_DIR .. "images/green_ball.gif")[1] blueball = image.load(_DIR .. "images/blue_ball.gif")[1] scrn = Screen:new("Let's drop some balls!", 10, 4) scrn:usepalette(redball) scrn:autocolor() image.copymode(3, true) redbox = view.new(scrn.mainvp, 16, 16, 16, 16) image.draw(redball, 0, 0, 0, 0, 16, 16) greenbox = view.new(scrn.mainvp, 16, 48, 16, 16) image.draw(greenball, 0, 0, 0, 0, 16, 16) bluebox = view.new(scrn.mainvp, 16, 80, 16, 16) image.draw(blueball, 0, 0, 0, 0, 16, 16) end function _step() scrn:step() view.active(scrn.mainvp) local mx, my, mb = input.mouse() local drop = input.drop() while drop do if drop == "red" then image.draw(redball, mx - 8, my - 8, 0, 0, 16, 16) end if drop == "green" then image.draw(greenball, mx - 8, my - 8, 0, 0, 16, 16) end if drop == "blue" then image.draw(blueball, mx - 8, my - 8, 0, 0, 16, 16) end drop = input.drop() end view.active(redbox) mx, my, mb = input.mouse() if mb == 1 then input.drag("red", redball) end view.active(greenbox) mx, my, mb = input.mouse() if mb == 1 then input.drag("green", greenball) end view.active(bluebox) mx, my, mb = input.mouse() if mb == 1 then input.drag("blue", blueball) end view.active(scrn.rootvp) if input.hotkey() == "q" then sys.exit() end end