[Solved] Pointing at an object that's out of sight

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.
User avatar
darkfrei
Party member
Posts: 1169
Joined: Sat Feb 08, 2020 11:09 pm

Re: [Solved] Pointing at an object that's out of sight

Post by darkfrei »

But (t==t) is always true.
:awesome: in Lua we Löve
:awesome: Platformer Guide
:awesome: freebies
RNavega
Party member
Posts: 239
Joined: Sun Aug 16, 2020 1:28 pm

Re: [Solved] Pointing at an object that's out of sight

Post by RNavega »

@pgimeno it's not pickiness xD , it's an important pointer.

That point-slope code has special cases for when the player and enemy are perfectly aligned on the X or Y axes (so this prevents a division by zero, or when the slope 'm' results in zero itself), but for the case you mentioned of the player being at/beyond the screen borders, I think you could solve it by making the intersection point the player's position already.

So when the player is at or beyond the screen edges, the arrow position should equal that of the player's. But this shouldn't happen in practice I think -- a game like Super Smash Brothers that has this kind of feature seems to consider the ray origin as the center of the screen. Here you can see that magnifying glass bubble for when a character is off-screen:

Image
User avatar
zorg
Party member
Posts: 3436
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: [Solved] Pointing at an object that's out of sight

Post by zorg »

darkfrei wrote: Sat Jan 09, 2021 8:55 pm But (t==t) is always true.
Not for NaN values; those are the only ones where x==x is false.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
User avatar
Gunroar:Cannon()
Party member
Posts: 1085
Joined: Thu Dec 10, 2020 1:57 am

Re: [Solved] Pointing at an object that's out of sight

Post by Gunroar:Cannon() »

what does NaN mean :P ?
By the way, with that whole t==t thing I did my own rough fix through trail and error before pgmeno posted his fix when I saw things getting buggy.
The risk I took was calculated,
but man, am I bad at math.

-How to be saved and born again :huh:
User avatar
pgimeno
Party member
Posts: 3544
Joined: Sun Oct 18, 2015 2:58 pm

Re: [Solved] Pointing at an object that's out of sight

Post by pgimeno »

NaN means Not a Number. You get those in a few situations; dividing 0/0 is probably the most common. Checking for NaN with t == t saves adding guards for division by zero in my code. The case nonzero/0 gives infinity, and that is already handled properly because it won't pass the test for being the smallest.
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 44 guests