1 void SmashPcItem::CreatePhysicsObjects(void) 2 { 3 if (mbPhysical) 4 { 5 cpFloat Inertia; 6 mpBody = cpBodyNew(500.0f, 500.0f); 7 cpBodySetPos(mpBody, mItemInfo.Location); 8 9 mpBody->v = cpvzero; 10 11 /* teleporter doesn't spin */ 12 mpBody->w = 2.0f; 13 14 mpShape = cpCircleShapeNew(mpBody, 15 (cpFloat)((mItemInfo.pImage->GetWidth() + mItemInfo.pImage->GetHeight())/4), 16 cpvzero); 17 18 Inertia = cpMomentForCircle(5.0f, 0.0f, 19 (cpFloat)((mItemInfo.pImage->GetWidth() + mItemInfo.pImage->GetHeight())/4), 20 cpvzero); 21 22 cpBodySetMoment(mpBody, Inertia); 23 24 mpShape->e = 0.0f; // not elatics, no bouncing 25 mpShape->u = 1.0f; // 0.0 is frictionless 26 mpShape->collision_type = ITEM_COL_TYPE; 27 mpShape->layers = MAP_ITEM_LAYER; 28 mpShape->data = static_cast<void *>(this); 29 30 cpSpaceAddBody(mpSpace, mpBody); 31 cpSpaceAddShape(mpSpace, mpShape); 32 33 // Create Collision handler here, only player notifies the item 34 // data can be NULL since we have class stored in Shape 35 cpSpaceAddCollisionHandler(mpSpace, ITEM_COL_TYPE, PLAYER_COL_TYPE, SmashPcItem::PlayerCollision, NULL, NULL, NULL, NULL); 36 } 37 }