Image problems

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.
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Image problems

Post by pgimeno »

Well, that's not too easy. I suggest you take a look at a skeletal animation library, like this one: https://love2d.org/forums/viewtopic.php?f=5&t=79607
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: Image problems

Post by Gunroar:Cannon() »

Oh, I checked and yours worked perfect but I need a way to do it without adding the origin (7th and 8th) arguments to draw for body/image2.

Also, I only need minimal stuff. So really it's not that skeletal of an animation.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Image problems

Post by pgimeno »

Then draw the hands by calculating the hook point manually.

Code: Select all

local body = love.graphics.newImage('0.png')
local hands = love.graphics.newImage('hands.png')
local nose = love.graphics.newImage('moleMask.png')

local a
love.mouse.setPosition(0, 0)
love.mouse.setPosition(400, 300)

function love.update(dt)
  local mx, my = love.mouse.getPosition()
  a = math.atan2(my - (100+body:getHeight()/2), mx - (100+body:getWidth()/2))
end

function love.draw()
  local bright = 0.8
  love.graphics.setColor(1*bright, 0.5*bright, 0.25*bright)

  love.graphics.draw(body, 100, 100,  0, 1, 1,  0, 0)
  love.graphics.setBlendMode("alpha", "premultiplied")
  love.graphics.draw(nose, 100-160/2, 100-256/2, 0, 1, 1, 0, 0)

  -- Add the centre of the body image to the hands
  love.graphics.draw(hands, 100+body:getWidth()/2, 100+body:getHeight()/2,
    a, 1, 1, hands:getWidth()/2, hands:getHeight()/2)

  love.graphics.setBlendMode("alpha", "alphamultiply")

  love.graphics.setColor(1, 1, 1)
end

function love.keypressed(k) return k == "escape" and love.event.quit() end
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: Image problems

Post by Gunroar:Cannon() »

Thanks!

Also
Anything bad with "easy method". Does it reduce quality or slow down game?
??

Just wondering why you use "bright" at the beginning of love.draw?
edit: oh, dumb me, that's to make it brown.

Also wondering whether you think the images together ressembles some kind of mole :?
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
pgimeno
Party member
Posts: 3548
Joined: Sun Oct 18, 2015 2:58 pm

Re: Image problems

Post by pgimeno »

The nearest filter makes the rendering pixellated. For some that's a desirable property; it depends on your game. Generally I don't give artistic advice, so I can't tell whether it looks good or not in your case; try nearest and premultiplied alpha and see which one you like best. For the same reason I defer the second question to someone else.
User avatar
Gunroar:Cannon()
Party member
Posts: 1088
Joined: Thu Dec 10, 2020 1:57 am

Re: Image problems

Post by Gunroar:Cannon() »

Hmmm...okay. I see :)

Thanks! The thing works, though I just need to scale multiply the added width/height by the scale (if it's not 1).

Code: Select all


    local source = game:getAsset(self.source)
    
    vw = source:getWidth()/2
    vh = source:getHeight()/2
    
    local vww = self.parent.spriteImage:getWidth()/2 *self._w
    local vhh = self.parent.spriteImage:getHeight()/2 *self._h
    
    love.graphics.draw(source,self.x+vhh,self.y+vww,(angle or 0),self._w*flX,self._h,vw,vh)

The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
Post Reply

Who is online

Users browsing this forum: Majestic-12 [Bot] and 91 guests