Log In  

Cart #27042 | 2016-08-18 | Code ▽ | Embed ▽ | License: CC4-BY-NC-SA


Heyo, this is my first post and I have no idea how anything works. Pardon my ignorance :y

This is something I've been working on for the past couple of days. It has vacuum/gravity physics thus far. I'm trying to get proper collision physics in next but I encountered a weird bug with the distance on the way. Watch the distance meter (white) as you move away from the red circle, you'll see what I mean. A sound plays when the distance is less than or equals 11, but it does it in places it shouldn't. Advice is welcome!

Update: Now that the bug has been squished, time to figure out collision physics. Oh boy, trig :V
Thanks for the help so far, I'm probably going to need more later ^^;

P#26978 2016-08-16 03:05 ( Edited 2016-08-18 05:02)

I assume the x^2 or y^2 in your distance calc is overflowing the maximum value of pico-8. (from the quirks section of the manual: "PICO-8 numbers only go up to 32767.99")

So it winds up calculating the sqrt of negative numbers, and I won't pretend to know what pico8 does with that.

P#26990 2016-08-16 11:56 ( Edited 2016-08-16 15:56)

Yeah, I think you're right about it overflowing. It seems to do this whenever the absolute value of x or y are greater than 181, whose square is 32761.

Thanks, tyroney!

P#26998 2016-08-16 19:18 ( Edited 2016-08-16 23:18)

Yep, this is a common problem.

Try dividing your numbers by a constant before squaring them, then multiply by that constant after you get the square root.

P#27004 2016-08-16 21:24 ( Edited 2016-08-17 01:24)

Hey, that did the trick! Thanks, impbox!

P#27041 2016-08-18 00:46 ( Edited 2016-08-18 04:46)

[Please log in to post a comment]

Follow Lexaloffle:          
Generated 2024-03-29 14:24:37 | 0.010s | Q:16