Page 1 of 1

Changing number varibles

Posted: Sat Feb 23, 2013 8:45 pm
by blindside78
im tring to change a number varible everytime my timer reaches over 10 seconds but the quardinates dont change.

Code: Select all

player = {}
player.x = 200
player.y = 300
player.speed = 150
player.width = 80
player.height = 80
player.friction = 0  
QposX = 153
QposY = 33
fx = 240
fy = 320
timer = 2
one  = 1
function player_load()

player.pic = love.graphics.newImage("Pics/sprsh.png")
quad = love.graphics.newQuad(3,3,112,112,468,124)
Face = love.graphics.newQuad(QposX,QposY, 74, 74, 468, 124)
end

function player_draw()

love.graphics.drawq(player.pic, quad, player.x, player.y)
love.graphics.drawq(player.pic, Face, fx, fy)
end

function player_active(dt)
	
	
	
	if timer > 1 then
	    
	end
	
	if love.keyboard.isDown("a") then
	timer = timer + one * dt
	QposX = 267
	player.x = player.x  - player.speed * dt
	fx = fx  - player.speed * dt
	elseif love.keyboard.isDown("d") then
	player.x = player.x + player.speed * dt
	fx = fx + player.speed * dt
	end	
end

please help

Re: Changing number varibles

Posted: Sat Feb 23, 2013 8:50 pm
by pakoskyfrog
you could try something like :

Code: Select all

timer = timer * one*dt -- already in your code
if timer >= 10 then
    -- insert here what you want to do when the timer get over 10 sec
    timer = 0 -- reinit the timer
end

Re: Changing number varibles

Posted: Sat Feb 23, 2013 8:59 pm
by blindside78
this is in my code:

Code: Select all

if love.keyboard.isDown("a") then
	timer = timer + one * dt
	QposX = 267
	QposY  = 30
	player.x = player.x  - player.speed * dt
	fx = fx  - player.speed * dt
	elseif love.keyboard.isDown("d") then
	player.x = player.x + player.speed * dt
	fx = fx + player.speed * dt
	end
but the "QposX" and "QposY" dont change when i press 'a'.
thats what i need help with :P

please help
thanks

Re: Changing number varibles

Posted: Sat Feb 23, 2013 9:09 pm
by pakoskyfrog
It's maybe a keyboard issue... tried pushing "q" instead ? (as in US layout)
what type of keyboard do you use ? (i use a french one)

Under your If, you define QposX and QposY as constants ... i don't know if it's by design
And you have to keep pressing the key if you want what is under the If to be executed.

And i see nowhere a threshold that triggers anything every ten secs

Re: Changing number varibles

Posted: Sun Feb 24, 2013 3:55 pm
by Robin
If you upload your full game, we may be able to help you. With the information we have now? Not so much. Please upload a .love.