animation starts too fast with AnAL

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
Fatmat927
Prole
Posts: 42
Joined: Wed Sep 18, 2013 1:15 am

animation starts too fast with AnAL

Post by Fatmat927 »

okay so I'm trying to put a fighting animation that plays only once when you change gamestate (I'm making a text adventure game) but it starts too fast so when i get to it it's not at the starts, I'm using AnAL.
here's the code
sorry some of my titles are in french :/

Code: Select all

--require le fichier pour faire des animations
require("AnAL")
--mettre un gamestate initial ce qui me permettras de le changer plus tard
local gamestate = "intro"

function love.load()
	--distance x et y de la fenetre du jeu(avoir la distance et non la setter)
	WindowWidth = love.graphics.getWidth()
	WindowHeight = love.graphics.getHeight()
	--images pour les tilesets (animations)
	blacktoredfadeimage = love.graphics.newImage("blacktoredfadeanimation.png")
	explosionimage = love.graphics.newImage("explosion.png")
	satanicfortfightimage = love.graphics.newImage("satanicfortfightwarrior.png")
	--create the animations with AnAL
	blacktoredfadeanimation = newAnimation(blacktoredfadeimage, 800, 600, 0.1, 0)
	explosionanimation = newAnimation(explosionimage, 100, 100, 0.1, 0)
	explosionanimation2 = newAnimation(explosionimage, 100, 100, 0.1222, 0)
	satanicfortfightanimation = newAnimation(satanicfortfightimage, 800, 600, 4, 0)
	--determiner le mode pour les animation (loop is default)
	satanicfortfightanimation:setMode("once")
	--images pour tout le jeu
	darktree = love.graphics.newImage("dark tree.png")
	stars = love.graphics.newImage("stars.png")
	mage = love.graphics.newImage("mage.png")
	warrior = love.graphics.newImage("warrior.png")
	cactus = love.graphics.newImage("cactus.png")
	johnmarston = love.graphics.newImage("transparent john marston.png")
	pinguin = love.graphics.newImage("pinguin.png")
	jungletree = love.graphics.newImage("jungle tree.png")
	sharkeatingwarrior = love.graphics.newImage("shark eating warrior.png")
	Fire1 = love.graphics.newImage("Fire1.png")
	Fire2 = love.graphics.newImage("Fire2.png")
	Fire3 = love.graphics.newImage("Fire3.png")
	satanicdoor = love.graphics.newImage("satanic door.png")
	sataniccultist = love.graphics.newImage("soldier.png")
	--les fonts qui seront utiliser lors du jeu
	font12 = love.graphics.setNewFont(12)
	font30 = love.graphics.setNewFont(30)
	font50 = love.graphics.setNewFont(50)
	font13 = love.graphics.setNewFont(13)
	font19 = love.graphics.setNewFont(19)
	font11 = love.graphics.setNewFont(11)
end

function drawintro()
	--couleur de font pour le gamestate intro
	love.graphics.setBackgroundColor(0, 50, 0)
	--dessins qui s'affichent au tout debut du jeu
	love.graphics.setColor(0, 0, 70)
	love.graphics.rectangle("fill", 0, 0, WindowWidth, WindowHeight / 4)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(stars , 0, 0, 0, 1, 0.75, 0, 0)
	love.graphics.draw(darktree, WindowWidth / 2 - 300, WindowHeight / 2 - 200, 0, 1, 1, 0, 0)
	love.graphics.draw(darktree, WindowWidth / 2 + 150, WindowHeight / 2 - 300, 0, 1, 1, 0, 0)
	love.graphics.draw(darktree, WindowWidth / 2 + 100, WindowHeight / 2 - 100, 0, 1, 1, 0, 0)
	love.graphics.setFont(font12)
	love.graphics.print("Welcome to the world of Dahamar, you now have to choose your path. Move with the arrows keys.", 100, 200, 0, 1, 1, 0, 0)
	love.graphics.setColor(255, 10, 10)
	love.graphics.setFont(font30)
	love.graphics.print("WARRIOR", 350, 30, 0, 1, 1, 0, 0)
	love.graphics.setColor(10, 10, 255)
	love.graphics.print("MAGE", 30 , 300, 0, 1, 1, 0, 0)
	love.graphics.setColor(255, 255, 255)
	love.graphics.print("THIEF/ASSASSIN", 540, 300, 0, 1, 1, 0, 0)
end

function drawwarrior1()
	--dessins qui s'affichent dès que l'on choisi le perso warrior
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(warrior, WindowWidth / 2 - 75, WindowHeight / 2 - 110, 0, 2, 2, 0, 0)
	love.graphics.setFont(font50)
	love.graphics.setColor(rr, br, gr)
	love.graphics.print("this is yo face man yo ugly", WindowWidth / 2 - 350, WindowHeight / 2 - 200, 0, 1, 1, 0, 0)
	love.graphics.setColor(255, 255, 255)
	love.graphics.setFont(font13)
	love.graphics.print("Now decide wether you want to go north, east or west and no you cant go south. Deal with it", 10, WindowHeight / 2 + 200, 0, 1, 1, 0, 0)
	love.graphics.print("N for North, W for West, E for East come on faster!!!", 60, WindowHeight / 2 + 250, 0, 1, 1, 0, 0)
end	

function drawwarriornorth1()
	--dessins qui s'affichent dès que l'on choisi le perso warrior puis que l'on va au nort
	love.graphics.setBackgroundColor(183, 240, 240)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(pinguin, WindowWidth / 2 - 200, WindowHeight / 2 - 250, 0, 1, 1, 0, 0)
	love.graphics.draw(pinguin, WindowWidth / 2, WindowHeight / 2 + 175, 0, 1, 1, 0, 0)
	love.graphics.draw(pinguin, WindowWidth / 2 - 250, WindowHeight / 2 + 100 - 50, 0, 1, 1, 0, 0)
	love.graphics.draw(pinguin, WindowWidth / 2 + 100, WindowHeight / 2 - 150, 0, 1, 1, 0, 0)
	love.graphics.draw(pinguin, WindowWidth / 2 + 250, WindowHeight / 2 - 300, 0, 1, 1, 0, 0)
	love.graphics.setColor(0, 0, 0)
	love.graphics.setFont(font19)
	love.graphics.print("congratulations idiot! you went to the artic and froze to death you dumbass!!!", 40, WindowHeight / 2, 0, 1, 1, 0, 0)
end

function drawwarriorwest1()
	--dessins qui s'affichent dès que l'on choisi le warrior et que l'on va a l'ouest
	love.graphics.setBackgroundColor(250, 248, 154)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(cactus, WindowWidth / 2 - 300, WindowHeight / 2 - 200, 0, 1, 1, 0, 0)
	love.graphics.draw(cactus, WindowWidth / 2, WindowHeight / 2 - 300, 0, 1, 1, 0, 0)
	love.graphics.draw(cactus, WindowWidth / 2 + 200, WindowHeight / 2 - 100, 0, 1, 1, 0, 0)
	love.graphics.draw(cactus, WindowWidth / 2 - 250, WindowHeight / 2 + 150, 0, 1, 1, 0, 0)
	love.graphics.draw(cactus, WindowWidth / 2 - 100, WindowHeight / 2 - 20, 0, 1, 1, 0, 0)
	love.graphics.draw(cactus, WindowWidth / 2 + 100, WindowHeight / 2 + 100, 0, 1, 1, 0, 0)
	love.graphics.draw(johnmarston, WindowWidth / 2, WindowHeight / 2 , 0, 0.2, 0.2, 0, 0)
	love.graphics.setFont(font12)
	love.graphics.setColor(0, 0, 0)
	love.graphics.print("hahahahahaha wild west... you're stupid John Marston lives there and so he killed you with a revolver when u draw your sword", 10, 10, 0, 1, 1, 0, 0)
end

function drawwarrioreast1()
	--dessins qui s'affichent quand on choisi le warrior et que l'on va a l'Est
	love.graphics.setBackgroundColor(0, 30, 255)
	love.graphics.setColor(0, 100, 0)
	love.graphics.rectangle("fill", 0, 400, WindowWidth, 200)
	love.graphics.setColor(255, 255, 255)
	-- rangé d'arbres de gauche pour effet couloir
	love.graphics.draw(jungletree, 20, 185, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 0, 215, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 20, 245, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 40, 275, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 60, 305, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 80, 335, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 100, 365, 0, 1, 1, 0, 0)
	--rangé d'arbres de droite pour effet couloir
	love.graphics.draw(jungletree, 570, 185, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 590, 215, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 610, 245, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 630, 275, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 650, 305, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 670, 335, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 690, 365, 0, 1, 1, 0, 0)
	--couloir fini
	love.graphics.setFont(font50)
	love.graphics.setColor(rr, gr, br)
	love.graphics.print("YOU LIVED!!!", WindowWidth / 2 - 170, 30, 0, 1, 1, 0, 0)
	love.graphics.setFont(font12)
	love.graphics.setColor(255, 255, 255)
	love.graphics.print("but you ain't done for shit press I to swim to another Island, C to stay here and set Camp for the night, S to Scout around you", 10, 120, 0, 1, 1, 0, 0)
end
	
function drawwarriorisland2()
	--dessins qui s'affichent quand on choisi le warrior et qu'on va à l'ESt puis que on nage a une île
	love.graphics.setBackgroundColor(0, 30, 255)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(sharkeatingwarrior, 100, 0, 0, 1, 1, 0, 0)
	love.graphics.setFont(font13)
	love.graphics.print("BWAHAHAHAHAHAHHAHAHAHAHA YOU'VE BEEN EATED BY A SHARK BWAHAHHAHAHAHAHAHA", 20, 20, 0, 1, 1, 0, 0)
end

function drawwarriorcamp2()
	--dessins qui s'affichent quand on choisi le warrior et qu'on va à l'ESt puis que on fait un camp
	love.graphics.setBackgroundColor(0, 30, 255)
	love.graphics.setColor(0, 100, 0)
	love.graphics.rectangle("fill", 0, 400, WindowWidth, 200)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(jungletree, 20, 185, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 0, 215, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 20, 245, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 40, 275, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 60, 305, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 80, 335, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, - 100, 365, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 570, 185, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 590, 215, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 610, 245, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 630, 275, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 650, 305, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 670, 335, 0, 1, 1, 0, 0)
	love.graphics.draw(jungletree, 690, 365, 0, 1, 1, 0, 0)
	love.graphics.setFont(font13)
	love.graphics.setColor(255, 255, 255)
	love.graphics.print("so, as you set camp for the night it's all fine then as you sleep, the fire take over your camp :|, you're pretty noob friend.", 20, 20, 0, 1, 1, 0, 0)
	love.graphics.draw(Fire2, 165, 360, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire2, 265, 360, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire2, 365, 360, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(warrior, WindowWidth / 2 - 50, WindowHeight / 2 + 100, 0, 1, 1, 0, 0)
	love.graphics.draw(Fire1, 130, 410, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire1, 230, 410, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire1, 330, 410, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire1, 430, 410, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire1, 450, 410, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 100, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 200, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 300, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 400, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 500, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 100, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 200, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 300, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 400, 450, 0, 0.4, 0.4, 0, 0)
	love.graphics.draw(Fire3, 500, 450, 0, 0.4, 0.4, 0, 0)
end

function drawwarriorscout2()
	--dessins qui s'affichent quand on choisi le warrior et qu'on va à l'ESt puis que on scout les environs
	love.graphics.setBackgroundColor(rrr, 0, 0)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(satanicdoor, 0, 0, 0, 1, 1, 0, 0)
	love.graphics.setFont(font11)
	love.graphics.print("You've arrived to a satanic fort, you can't turn back now(cuz i didn't want to program a way of turning back, deal with it) press enter to continue", 5, 20, 0, 1, 1, 0, 0)
end

function drawwarriorsatanicfortentrance3()
	love.graphics.setBackgroundColor(0, 0, 0)
	blacktoredfadeanimation:draw(0, 0)
	love.graphics.setFont(font13)
	love.graphics.setColor(255, 255, 255)
	love.graphics.draw(sataniccultist, 20, 300, 0, 3, 3, 0, 0)
	love.graphics.draw(sataniccultist, 120, 300, 0, 2.5, 2.5, 0, 0)
	love.graphics.draw(sataniccultist, 220, 300, 0, 2, 2, 0, 0)
	love.graphics.draw(sataniccultist, 320, 300, 0, 1.5, 1.5, 0, 0)
	love.graphics.draw(sataniccultist, 420, 300, 0, 2, 2, 0, 0)
	love.graphics.draw(sataniccultist, 520, 300, 0, 2.5, 2.5, 0, 0)
	love.graphics.draw(sataniccultist, 620, 300, 0, 3, 3, 0, 0)
	love.graphics.print("yeah so i was sick of drawing and I had no one to do this, so deal with the shitty drawings", 120, 50, 0, 1, 1, 0, 0)
	love.graphics.setFont(font11)
	love.graphics.print("as you enter, a bunch of satanic cultist look at you weirdly what do you do? J to join them and become a satanist, K to kill them, R to run", 30, 80, 0, 1, 1, 0, 0)
end

function drawwarriorsatanicfortjoin3()
	love.graphics.setBackgroundColor(0, 0, 0)
	love.graphics.setFont(font13)
	love.graphics.setColor(255, 255, 255)
	love.graphics.print("ha...ha...hahaha, you thought you could joins demons as a human?, you could if you were dying but not now, you might wanna remember this", 20, 20, 0, 1, 1, 0, 0)
	love.graphics.print("btw this is what happened to you lol", 20, 50, 0, 1, 1, 0, 0)
	love.graphics.draw(warrior, WindowWidth / 2 - 60, WindowHeight / 2 - 100, 0, 1, 1, 0, 0)
	explosionanimation:draw(WindowWidth / 2 - 50, WindowHeight / 2 - 90)
	explosionanimation2:draw(WindowWidth / 2 - 100, WindowHeight / 2 - 110)
	explosionanimation:draw(WindowWidth / 2 - 75, WindowHeight / 2 - 135)
	explosionanimation2:draw(WindowWidth / 2 - 75, WindowHeight / 2 - 70)
	explosionanimation:draw(WindowWidth / 2 - 100, WindowHeight / 2 - 110)
	explosionanimation2:draw(WindowWidth / 2 - 50, WindowHeight / 2 - 90)
	explosionanimation:draw(WindowWidth / 2 - 75, WindowHeight / 2 - 70)
	explosionanimation2:draw(WindowWidth / 2 - 75, WindowHeight / 2 - 1350)
end

function drawwarriorsatanicfortkill3()
	love.graphics.setBackgroundColor(255, 255, 255)
	love.graphics.setColor(255, 255, 255)
	if gamestate == "warriorsatanicfortkill3" then
		satanicfortfightanimation:draw(0, 0)
	end
end

function drawwarriorsatanicfortrun3()
end

function love.update(dt)
	--gamestate (ils servent à déterminer quelle fonction love.draw() est active)
	--love.draw pour warrior1
	if gamestate == "intro" then
		love.draw = drawintro
	elseif gamestate == "warrior1" then
		love.draw = drawwarrior1
	elseif gamestate == "warriornorth1" then
		love.draw = drawwarriornorth1
	elseif gamestate == "warriorwest1" then
		love.draw = drawwarriorwest1
	elseif gamestate == "warrioreast1" then
		love.draw = drawwarrioreast1
	--love.draw pour warrior2
	elseif gamestate == "warriorisland2" then
		love.draw = drawwarriorisland2
	elseif gamestate == "warriorcamp2" then
		love.draw = drawwarriorcamp2
	elseif gamestate == "warriorscout2" then
		love.draw = drawwarriorscout2
	elseif gamestate == "warriorsatanicfortentrance3" then
		love.draw = drawwarriorsatanicfortentrance3
	elseif gamestate == "warriorsatanicfortrun3" then
		love.draw = drawwarriorsatanicfortrun3
	elseif gamestate == "warriorsatanicfortkill3" then
		love.draw = drawwarriorsatanicfortkill3
	elseif gamestate == "warriorsatanicfortjoin3" then
		love.draw = drawwarriorsatanicfortjoin3
	end
	--variable qui se modifient chaque seconde grace a math.random (ils servent a faire flasher le texte) (toute les couleurs)
	rr = math.random(0, 255)
	br = math.random(0, 255)
	gr = math.random(0, 255)
	--variable de text ou autre qui flash teinte rouge (rrr = rougerandomrouge)
	rrr = math.random(10, 255)
	--animations (les updaters)
	blacktoredfadeanimation:update(dt)
	explosionanimation:update(dt)
	explosionanimation2:update(dt)
	satanicfortfightanimation:update(dt)
end

function love.keypressed(key)
	--modifier le gamestate qui sert a ... (voir plus haut pour l'effet de changer les gamestate, aller dans love.update(dt))
	--gamestate warrior1
	if key == "kp0" then
		gamestate = "intro"
	elseif key == "up" and gamestate == "intro" then
		gamestate = "warrior1"
	elseif key == "n" and gamestate == "warrior1" then
		gamestate = "warriornorth1"
	elseif key == "w" and gamestate == "warrior1" then
		gamestate = "warriorwest1"
	elseif key == "e" and gamestate == "warrior1" then
		gamestate = "warrioreast1"
	--gamestate warrior2
	elseif key == "i" and gamestate == "warrioreast1" then
		gamestate = "warriorisland2"
	elseif key == "c" and gamestate == "warrioreast1" then
		gamestate = "warriorcamp2"
	elseif key == "s" and gamestate == "warrioreast1" then
		gamestate = "warriorscout2"
	--gamestates warrior3
	elseif key == "return" and gamestate == "warriorscout2" then
		gamestate = "warriorsatanicfortentrance3"
	elseif key == "r" and gamestate == "warriorsatanicfortentrance3" then
		gamestate = "warriorsatanicfortrun3"
	elseif key == "j" and gamestate == "warriorsatanicfortentrance3" then
		gamestate = "warriorsatanicfortjoin3"
	elseif key == "k" and gamestate == "warriorsatanicfortentrance3" then
		gamestate = "warriorsatanicfortkill3"
	--gamestates warrior4
	end
end
User avatar
tavuntu
Citizen
Posts: 65
Joined: Mon Dec 24, 2012 6:56 am
Contact:

Re: animation starts too fast with AnAL

Post by tavuntu »

Remember that the penultimate parameter of newAnimation is the delay of each frame, if you change it from 0.1 to 0.2, the animation will run at half speed.
Regards :)
User avatar
tavuntu
Citizen
Posts: 65
Joined: Mon Dec 24, 2012 6:56 am
Contact:

Re: animation starts too fast with AnAL

Post by tavuntu »

If you're using Windows, sometimes there's a kind of bug which makes yor first frames pass really fast and after a little time, pass at normal velocity (it happends to me once, on Linux I don't have that problem, I guess for the native OpenGL libraries).
Fatmat927
Prole
Posts: 42
Joined: Wed Sep 18, 2013 1:15 am

Re: animation starts too fast with AnAL

Post by Fatmat927 »

its neither of that i fixed it's bacause i was updating it from the start had to change update() to an if..... then update()
Post Reply

Who is online

Users browsing this forum: No registered users and 41 guests