need verlet-rect collisions or verlet-poly

BlitzMax Forums/BlitzMax Programming/need verlet-rect collisions or verlet-poly

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Hi

I am newish to blitz max but in no way new to programming
to the point.. I was working on a little physics project just to get used to using types lists inheritence etc when I cam upon a problem.. I really want to make this into a game but I need verlet to rect collisions (verlet to poly works even better!) I have come up with some code but it slows my game down so much (not to mention it is buggy) that rather than handle 700-800 verlets and constraints, it now only handles 90-100 :(

here is the code I am using

variables:
v.x = verlet x
v.y = verlet y
v.ox = verlet old x
v.oy = verlet old y
v.siz = verlet radius

s.x1 = rect upper left corner x value
s.y1 = rect upper left corner y value
s.width = rect width
s.height = rect height

df vars:

dfu = distance from upper side
dfd = distance from lower side
dfl = distance from left side
dfr = distance from right side

If v.x > s.x1 And v.x < s.x1+s.width Then
If v.y > s.y1-v.siz And v.y < s.y1+s.height+v.siz Then
	
	Local dfu:Int,dfd:Int,dfl:Int,dfr:Int
	
	dfd = v.y - s.y1
	dfu = (s.y1+s.height) - v.y
	dfl = v.x - s.x1
	dfr = (s.x1+s.width) - v.x
	
	If dfu > dfd And dfu > dfl And dfu > dfr Then
		v.oy = v.y
		v.y = s.y1 - v.siz
	ElseIf dfd > dfl And dfd > dfr Then
		v.oy = v.y
		v.y = s.y1 + s.height + v.siz
	ElseIf dfl > dfr Then
		v.ox = v.x
		v.x = s.x1 - v.siz
	Else
		v.ox = v.x
		v.x = s.x1 + s.width + v.siz
	EndIf
	
EndIf
ElseIf v.x > s.x1-v.siz And v.x < s.x1+s.width+v.siz Then
If v.y > s.y1 And v.y < s.y1+s.height Then
	Local dfu:Int,dfd:Int,dfl:Int,dfr:Int
	
	dfd = v.y - s.y1
	dfu = (s.y1+s.height) - v.y
	dfl = v.x - s.x1
	dfr = (s.x1+s.width) - v.x
	
	If dfu < dfd And dfu < dfl And dfu < dfr Then
		v.oy = v.y
		v.y = s.y1 - v.siz
	ElseIf dfd < dfl And dfd < dfr Then
		v.oy = v.y
		v.y = s.y1 + s.height + v.siz
	ElseIf dfl < dfr Then
		v.ox = v.x
		v.x = s.x1 - v.siz
	Else
		v.ox = v.x
		v.x = s.x1 + s.width + v.siz
	EndIf
EndIf
EndIf


if anyone has any fast code for verlet-rect collisions please post.
also does anyone know why the above code is slowing down my program? am I using a slow command in bmax? thanks