Commits

Anonymous committed 49fbe0c

Comments (0)

Files changed (7)

src/pgBody.h

-#ifndef _PYGAME_PHYSICS_BODY_
-#define _PYGAME_PHYSICS_BODY_
-
-#include "pgMathTypeDef.h"
-#include "pgVector2.h"
-
-typedef struct _pgShape pgShape;
-
-typedef struct _pgBody{
-	
-	pgReal		fMass;
-	pgVector2	vecLinearVelocity;
-	pgReal		fAngleVelocity;
-
-	pgVector2	vecPosition;
-	pgReal		fRotation;
-	pgVector2	vecImpulse;
-	pgVector2	vecForce;
-	pgReal		fTorque;
-
-	pgReal		fRestitution;
-	pgReal		fFriction;
-
-	pgShape*	shapeBody;
-} pgBody;
-
-
-
-#endif //_PYGAME_PHYSICS_BODY_

src/pgJoint.h

-#ifndef _PYGAME_PHYSICS_JOINT_
-#define _PYGAME_PHYSICS_JOINT_
-
-#include "pgMathTypeDef.h"
-
-typedef struct _pgJoint pgJoint;
-
-typedef struct _pgJoint{
-	pgBody*	body1;
-	pgBody*	body2;
-	bool	isCollideConnect;
-	void	(*SolveConstraint)(pgJoint* joint,pgReal stepTime);
-} pgJoint;
-
-typedef struct _pgDistanceJoint{
-	pgJoint		joint;
-	pgReal		distance;
-	pgVector2	anchor1,anchor2;
-} pgDistanceJoint;
-
-pgJoint* CreateDistanceJoint(pgBody* _body1,pgBody* _body2,pgReal _dist,pgVector2 anchor1,pgVector2 anchor2);
-void	 DestroyDistanceJoint(pgJoint* joint);
-
-
-#endif //_PYGAME_PHYSICS_JOINT_

src/pgMathTypeDef.h

-#ifndef _PYGAME_MATH_TYPE_DEF_
-#define _PYGAME_MATH_TYPE_DEF_
-
-
-typedef float pgReal;
-typedef	int	  bool;
-
-#define true 1;
-#define false 0;
-
-#endif //_PYGAME_MATH_TYPE_DEF_

src/pgMatrix2x2.h

-#ifndef _PYGAME_MATH_MATRIX2X2_
-#define _PYGAME_MATH_MATRIX2X2_
-
-#include "pgMathTypeDef.h"
-
-typedef struct _pgMatrix2x2
-{
-	pgReal x11,x12,x21,x22;
-} pgMatrix2x2;
-
-
-
-
-#endif //_PYGAME_MATH_MATRIX2X2_

src/pgShape.h

-#ifndef _PYGAME_PHYSICS_SHAPE_
-#define _PYGAME_PHYSICS_SHAPE_
-
-#include "pgVector2.h"
-#include "pgAABBBox.h"
-
-typedef struct _pgBody pgBody;
-
-
-typedef struct _pgShape{
-	pgBody*		body;
-	pgAABBBox	box;
-
-	void (*InitShape)(pgBody* bd);
-	void (*DestroyShape)();
-	void (*UpdateAABBBox)();
-} pgShape;
-
-
-typedef struct _pgPolygonShape{
-	pgShape		shape;
-	
-	int			iVertexNum;
-	pgVector2*	iVertexArray;
-} pgPolygonShape;
-
-typedef struct _pgCircleShape{
-	pgShape		shape;
-
-	pgVector2	vecCenter;
-	pgReal		fRadius;
-} pgCircleShape;
-
-#endif //_PYGAME_PHYSICS_SHAPE_

src/pgVector2.h

-#ifndef _PYGAME_MATH_VECTOR2_
-#define _PYGAME_MATH_VECTOR2_
-
-#include "pgMathTypeDef.h"
-
-typedef struct _pgVector2
-{
-	pgReal x,y;
-} pgVector2;
-
-static pgVector2 pgInitVector2(pgReal x,pgReal y);
-static pgVector2 pgAddVector2(const pgVector2 vec1,const pgVector2 vec2);
-static pgVector2 pgSubVector2(const pgVector2 vec1,const pgVector2 vec2);
-static pgVector2 pgMulVector2(const pgVector2 vec1,const pgVector2 vec2);
-static pgVector2 pgMulVector2WithReal(const pgVector2 vec,const pgReal real);
-static pgReal	pgDotVector2(const pgVector2 vec1,const pgVector2 vec2);
-static pgReal	pgGetLengthVector2(const pgVector2 vec);
-static pgReal	pgGetLengthSquareVector2(const pgVector2 vec);
-static void		pgNormalizeVector2(pgVector2*	pVec);
-static pgVector2 pgCrossVector2(const pgVector2 vec1,const pgVector2 vec2);
-
-
-static pgVector2 pgMoveVector2(const pgVector2 vec,const pgVector2 moveVec);
-static pgVector2 pgScaleVector2(const pgVector2 vec,const pgVector2 scaleVec);
-static pgVector2 pgRotate(const pgVector2 vec,const pgVector2 centerVec,const pgReal angle);
-
-#endif //_PYGAME_MATH_VECTOR2_

src/pgWorld.h

-#ifndef _PYGAME_PHYSICS_WORLD_
-#define _PYGAME_PHYSICS_WORLD_
-
-#include <ds.h>
-
-#include "pgMathTypeDef.h"
-#include "pgBody.h"
-#include "pgJoint.h"
-
-
-typedef struct _pgWorld{
-	PARRAY	bodyArray;
-	PARRAY	jointArray;
-
-	pgReal	fGravity;
-	pgReal	fDamping;
-} pgWorld;
-
-static void pgAddBodyToWorld(pgWorld* world,pgBody* body);
-static void pgRemoveBodyFromWorld(pgWorld* world,pgBody* body);
-static void pgAddJointToWorld(pgWorld* world,pgJoint* joint);
-static void pgRemoveJointFromWorld(pgWorld* world,pgJoint* joint);
-static void pgWorldStepSimulation(pgWorld* world,pgReal stepTime);
-
-#endif