Boundary limit for < 0 doesn't work?
Posted: Sun Sep 20, 2015 3:05 am
Hi. This might be a little pointless since there's gonna be collision boxes blocking the way, but it's bothering me and I feel like it's gonna come back to bite me in the ass if I don't take care of it now. It's your average "keep the character from running off the screen". I used this exact same thing with different values in the little game I last made, over a year ago.
Suddenly, I can seem to keep the character from running off the screen to the right and down, but not up and to the left. That is, the "if position is less than zero, position is zero" isn't working. I'll upload my code, keep in mind the values are all screwed up because I've been messing with them trying to figure out the problem. The code in question is on playercolin.lua. Here it is by itself:
Pardon the messy code, I'll clean it up I swear!
Suddenly, I can seem to keep the character from running off the screen to the right and down, but not up and to the left. That is, the "if position is less than zero, position is zero" isn't working. I'll upload my code, keep in mind the values are all screwed up because I've been messing with them trying to figure out the problem. The code in question is on playercolin.lua. Here it is by itself:
Code: Select all
if playercolin.positionx > 700*scale then
playercolin.positionx = 700*scale
end
if playercolin.positionx < 100*scale then
playercolin.positonx = 100*scale ---- WHY ISN'T THIS WORKING?
end
if playercolin.positiony > (1000-playercolin.colin_size/2)*scale then
playercolin.positiony = (1000-playercolin.colin_size/2)*scale
end
if playercolin.positiony < 100*scale then
playercolin.positony = 100*scale ---- WHY ISN'T THIS WORKING?
end