Page 1 of 1
Help me please, I'm noob :S
Posted: Thu Jan 29, 2015 5:17 am
by Byakko
I made a square that you can move with the arrows. When it goes out of the screen it's supposed to appear in the other side. It doesn't work when it goes out from the left or up edge. What am I doing wrong? Here's the code:
Code: Select all
x = 350
y = 250
function love.load()
love.graphics.setBackgroundColor( 255, 255, 255, 255)
end
function love.draw()
love.graphics.setColor( 0, 0, 0, 255 )
love.graphics.rectangle( "fill", x, y, 100, 100)
end
function love.update(dt)
if love.keyboard.isDown("right") then
x = x + 128*dt
end
if love.keyboard.isDown("left") then
x = x - 128*dt
end
if love.keyboard.isDown("up") then
y = y - 128*dt
end
if love.keyboard.isDown("down") then
y = y + 128*dt
end
if x > 800 then
x = -100
end
if y > 600 then
y = -100
end
if x = -100 then
x = 900
end
if y = -100 then
y = 700
end
end
Re: Help me please, I'm noob :S
Posted: Thu Jan 29, 2015 5:40 am
by DaedalusYoung
This:
Byakko wrote:Code: Select all
if x = -100 then
x = 900
end
if y = -100 then
y = 700
end
is checking if the square is at
exactly -100. This probably never happens. Change it to:
Code: Select all
if x < -100 then
x = 900
end
if y < -100 then
y = 700
end
Re: Help me please, I'm noob :S
Posted: Thu Jan 29, 2015 9:07 pm
by Byakko
Oh, that's what I did first and it also didn't work :s
Re: Help me please, I'm noob :S
Posted: Thu Jan 29, 2015 11:58 pm
by s-ol
Byakko wrote:Oh, that's what I did first and it also didn't work :s
Then maybe use 0 instead of -100? This should definitely work.
Re: Help me please, I'm noob :S
Posted: Fri Jan 30, 2015 12:12 am
by Byakko
S0lll0s wrote:Then maybe use 0 instead of -100? This should definitely work.
Never mind.
I realized what it's the problem!
Code: Select all
if x > 800 then
x = -100
end
if y > 600 then
y = -100
end
if x < -100 then
x = 900
end
if y < -100 then
y = 700
end
When x < -100 then it becomes 900, then x > 800 so it's supposed to become -100. I think this makes the program get crazy. I feel stupid
Re: Help me please, I'm noob :S
Posted: Sun Feb 01, 2015 5:49 am
by pactace
haha im on the same level with ya bro can anyone give me some code to import enemys I'm doing a 2D platformer and Im so confused
Re: Help me please, I'm noob :S
Posted: Sun Feb 01, 2015 7:12 am
by Doctory
start another thread @pactace
Re: Help me please, I'm noob :S
Posted: Sun Feb 01, 2015 12:52 pm
by s-ol
pactace wrote:haha im on the same level with ya bro can anyone give me some code to import enemys I'm doing a 2D platformer and Im so confused
that's not an actual question....
Doctory wrote:start another thread @pactace
when he finds a question. For now you better look around the wiki and forum, or open up some other love game. We don't need more threads like "help me: how do I do everything?"
Re: Help me please, I'm noob :S
Posted: Fri Feb 06, 2015 4:30 am
by pactace
Really I posted a thread with basically the same title and you guys were mad at me
Re: Help me please, I'm noob :S
Posted: Fri Feb 06, 2015 2:45 pm
by Positive07
pactace wrote:Really I posted a thread with basically the same title and you guys were mad at me
Yeah... so?
Your post was the main problem, you had no idea what you wanted to do, you had no idea on how to do anything so basically you wanted us to give you everything, and after that you would have asked us to assemble it... that is a BIG NO!
Read, learn, understand and come with a question like this guy did, the title is less important than the question itself. Of course if your post has a title like this then less people will look at it, so a good title is better.
First get your question as Solllos suggested
EDIT: Dont comment dead or already answered threads with this kind of issues... Or I'll start to report your comments.
Also dont "flag" useful threads with comments, that is no good and makes old post pop up as new, which is something no one wants, already answered and solved problems should be left there