Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Code Excerpt #1
- // Aidan's Cooler
- static cpVect aidansCoolerHandleVerts[4] = {cpvFtoI(5-16,22-16),cpvFtoI(9-16,25-16),cpvFtoI(27-16,8-16),cpvFtoI(25-16,6-16)};
- static cpVect aidansCoolerVertsInside[4] = {cpvFtoI(9-31.5f,18-28),cpvFtoI(12-31.5f,30-28),cpvFtoI(53-31.5f,30-28),cpvFtoI(53-31.5f,18-28)};
- static cpVect aidansCoolerVertsFront[4] = {cpvFtoI(5-31.5f,15-28),cpvFtoI(8-31.5f,39-28),cpvFtoI(57-31.5f,38-28),cpvFtoI(57-31.5f,15-28)};
- static cpVect aidansCoolerVertsRight[4] = {cpvFtoI(54-31.5f,15-28),cpvFtoI(54-31.5f,39-28),cpvFtoI(57-31.5f,38-28),cpvFtoI(57-31.5f,15-28)};
- static cpVect aidansCoolerVertsLeft[4] = {cpvFtoI(5-31.5f,15-28),cpvFtoI(8-31.5f,39-28),cpvFtoI(10-31.5f,39-28),cpvFtoI(7-31.5f,15-28)};
- static cpVect aidansCoolerVerts[4] = {cpvFtoI(11-31.5f,38-28),cpvFtoI(12-31.5f,50-28),cpvFtoI(54-31.5f,50-28),cpvFtoI(54-31.5f,38-28)};
- static CMPartBodyDynamicDef aidansCoolerWheelBodyDef(2,CC_TO_TMPOINTINT32(16-31.5f,46-28), FLOAT_TO_INT32(1.5f), FLOAT_TO_INT32(7.8f), false,false,false, NULL);
- static CMPartBodyDynamicDef aidansCoolerHandleBodyDef(1,CC_TO_TMPOINTINT32(66-31.5f,9-28), FLOAT_TO_INT32(12), FLOAT_TO_INT32(7.8f), false,false,false, &aidansCoolerWheelBodyDef);
- static CMPartBodyDynamicDef aidansCoolerBodyDef(0,CC_TO_TMPOINTINT32(0.0f,0.0f), FLOAT_TO_INT32(68), FLOAT_TO_INT32(7.8f), false,false,false, &aidansCoolerHandleBodyDef);
- static CMPartConstraintRotaryLimitJointDef aidansCoolerHandleRotaryConstraintDef(2,0,1, 0,TM_THREE_QUARTERS_PI, false,NULL);
- static CMPartConstraintPivotJointDef aidansCoolerHandleConstraintDef(1,1,0,CC_TO_TMPOINTINT32(58-31.5f,16-28),false,&aidansCoolerHandleRotaryConstraintDef);
- static CMPartConstraintPivotJointDef aidansCoolerConstraintDef(0,2,0,CC_TO_TMPOINTINT32(16-31.5f,46-28),false,&aidansCoolerHandleConstraintDef);
- static CMPartShapeCircleDef aidansCoolerWheelShapeDef(5,CC_TO_TMPOINTINT32(0,0),2, SP_SOFT_STICKY,SP_SFX_SILENT, FLOAT_TO_INT32(5.5f), COL_GROUP_DEFAULT,COL_TYPE_DEFAULT,COL_LAYER_DEFAULT, false, NULL);
- static CMPartShapePolyDef aidansCoolerHandleShapeDef(4,zeroPoint,1, SP_SOFT_NORMAL,SP_SFX_SILENT, aidansCoolerHandleVerts,4, COL_GROUP_DEFAULT,COL_TYPE_DEFAULT,COL_LAYER_DEFAULT, false,&aidansCoolerWheelShapeDef);
- static CMPartShapePolyDef aidansCoolerInsideShapeDef(CONTAINER_SHAPE_ID,zeroPoint,0, SP_SENSOR,SP_SFX_SILENT, aidansCoolerVertsInside,4, COL_GROUP_DEFAULT,COL_TYPE_SENSOR_BEGIN_SEPARATE,COL_LAYER_DEFAULT, false,&aidansCoolerHandleShapeDef);
- static CMPartShapePolyDef aidansCoolerFrontShapeDef(3,zeroPoint,0, SP_SOFT_NORMAL,SP_SFX_HARD_SURFACE, aidansCoolerVertsFront,4, COL_GROUP_DEFAULT,COL_TYPE_DEFAULT,COL_LAYER_BOX_FRONT, false,&aidansCoolerInsideShapeDef);
- static CMPartShapePolyDef aidansCoolerRightShapeDef(2,zeroPoint,0, SP_SOFT_NORMAL,SP_SFX_HARD_SURFACE, aidansCoolerVertsRight,4, COL_GROUP_DEFAULT,COL_TYPE_DEFAULT,COL_LAYER_DEFAULT, false,&aidansCoolerFrontShapeDef);
- static CMPartShapePolyDef aidansCoolerLeftShapeDef(1,zeroPoint,0, SP_SOFT_NORMAL,SP_SFX_HARD_SURFACE, aidansCoolerVertsLeft,4, COL_GROUP_DEFAULT,COL_TYPE_DEFAULT,COL_LAYER_DEFAULT, false,&aidansCoolerRightShapeDef);
- static CMPartShapePolyDef aidansCoolerShapeDef(0,zeroPoint,0, SP_SOFT_NORMAL,SP_SFX_HARD_SURFACE, aidansCoolerVerts,4, COL_GROUP_DEFAULT,COL_TYPE_DEFAULT,COL_LAYER_DEFAULT, false,&aidansCoolerLeftShapeDef);
- static CMPartAttachmentRopeDef aidansCoolerAttachmentDef(0,CC_TO_TMPOINTINT32(25-16,7-16),1,false,NULL);
- static CMPartArtSpriteRectDef aidansCoolerWheelArtDef(3,BOX_FRONT_LAYER+1,2,2,"iceChestWheels",FLOAT_TO_INT32(20.0f),FLOAT_TO_INT32(20.0f),1,zeroPoint, true,true,false,true);
- static CMPartArtSpriteRectDef aidansCoolerHandleArtDef(2,BOX_FRONT_LAYER+1,1,1,"iceChestHandle",FLOAT_TO_INT32(32.0f),FLOAT_TO_INT32(32.0f),1,zeroPoint, true,true,false,true, 255, &aidansCoolerWheelArtDef);
- static CMPartArtSpriteRectDef aidansCoolerFlippedArtDef(1,BOX_FRONT_LAYER,0,0,"iceChestBodyNoIceFlipped",FLOAT_TO_INT32(63),FLOAT_TO_INT32(56),1,zeroPoint, true,true,false,false, 255, &aidansCoolerHandleArtDef);
- static CMPartArtSpriteRectDef aidansCoolerArtDef(0,BOX_FRONT_LAYER,0,0,"iceChestBodyNoIce",FLOAT_TO_INT32(63),FLOAT_TO_INT32(56),1,zeroPoint, true,true,false,false, 255, &aidansCoolerFlippedArtDef);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #2
- // Some macros used above
- #define FLOAT_TO_INT32(flt) ((int)((flt)*INT32_ONE_FLOAT))
- #define CC_TO_TMPOINTINT32(x,y) TmPointInt32(FLOAT_TO_INT32(x),FLOAT_TO_INT32(y))
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #3
- // Constructor for Chipmunk dynamic body
- CMPartBodyDynamicDef(int id, TmPointInt32 pos, int mass, int density, bool noGravity=false, bool dampsRope=false, bool shouldSave=false, CMPartBodyDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #4
- // Constructor for Chipmunk rotary limit joint
- CMPartConstraintRotaryLimitJointDef(int id, int body1Id, int body2Id, int minAngle, int maxAngle, bool shouldSave=false, CMPartConstraintDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #5
- // Constructor for Chipmunk pivot joint
- CMPartConstraintPivotJointDef(int id, int body1Id, int body2Id, TmPointInt32 pivot, bool shouldSave=false, CMPartConstraintDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #6
- // Collision Group (used by chipmunk in conjunction with shapes)
- #define COL_GROUP_DEFAULT 0 // Collides with everything
- #define COL_GROUP_WALL 1
- #define COL_GROUP_GEAR 2
- #define COL_GROUP_TOASTER 3
- #define COL_GROUP_BOBBER 4
- #define COL_GROUP_FOCUS_LASER 5
- #define COL_GROUP_ARROW 6
- #define COL_GROUP_REMOTE_BOMB_PLUNGER -1
- // Collision Type (used by chipmunk in conjunction with shapes)
- #define COL_TYPE_DEFAULT 0
- #define COL_TYPE_BEGIN 1
- #define COL_TYPE_PRE 2
- #define COL_TYPE_POST 3
- #define COL_TYPE_SEPARATE 4
- #define COL_TYPE_SENSOR_BEGIN_SEPARATE 5
- #define COL_TYPE_SENSOR_PRE 6
- #define COL_TYPE_BEGIN_SEPARATE 7
- #define COL_TYPE_BEGIN_POST 8
- #define COL_TYPE_SENSOR_BEGIN 9
- #define COL_TYPE_BEGIN_PRE 10
- // Collision Layer (used by chipmunk in conjunction with shapes)
- #define COL_LAYER_ALL 0xffffffff
- #define COL_LAYER_SLED_FRONT 0x00000001 // Is part of default layers
- #define COL_LAYER_BOX_FRONT 0x00000002 // Doesn't collide with default (bit not set in default layers)
- #define COL_LAYER_LASER_IGNORE 0x00000002 // "
- #define COL_LAYER_GEAR 0x00000004 // "
- #define COL_LAYER_LASER_TRIGGER 0x00000008 // "
- #define COL_LAYER_TOAST 0x00000010 // "
- #define COL_LAYER_BOBBER 0x00000020 // "
- #define COL_LAYER_LASER_SPLITTER 0x00000040 // "
- #define COL_LAYER_DOG 0x00000080 // "
- #define COL_LAYER_FORCE_FIELD 0x00000100 // "
- #define COL_LAYER_LADDER 0x00000200 // Is part of default layers
- #define COL_LAYER_PROJECTION 0x80000000 // Only used by the part that is being projected from
- #define COL_LAYER_NON_DEFAULT (COL_LAYER_BOX_FRONT|COL_LAYER_LASER_IGNORE|COL_LAYER_GEAR|COL_LAYER_LASER_TRIGGER|COL_LAYER_TOAST|COL_LAYER_BOBBER|COL_LAYER_LASER_SPLITTER|COL_LAYER_DOG|COL_LAYER_FORCE_FIELD|COL_LAYER_PROJECTION)
- #define COL_LAYER_DEFAULT (COL_LAYER_ALL ^ COL_LAYER_NON_DEFAULT)
- #define COL_LAYER_TT (COL_LAYER_DEFAULT & ~COL_LAYER_SLED_FRONT) // Collides with all default layers except for the sled front layer
- #define COL_LAYER_LASER (COL_LAYER_ALL ^ (COL_LAYER_BOX_FRONT|COL_LAYER_GEAR|COL_LAYER_LASER_SPLITTER))
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #7
- struct CpShapeProperty
- {
- int e; // Coefficient of restitution. (elasticity)
- int uSliding; // Coefficient of friction. (sliding)
- int uRolling; // Coeffience of friction. (rolling)
- };
- #define SP_FIRST 0
- #define SP_VERY_BOUNCY_NONE 0
- #define SP_VERY_BOUNCY_SLICK 1
- #define SP_VERY_BOUNCY_NORMAL 2
- #define SP_VERY_BOUNCY_STICKY 3
- #define SP_VERY_BOUNCY_MED_STICKY 4
- #define SP_VERY_BOUNCY_VERY_STICKY 5
- #define SP_BOUNCY_NONE 6
- #define SP_BOUNCY_SLICK 7
- #define SP_BOUNCY_NORMAL 8
- #define SP_BOUNCY_STICKY 9
- #define SP_BOUNCY_MED_STICKY 10
- #define SP_BOUNCY_VERY_STICKY 11
- #define SP_NORMAL_NONE 12
- #define SP_NORMAL_SLICK 13
- #define SP_NORMAL_NORMAL 14
- #define SP_NORMAL_STICKY 15
- #define SP_NORMAL_MED_STICKY 16
- #define SP_NORMAL_VERY_STICKY 17
- #define SP_SOFT_NONE 18
- #define SP_SOFT_SLICK 19
- #define SP_SOFT_NORMAL 20
- #define SP_SOFT_STICKY 21
- #define SP_SOFT_MED_STICKY 22
- #define SP_SOFT_VERY_STICKY 23
- #define SP_VERY_SOFT_NONE 24
- #define SP_VERY_SOFT_SLICK 25
- #define SP_VERY_SOFT_NORMAL 26
- #define SP_VERY_SOFT_STICKY 27
- #define SP_VERY_SOFT_MED_STICKY 28
- #define SP_VERY_SOFT_VERY_STICKY 29
- #define SP_NONE_NONE 30
- #define SP_NONE_SLICK 31
- #define SP_NONE_NORMAL 32
- #define SP_NONE_STICKY 33
- #define SP_NONE_MED_STICKY 34
- #define SP_NONE_VERY_STICKY 35
- #define SP_MECHANICAL_TRAMPOLINE 36
- #define SP_BALL_BASEBALL 37
- #define SP_BALL_BASKETBALL 38
- #define SP_BALL_BILLIARD 39
- #define SP_BALL_BOWLING 40
- #define SP_BALL_IRONBALL 41
- #define SP_BALL_SOCCER 42
- #define SP_BALL_BOUNCYBALL 43
- #define SP_BALL_TENNIS 44
- #define SP_BALL_MARBLE 45
- #define SP_SENSOR 46
- #define SP_SCRIPT_NON_SENSOR 47
- #define SP_NORMAL_TRAMPOLINE 48
- #define SP_CONVEYOR_BELT 49
- #define SP_EGG 50
- #define SP_CREATURE_TREADS 51
- #define SP_ICE 52
- #define SP_SNOW 53
- #define SP_SLED 54
- #define SP_BLOCK 55
- #define SP_LAST 55
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #8
- struct CpShapeSfxProperty
- {
- int mSfxResIndex;
- int minVel; // Minimun velocity for sfx to be played
- char *desc;
- };
- // These are the actual sfx
- #define CM_SFX_BASEBALL 0
- #define CM_SFX_BASKETBALL 1
- #define CM_SFX_BOUNCY_BALL 2
- #define CM_SFX_BOWLING_BALL 3
- #define CM_SFX_CANNONBALL 4
- #define CM_SFX_CARDBOARD 5
- #define CM_SFX_MARBLE 6
- #define CM_SFX_SOCCER_BALL 7
- #define CM_SFX_TENNIS_BALL 8
- #define CM_SFX_WOOD_CRATE 9
- #define CM_SFX_NUM 10
- // These are the types of sfx surfaces that are mapped to actual sfx
- #define SP_SFX_FIRST 0
- #define SP_SFX_BASEBALL 0
- #define SP_SFX_BASKETBALL 1
- #define SP_SFX_BOUNCYBALL 2
- #define SP_SFX_BOWLING_BALL 3
- #define SP_SFX_CANNONBALL 4
- #define SP_SFX_CARDBOARD 5
- #define SP_SFX_MARBLE 6
- #define SP_SFX_SOCCER_BALL 7
- #define SP_SFX_TENNIS_BALL 8
- #define SP_SFX_WOOD_CRATE 9
- #define SP_SFX_HARD_SURFACE 10
- #define SP_SFX_SOFT_SURFACE 11
- #define SP_SFX_SILENT 12
- #define SP_SFX_LAST 12
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #9
- // Constructor for Chipmunk circle collision shape
- CMPartShapeCircleDef(int id, TmPointInt32 pos, int bodyId, int shapeProperty, int shapeSfxProperty, int radius, int group=COL_GROUP_DEFAULT, int collisionType=COL_TYPE_DEFAULT, int layers=COL_LAYER_DEFAULT, bool shouldSave=false, CMPartShapeDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #10
- // Constructor for Chipmunk polygon collision shape
- CMPartShapePolyDef(int id, TmPointInt32 pos, int bodyId, int shapeProperty, int shapeSfxProperty, cpVect *verts, int numVerts, int group=COL_GROUP_DEFAULT, int collisionType=COL_TYPE_DEFAULT, int layers=COL_LAYER_DEFAULT, bool shouldSave=false, CMPartShapeDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #11
- // Constructor for a Rope attachment
- CMPartAttachmentRopeDef(int id, TmPointInt32 pos, int bodyLinkId, bool shouldSave=false, CMPartAttachmentDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #12
- // Constructor for the sprites
- CMPartArtSpriteRectDef(int id, int layer, int posLinkId, int rotLinkId, const char *spriteName, int width, int height, int partAttachmentId=-1, TmPointInt32 pos=TmPointInt32(0,0), bool useFrameCache=false, bool usedForBb=true, bool shouldSave=false, bool shouldPostProcess=true, unsigned char opacity=255, CMPartArtDef *next=NULL);
- //--------------------------------------------------------------------------------------------------------------------------------------------------
- // Code Excerpt #13
- // These are the different Chipmunk routines that are called along with some of the surrounding code
- // Dynamic Body
- cpVect gravity = getGravity();
- tmInt64 moment = computeMomentOfInertia(part);
- mCpBody = cpBodyNew(mMass, moment, gravity);
- // Rotary Limit Constraint
- mCpConstraint = cpRotaryLimitJointNew(body1->mCpBody,body2->mCpBody,mMinAngle,mMaxAngle);
- // Pivot Joint Constraint
- mCpConstraint = cpPivotJointNew(body1->mCpBody,body2->mCpBody,cpv(pivot.x+part->mPos.x,pivot.y+part->mPos.y));
- // Circle Collision Shape
- mCpShape = cpCircleShapeNew(body->mCpBody, mRadius, cpv(pos.x,pos.y));
- mCpShape->shapeProperty = mShapeProperty;
- mCpShape->shapeSfxProperty = mShapeSfxProperty;
- mCpShape->e = defaultShapeProps[mShapeProperty].e;
- mCpShape->u = defaultShapeProps[mShapeProperty].uSliding;
- mCpShape->uRolling = defaultShapeProps[mShapeProperty].uRolling;
- mCpShape->group = mGroup;
- mCpShape->layers = mLayers;
- mCpShape->collision_type = mCollisionType;
- mCpShape->sensor = (mShapeProperty == SP_SENSOR);
- mCpShape->id = mId;
- // Polygon Collision Shape
- mCpShape = cpPolyShapeNew(body->mCpBody, numVerts, verts, cpv(pos.x,pos.y));
- mCpShape->shapeProperty = mShapeProperty;
- mCpShape->shapeSfxProperty = mShapeSfxProperty;
- mCpShape->e = defaultShapeProps[mShapeProperty].e;
- mCpShape->u = defaultShapeProps[mShapeProperty].uSliding;
- mCpShape->uRolling = defaultShapeProps[mShapeProperty].uRolling;
- mCpShape->group = mGroup;
- mCpShape->layers = mLayers;
- mCpShape->collision_type = mCollisionType;
- mCpShape->sensor = (mShapeProperty == SP_SENSOR);
- mCpShape->id = mId;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement