Changing number varibles

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
blindside78
Prole
Posts: 3
Joined: Fri Feb 22, 2013 12:35 pm

Changing number varibles

Post 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
User avatar
pakoskyfrog
Citizen
Posts: 62
Joined: Mon Feb 04, 2013 12:54 pm
Location: France

Re: Changing number varibles

Post 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
blindside78
Prole
Posts: 3
Joined: Fri Feb 22, 2013 12:35 pm

Re: Changing number varibles

Post 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
User avatar
pakoskyfrog
Citizen
Posts: 62
Joined: Mon Feb 04, 2013 12:54 pm
Location: France

Re: Changing number varibles

Post 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
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Changing number varibles

Post 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.
Help us help you: attach a .love.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot] and 2 guests