another neophyte having animation issues
Posted: Sun Jul 08, 2012 11:38 pm
greetings, LOVE community. i have just started to use this framework about 4 days ago and i must say it's absolutely splendid so far. now, i hate to be asking for things right off the bat without contributing through one way or another but i have been rewriting the drawing code for this particular project a lot and none of the methods i've tried so far seems to work. i do have the current system that i will explain below the following code block, though.
mario's image file located in the root of the program:
so i just stored all of mario's graphics information in a table and made the program draw the first frame which is located on the far left of the sheet. in the keypress function, i tried to make it so that the quad's drawing coordinates would switch to his second image by pressing on the right arrow key, however, it doesn't seem to cycle through any of the images at all even though the program is telling me that "objects.mario.quadStartX" is in fact being manipulated. the line "if not (objects.mario.quadStartX > (objects.mario.graphicsWidth - objects.mario.quadWidth * 2)) then" tells the program to switch to the first frame again after the quad's top-right coordinates is larger than a certain point (64,0).
can anyone tell me what i'm doing wrong? i would also prefer to use my own animation system rather than using a library such as AnAL simply because i think it'll help me get more familiar with the language.
thanks everyone.
Code: Select all
function love.load()
screen = {};
screen.width = 640;
screen.height = 480;
love.graphics.setMode(screen.width, screen.height, false, false, 0);
music = {};
--music.source = love.audio.newSource("14Confrontation.mp3");
--love.audio.play(music.source);
objects = {};
objects.mario = {};
objects.mario.graphics = love.graphics.newImage("mario.png");
objects.mario.graphicsWidth = objects.mario.graphics:getWidth(objects.mario.graphics);
objects.mario.graphicsHeight = objects.mario.graphics:getHeight(objects.mario.graphics);
objects.mario.quadStartX = 0;
objects.mario.quadStartY = 0;
objects.mario.quadWidth = 32;
objects.mario.quadHeight = 64;
objects.mario.originX = objects.mario.quadWidth / 2;
objects.mario.originY = objects.mario.quadHeight / 2;
objects.mario.quad = love.graphics.newQuad(objects.mario.quadStartX, objects.mario.quadStartY,
objects.mario.quadWidth, objects.mario.graphicsHeight, 96, 64);
end
function love.update(dt)
--PLACE HOLDER
end
function love.keypressed(key)
if key == "right" then
if not (objects.mario.quadStartX > (objects.mario.graphicsWidth - objects.mario.quadWidth * 2)) then
objects.mario.quadStartX = objects.mario.quadStartX + objects.mario.quadWidth;
else
objects.mario.quadStartX = 0;
end
end
end
function love.draw()
love.graphics.drawq(objects.mario.graphics, objects.mario.quad, (screen.width / 2), (screen.height / 2),
0, 1, 1, objects.mario.originX, objects.mario.originY, 0, 0);
love.graphics.print(objects.mario.graphicsWidth,0,0);
love.graphics.print(objects.mario.quadStartX,0,14);
end
can anyone tell me what i'm doing wrong? i would also prefer to use my own animation system rather than using a library such as AnAL simply because i think it'll help me get more familiar with the language.
thanks everyone.