i problem with making borders for my game

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
imDread
Prole
Posts: 6
Joined: Mon May 20, 2024 10:39 am

i problem with making borders for my game

Post by imDread »

function explo(x)
if x*x <=30 then
return ((x*x)*1.1)/(x*1.01)
else
return x
end
end

function border(y)
if y <= 10 then
return 10
else
return y
end
end

function love.load()
_G.paddle1 = {
x = 20,y=200,speed
}
_G.paddle2 = {
x = 460,y=200,speed
}
end

function love.update(dt)
if love.keyboard.isDown("up") then
paddle2.y = paddle2.y - paddle2.speed
paddle2.speed = explo(paddle2.speed)
paddle2.y = border(y)

i created border function to check to make borders for the game but when i try to move the player "up" it says

main.lua:11: attempt to compare nil with number


Traceback

[love "callbacks.lua"]:228: in function 'handler'
main.lua:11: in function 'border'
main.lua:31: in function 'update'
[love "callbacks.lua"]:162: in function <[love "callbacks.lua"]:144>
[C]: in function 'xpcall'
User avatar
knorke
Party member
Posts: 262
Joined: Wed Jul 14, 2010 7:06 pm
Contact:

Re: i problem with making borders for my game

Post by knorke »

paddle2.y = border(y)
should be:
paddle2.y = border(paddle2.y)
Post Reply

Who is online

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