-- love2d bit operation test bit = require("bit") function love.load() tm = 0 v = 0 end function love.update(dt) tm = tm + dt local st = 0.2 if tm >= st then tm = tm - st v = bit.band(v + 1, 0x0f) end end function love.draw() love.graphics.clear(0, 0.25, 0.5, 1.0) local s = "" for i=0,3 do local msk = bit.lshift(1, i) if bit.band(v, msk) == 0 then s = "0"..s else s = "1"..s end end love.graphics.print(s, 10, 40) end function love.keypressed(key, isrepeat) if key == "escape" then -- ESC to exit love.event.quit() end end