Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines
(+1)

Cool mechanic! I'm wondering how you programmed the detection for number of intersections. 

(+1)

Hey, thanks for playing!  The line you draw is made up of many small segments stored in a list.  Each time a new segment is added to the list, it's compared against every other segment that came before to see whether they intersect using "funky math stuff" (parametric equations, it's actual magic to me).  If the math says they intersect, then the coordinates of that point are added to a list of pending intersections.  If the mouse moves a certain distance away from that point with left-click still held down, then it locks in that intersection and draws a star to indicate it registered.  When left-click is released, the number of stars are counted and that's what determines which spell is cast.

I added the pending system as a sort of "dead zone" to prevent unintentional crossings when the end of the line just barely crosses over the start of the line, but it's less effective if the loop is drawn very large.  That's why I'm planning on dynamically changing the dead zone distance based on the total length of the line after the jam ends :)  Hopefully, that'll help make the detection more accurate.