[Solved]Disappearing Shapes Problem

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
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

[Solved]Disappearing Shapes Problem

Post by davisdude »

Okay, so I'm doing something with triangle/rectangle/circle collision. A very basic Hardagon Collider-esque thing. I figured I'd start on the triangles because I already knew circle-circle, rectangle-rectangle, and circle-rectangle (see post here if you're curious: http://www.love2d.org/forums/viewtopic.php?f=4&t=33493 ). Anyway, I was just beginning testing my first part of the actual collision, and have an encountered my first problem that I cannot fix: one of the triangles disappears when the mouse is over both of them. I know it has something to do with the tri.offset table, but other than that I would have to guess it overrides the table or something? I don't know. Anyway, feel free to poke through my code if you want to, just give credit to me, and don't just copy and paste! Look at it so that you learn something. Anyway, I made all of it by my self (except Herod's formula, obviously). I also know that I have not made the circle bit yet. I'm getting to that.
Please feel free to critique my code/ let me know if you have any suggestions.
Thanks!

Edit: If it's any help you can know one thing: when the shape disappears its coordinates are replaced by the same 2 repeating coordinates.
I think this might be caused by all but one pair of the coordinates replacing them all?

Another edit: if you 'acclimate' them by moving it over the other WITHOUT the mouse going over the other, it will then work. Not exactly sure why...

Update: In the mean time, you can see an 'update log' that prints the coordinates of the second triangle (the one in the right of the screen). What you have to do is click on both the shapes before you drag the both over.

Yet another update: I've figured out that the two coordinates it makes are where the mouse goes over the two shapes. I also know why it does it: it doesn't have a previous offset (attained in the move function, which is only called on click ). This explains why it's reduced to two points: it has no previous offset, so it makes it the offset of the mouse x and mouse y when it crosses. Obviously, it can't draw a triangle using just two points, so it just draws the whole 'triangle' as one point. Still haven't fixed it yet, though.

FINAL UPDATE!
I figured it out! In the love.update I made it so that if there wasn't the table with the coordinates it made it.
Attachments
shape_collision.love
(2.93 KiB) Downloaded 66 times
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
Post Reply

Who is online

Users browsing this forum: Google [Bot] and 1 guest