2D Physics: Ideas for a Community Project

BlitzMax Forums/BlitzMax Programming/2D Physics: Ideas for a Community Project

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.

Good to hear ;)

I'll soon make a fresh thread and start he project for real. I think we should have the project work threads in Moudle/Tweaks forum instead.


This does not seem to work, I'm trying to get the line normal, Method lies in Type Line2D:

Method CalculateNormal()
'Both these ways should work (WARPY)
'But none of them do!?

' Local Angle# = ATan2( X, Y )
' Normal.X = Cos( Angle + 90 )
' Normal.Y = Sin( Angle + 90 )

'OR

Normal.X = 1
Normal.Y = - X/Y
'Normal.Normalize()
EndMethod



MOST IMPORTANT:

How to handle collisions?
The library will take care of most of the work for the user. The user only needs to create som eCollisionplanes, fill them with objects and then set the collisionresponse for each plane against each other plane. In other words this determines how the Shots collides with walls, how they collide with Ships or ships with sheilds. The result would be that a Plane for each response type will be required. One object is recommended to only be in one plane.

Example code not runnable (See the idea)
Type Line2D

	Method CircleCollide( Circle:Circle2D ) 'Line or Vector vs Circle
		
		
		'All calculations is done here
		'Check is they collide
		If Collide Then Return True	
		
		
		'Most times we want to know more than that they just collided:
		
		'The intersection point
		'The reflecting vector

		'This is optional and is done after we know they collided
		
		'All data of the collision needs To be accesible
		'to further functions that deals with collision response
			
	EndMethod

	Method Collision_GetIntersection( X Var , Y Var)
		'.....
	EndMethod

	Method Collision_GetSeparationVector:Vector2D()
		'.....
		'Usually you use this to alter you position back - so that you do not collide
		'Then depending on elasticy and friction we alter the response.
	EndMethod

EndType

Type MaxPhysicsObject

	Method Collision_ApplyResponse()
		'Alters your speed and your location after a collision
	EndMethod
	
EndType


Type Circle2D Extends MaxPhysicsObject

	Method LineCollide( Line:Line2D ) 'Circle vs Line
		
		Line.CollideCircle( Self )'Call the actuall Line vs Circle method which lies in Line2D
						
	EndMethod
	
EndType