General discussion about LÖVE, Lua, game development, puns, and unicorns.
blindside78
Prole
Posts: 3 Joined: Fri Feb 22, 2013 12:35 pm
Post
by blindside78 » Sat Feb 23, 2013 8:45 pm
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
pakoskyfrog
Citizen
Posts: 62 Joined: Mon Feb 04, 2013 12:54 pm
Location: France
Post
by pakoskyfrog » Sat Feb 23, 2013 8:50 pm
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
blindside78
Prole
Posts: 3 Joined: Fri Feb 22, 2013 12:35 pm
Post
by blindside78 » Sat Feb 23, 2013 8:59 pm
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
please help
thanks
pakoskyfrog
Citizen
Posts: 62 Joined: Mon Feb 04, 2013 12:54 pm
Location: France
Post
by pakoskyfrog » Sat Feb 23, 2013 9:09 pm
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
Robin
The Omniscient
Posts: 6506 Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:
Post
by Robin » Sun Feb 24, 2013 3:55 pm
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.
Users browsing this forum: Ahrefs [Bot] and 6 guests