Page 1 of 1

A couple of questions about AnAL and such

Posted: Sat Dec 17, 2011 11:52 pm
by Delibrete
Hello,

I'm currently experimenting with love, trying to build my knowledge base of the framework and the lua language and I'm using the AnAL library for animations. Here are the problems I'm facing:
  • >The robot is slightly flashing when he moves

    >You can see part of the robots knee in behind him when he walks (fig.1)
fig.1
Image

Also, how would I go about making the mouse in the center of both of the guns?

Image

Thank you.

Re: A couple of questions about AnAL and such

Posted: Sun Dec 18, 2011 5:25 am
by LiquidDandruff
hello, im new to lua and love and i too am also using the anal library. I got the same problem as you too when i first started but i sort of fixed it after a few minutes of fiddling. Go in your image editing program and sort of center your sprite and border each frame with say 2 pixels of transparency, so when anal is iterating through the frames you wont see any artifacts.

Example, your spritesheet has 4 frames and each frame is say 50 pixels wide and 80 pixels tall. Instead of having the finished sprite sheet 200 pixels by 160 pixels, space each frame by 2 pixels of transparency -> 4(50+2) = finished sprite sheet width = 208. Go to the next power of 2 if you have to. Now in your code, instead of having the width of each frame set at 50 pixels, make it 52.

I also have a bit of flashing in my animation too if i do things with love.graphics.translate(). I don't know how to fix this though.

The angle seems to be okay- it's not really noticeable, but if you want to modify it you might need to make a new angle variable and with it, calculate its dx separately - you're basing the angles of both arms with the x of one. example:

Code: Select all

        leftarmx = 64
        rightarmx = 70 --idk made it up, lets say it is :)
	xmouse = love.mouse.getX()
	ymouse = love.mouse.getY()
	
	dxleft = (leftarmx+2+4) - xmouse
        dxright = (rightarmx+2+4)-xmouse
	dy = 82+4 - ymouse
	
	angleleft = math.atan2(dxleft,-dy)
        angleright = math.atan2(dxright,-dy)
then draw it with the appropriate angles!

Re: A couple of questions about AnAL and such

Posted: Sun Dec 18, 2011 6:53 am
by Taehl
That little line thing is actually caused by all graphics hardware, as a result of filtering. Without getting all technical, all you need to do is have at least one pixel of transparency around every sprite.

Re: A couple of questions about AnAL and such

Posted: Sun Dec 18, 2011 12:59 pm
by Ellohir
Taehl wrote:That little line thing is actually caused by all graphics hardware, as a result of filtering. Without getting all technical, all you need to do is have at least one pixel of transparency around every sprite.
I was watching some weird things on my tiles while I was moving, knowing they were perfectly aligned. It's nice to know it can be that.

To check if it's a title problem I recommend ASEprite. It's a very small graphic program. Click on "Import sprite sheet" and shows two lines making the first sprite and creating a grid for the rest of the image. Move that lines and you know exactly where and how you were drawing out of a sprite :crazy:

Re: A couple of questions about AnAL and such

Posted: Mon Dec 19, 2011 1:19 am
by LiquidDandruff
LiquidDandruff wrote: I also have a bit of flashing in my animation too if i do things with love.graphics.translate(). I don't know how to fix this though.
Fix! It flickers because of floating point arithmetic, so rounding the values to closest whole number works great.

http://lua-users.org/wiki/SimpleRound

Code: Select all


function round(num, idp)
	local mult = 10^(idp or 0)
	return math.floor(num * mult + 0.5) / mult
end



	local xzoom,yzoom = round((mousetoarea.x-self.x)*zoompanfactor),((mousetoarea.y-self.y)*zoompanfactor) --rounds it to nearest whole number
	love.graphics.translate(screenWc-self.x-xzoom, screenHc-self.y-yzoom)
and also round drawing calls
actually, better fix is to just round the xs and ys at drawing call like so

Code: Select all

anim:draw(round(self.x),round(self.y), self.r, self.facing, 1, 25, 25)