Boundary limit for < 0 doesn't work?

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
geleiademocoto
Prole
Posts: 11
Joined: Sat Apr 26, 2014 11:25 pm

Boundary limit for < 0 doesn't work?

Post 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!
Attachments
cc.love
(333.62 KiB) Downloaded 91 times
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

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

Post 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.)
Help us help you: attach a .love.
User avatar
kbmonkey
Party member
Posts: 139
Joined: Tue Sep 01, 2015 12:19 pm
Location: Sydney
Contact:

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

Post by kbmonkey »

You made a typo

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

It happens.
User avatar
kbmonkey
Party member
Posts: 139
Joined: Tue Sep 01, 2015 12:19 pm
Location: Sydney
Contact:

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

Post by kbmonkey »

Oh snap Robin. Sorry I should have refreshed before posting :crazy:
geleiademocoto
Prole
Posts: 11
Joined: Sat Apr 26, 2014 11:25 pm

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

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 3 guests