Quads Rotates

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
pgimeno
Party member
Posts: 3550
Joined: Sun Oct 18, 2015 2:58 pm

Re: Quads Rotates

Post by pgimeno »

I'm not sure I understand where you're having trouble, but just in case, here's a simple demo that rotates a quad of an image (at a speed that depends on the frame rate, for simplicity).

Code: Select all

-- Image: https://opengameart.org/content/rpg-sprite-sheet
local img = love.graphics.newImage('Tile Sheet.png')
local spritePosX = 0
local spritePosY = 90
local spriteWidth = 90
local spriteHeight = 90

local quad = love.graphics.newQuad(spritePosX, spritePosY, spriteWidth, spriteHeight, img:getDimensions())

local angle = 0
function love.draw()
  local mx, my = love.mouse.getPosition()
  love.graphics.draw(img, quad, mx, my, angle, 1, 1, spriteWidth*0.5, spriteHeight*0.5)
  angle = angle + 0.05
end

function love.keypressed(k) return k == "escape" and love.event.quit() end
Attachments
rotate-over-centre.love
(9.48 KiB) Downloaded 147 times
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 70 guests