-- Arm on love2d function love.load() love.graphics.setDefaultFilter("nearest", "nearest") img = love.graphics.newImage("circle02_64x64_take1_05_5bit32col_edit.png") scrw = love.graphics.getWidth() scrh = love.graphics.getHeight() bx = scrw / 2 by = scrh / 2 angles = {} pos_buf = {} for i = 1, 16 do angles[i] = 0 pos_buf[i] = {bx, by} end ang = 0 a0 = 15 a1 = 30 end function love.update(dt) ang = ang + 90 * dt mx, my = love.mouse.getPosition() a0 = 45 * (mx - (scrw / 2)) / (scrw / 2) a1 = 45 * (my - (scrh / 2)) / (scrh / 2) -- angles[1] = 0 angles[1] = ang for i = 2, #angles do -- angles[i] = a1 + a1 * math.sin(math.rad(a0 * (i - 2))) angles[i] = a1 * math.sin(math.rad(ang * 0.75 + (i - 1) * a0)) end local x = pos_buf[1][1] local y = pos_buf[1][2] local a = angles[1] -- local distance = 30 local distance = 24 + 12 * math.cos(math.rad(ang * 1.4)) for i = 2, #angles do a = a + angles[i] x = x + distance * math.cos(math.rad(a)) y = y + distance * math.sin(math.rad(a)) pos_buf[i] = {x, y} end end function love.draw() -- fill window background love.graphics.clear(0.4, 0.7, 0.8, 1.0) -- draw arm local ox, oy = img:getWidth() / 2, img:getHeight() / 2 love.graphics.setColor(1.0, 1.0, 1.0, 1.0) for i = 1, #pos_buf do local px = pos_buf[i][1] local py = pos_buf[i][2] love.graphics.draw(img, px, py, 0, 1.0, 1.0, ox, oy) end love.graphics.print("a0=" .. tostring(a0), 2, 16) love.graphics.print("a1=" .. tostring(a1), 2, 32) -- draw FPS txet love.graphics.print("FPS: " .. tostring(love.timer.getFPS()), 2, 2) end function love.keypressed(key, isrepeat) if key == "escape" then -- ESC key to exit love.event.quit() end end