Page 1 of 1

Boundary limit for < 0 doesn't work?

Posted: Sun Sep 20, 2015 3:05 am
by geleiademocoto
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:

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
Pardon the messy code, I'll clean it up I swear!

Re: Boundary limit for < 0 doesn't work?

Posted: Sun Sep 20, 2015 8:24 am
by Robin
You have a typo: positonx and positony instead of positionx and positiony.

(Also, your .love was packaged wrong: you zipped your game directory instead of its contents.)

Re: Boundary limit for < 0 doesn't work?

Posted: Sun Sep 20, 2015 8:31 am
by kbmonkey
You made a typo

playercolin.positonx = 100*scale ---- WHY ISN'T THIS WORKING?

It happens.

Re: Boundary limit for < 0 doesn't work?

Posted: Sun Sep 20, 2015 8:33 am
by kbmonkey
Oh snap Robin. Sorry I should have refreshed before posting :crazy:

Re: Boundary limit for < 0 doesn't work?

Posted: Sun Sep 20, 2015 4:30 pm
by geleiademocoto
Holy crap, I stared at those lines a million times and didn't see that. Should have posted this to the "questions that don't deserve their own thread" post. Thanks.