本文整理汇总了C++中cpCircleShapeNew函数的典型用法代码示例。如果您正苦于以下问题:C++ cpCircleShapeNew函数的具体用法?C++ cpCircleShapeNew怎么用?C++ cpCircleShapeNew使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了cpCircleShapeNew函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: mkparticle
int mkparticle(particle_kind_t kind, cpVect pos, cpVect impulse, double energy)
{
particle_t* p = malloc(sizeof *p);
if(p == NULL) {
return -1; // bad malloc
}
cpSpace* space = current_space();
cpBody* body = cpBodyNew(energy / 1000.0, particle_moi);
cpShape* shape = cpCircleShapeNew(body, particle_r, cpvzero);
cpBodySetUserData(body, p);
cpShapeSetUserData(shape, p);
cpSpaceAddBody(space, body);
cpSpaceAddShape(space, shape);
*p = (particle_t){
.id = id,
.kind = kind,
.energy = energy,
.life = energy,
.body = body
};
HASH_ADD_INT(particles, id, p);
return id++;
}
开发者ID:niksaak,项目名称:dame,代码行数:25,代码来源:particle.c
示例2: l_physics_newCircleShape
int l_physics_newCircleShape(lua_State* state)
{
l_tools_checkUserDataPlusErrMsg(state, 1, "You must provide a space!");
l_physics_PhysicsData* physics = (l_physics_PhysicsData*)lua_touserdata(state, 1);
l_tools_checkUserDataPlusErrMsg(state, 2, "You must provide a body");
l_physics_Body* body = (l_physics_Body*)lua_touserdata(state, 2);
float radius = l_tools_toNumberOrError(state, 3);
cpVect offset = cpvzero;
offset.x = l_tools_toNumberOrError(state, 4);
offset.y = l_tools_toNumberOrError(state, 5);
moduleData.shape = (l_physics_Shape*)lua_newuserdata(state, sizeof(l_physics_Shape));
moduleData.shape->physics = malloc(sizeof(physics_PhysicsData));
moduleData.shape->physics = physics->physics;
moduleData.shape->shape = cpSpaceAddShape(physics->physics->space, cpCircleShapeNew(body->body, radius, offset));
lua_rawgeti(state, LUA_REGISTRYINDEX, moduleData.shapeMT);
lua_setmetatable(state, -2);
return 1;
}
开发者ID:dns,项目名称:CLove,代码行数:25,代码来源:physics.c
示例3: obj_create_autoreleased
WorldShape_t *worldShape_createCircle(vec2_t aCenter, GLMFloat aRadius)
{
WorldShape_t *out = obj_create_autoreleased(&Class_WorldShape);
out->cpShape = cpCircleShapeNew(NULL, aRadius, VEC2_TO_CPV(aCenter));
out->cpShape->data = out;
return out;
}
开发者ID:fjolnir,项目名称:Dynamo,代码行数:7,代码来源:world.c
示例4: erl_element
ETERM *body_set_collision_circle(ETERM *fromp, ETERM *argp) {
// get the args
ETERM *space_refp = erl_element(1, argp);
ETERM *idp = erl_element(2, argp);
ETERM *radiusp = erl_element(3, argp);
ETERM *collision_typep = erl_element(4, argp);
erlmunk_space *s;
int space_id = ERL_REF_NUMBER(space_refp);
HASH_FIND_INT(erlmunk_spaces, &space_id, s);
int body_id = ERL_INT_VALUE(idp);
erlmunk_body *b;
HASH_FIND_INT(s->bodies, &body_id, b);
if (b == NULL)
return NULL;
cpShape *shape = cpSpaceAddShape(s->space,
cpCircleShapeNew(b->body, ERL_FLOAT_VALUE(radiusp),
cpvzero));
cpShapeSetCollisionType(shape, ERL_INT_VALUE(collision_typep));
// DEBUGF(("body_set_collision_circle has succeeded"));
return NULL;
}
开发者ID:lrascao,项目名称:erlmunk,代码行数:26,代码来源:erlmunk_space.c
示例5: do_logic
static void
do_logic(game_state *state)
{
switch_state_data *data = state->data->switch_data;
if (data->mouse_down_last_step && state->game->mouse_down == false)
{
/* clicked and released; create a circle */
cpFloat radius = 15;
cpFloat mass = 10;
cpFloat moment = cpMomentForCircle(mass, 0, radius, cpvzero);
cpBody *ball = cpSpaceAddBody(data->space, cpBodyNew(mass, moment));
cpBodySetPos(ball, state->game->mouse_pos);
cpShape *ball_shape = cpSpaceAddShape(data->space,
cpCircleShapeNew(ball, radius, cpvzero));
cpShapeSetElasticity(ball_shape, 0.7);
cpShapeSetFriction(ball_shape, 0.7);
cpShapeSetLayers(ball_shape, L_PLAYER);
}
cpSpaceStep(data->space, TARGET_SEC_PER_FRAME);
data->mouse_down_last_step = state->game->mouse_down;
if (ent_switch_get_state(data->sw))
debug_puts("switch is on");
else
debug_puts("switch is off");
}
开发者ID:hdgarrood,项目名称:swinging-game,代码行数:31,代码来源:switch_state.c
示例6: cpBodyNew
void Ring::init(float backBoardLength, float groundLength, float ringSize, float e, float u)
{
/*
cpBody* backBoardBody;
cpShape* backBoardShape;
cpShape* groundShape;
cpShape* ring1Shape;
cpShape* ring2Shape;*/
int easy = -3; // 난이도 하락시키는 직선높이 차이
this->ringSize = ringSize;
backBoardBody = cpBodyNew(INFINITY, INFINITY);
setPosition(cpv(57, 250));
//backBoardBody->p = cpv(60, 250); // 50
//backBoardBody->p = cpv(60, 100);
backBoardShape = cpSegmentShapeNew(backBoardBody, cpv(0,0), cpv(0, backBoardLength), 1.f);
// CCLog("backboard shape %x", backBoardShape);
backBoardShape->e = BACKBOARD_E;
backBoardShape->u = u;
groundShape = cpSegmentShapeNew(backBoardBody, cpv(0,0), cpv(groundLength - 2.f, easy), 1.f);
// CCLog("ground shape %x", groundShape);
groundShape->e = e / 3.f;
groundShape->u = u;
subObject = cpSegmentShapeNew(backBoardBody, cpv(groundLength -2.f, easy), cpv(groundLength - 2.f, -10.f), 1.f); // 길다란 보조 장치, 자연스러운 공경로를 위해
// CCLog("subobject shape %x", subObject);
subObject->e = e;
subObject->u = u;
ring1Shape = cpCircleShapeNew(backBoardBody, 1.f, cpv(groundLength, easy ));
// CCLog("ring1 shape %x", ring1Shape);
ring1Shape->e = e / 3.f;
ring1Shape->u = u;
ring2Shape = cpCircleShapeNew(backBoardBody, 1.f, cpv(groundLength + ringSize, 0.f));
// CCLog("ring2 shape %x", ring2Shape);
ring2Shape->e = e;
ring2Shape->u = u;
ring3Shape = cpCircleShapeNew(backBoardBody, 1.f, cpv((2*groundLength + ringSize) / 2.f, 0.f));
// CCLog("ring3 shape %x", ring2Shape);
ring3Shape->e = e;
ring3Shape->u = u;
}
开发者ID:LitQoo,项目名称:SportsWorldCupOriginal,代码行数:45,代码来源:BS2Ring.cpp
示例7: MessageBox
void Player::Initialize(void)
{
// Load the texture
if (!(this->m_Texture = this->m_Hge->Texture_Load("data/particles.png")))
{
MessageBox(NULL, "Can't load particles.png texture.", "Error", MB_OK | MB_ICONERROR | MB_APPLMODAL);
this->m_Engine->Shutdown();
return;
}
// Create the player sprite
this->m_Sprite = new hgeSprite(this->m_Texture, 60, 40, 20, 20);
this->m_Sprite->SetColor(this->m_Color);
this->m_Sprite->SetHotSpot(10, 10);
// Create the particle sprite
this->m_ParticleSprite = new hgeSprite(this->m_Texture, 20, 20, 20, 20);
this->m_ParticleSprite->SetBlendMode(BLEND_COLORMUL | BLEND_ALPHAADD | BLEND_NOZWRITE);
this->m_ParticleSprite->SetHotSpot(10, 10);
// Create the particle system
this->m_ParticleSystem = new hgeParticleSystem("data/trail.psi", this->m_ParticleSprite);
this->m_ParticleSystem->Fire();
// Initialize the weapon slots
this->m_Weaponslots = (Weapon**) malloc(sizeof(Weapon*) * NUM_WEAPON_SLOTS);
for (int i = 0 ; i < NUM_WEAPON_SLOTS ; ++i)
{
this->m_Weaponslots[i] = 0;
}
this->m_Weaponslots[0] = new Neoshooter(this, this->m_Engine->GetWorld());
// Initialize physics
{
// Define moment
cpFloat moment = cpMomentForCircle(1, 0, 10, cpvzero);
// Fetch the physics space
cpSpace *space = this->m_Engine->GetWorld()->GetSpace();
// Add the physics body
this->m_Body = cpSpaceAddBody(space, cpBodyNew(1, moment));
cpBodySetPos(this->m_Body, this->m_Position);
// Add the physics shape
this->m_Shape = cpSpaceAddShape(space, cpCircleShapeNew(this->m_Body, 10, cpvzero));
this->m_Shape->data = this;
this->m_Shape->collision_type = COLLISION_TYPE_GO;
cpShapeSetElasticity(this->m_Shape, 1.0f);
cpShapeSetFriction(this->m_Shape, 0.7);
// Define the collision handlers for various types of collisions
cpSpaceAddCollisionHandler(space, COLLISION_TYPE_GO, COLLISION_TYPE_ACTIVATOR, BeginCollisionD, NULL, NULL, SeparateCollisionD, this);
cpSpaceAddCollisionHandler(space, COLLISION_TYPE_GO, COLLISION_TYPE_BULLET, BeginCollisionD, NULL, NULL, NULL, this);
}
}
开发者ID:ofx,项目名称:dr,代码行数:57,代码来源:Player.cpp
示例8: init
// Init is called by the demo code to set up the demo.
static cpSpace *
init(void)
{
// Create an infinite mass body to attach ground segments and other static geometry to.
// We won't be adding this body to the space, because we don't want it to be simulated at all.
// Adding bodies to the space simulates them. (fall under the influence of gravity, etc)
// We want the static body to stay right where it is at all times.
staticBody = cpBodyNew(INFINITY, INFINITY);
// Create a space, a space is a simulation world. It simulates the motions of rigid bodies,
// handles collisions between them, and simulates the joints between them.
space = cpSpaceNew();
// Lets set some parameters of the space:
// More iterations make the simulation more accurate but slower
space->iterations = 10;
// These parameters tune the efficiency of the collision detection.
// For more info: http://code.google.com/p/chipmunk-physics/wiki/cpSpace
cpSpaceResizeStaticHash(space, 30.0f, 1000);
cpSpaceResizeActiveHash(space, 30.0f, 1000);
// Give it some gravity
space->gravity = cpv(0, -100);
// Create A ground segment along the bottom of the screen
cpShape *ground = cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f);
// Set some parameters of the shape.
// For more info: http://code.google.com/p/chipmunk-physics/wiki/cpShape
ground->e = 1.0f; ground->u = 1.0f;
ground->layers = NOT_GRABABLE_MASK; // Used by the Demo mouse grabbing code
// Add the shape to the space as a static shape
// If a shape never changes position, add it as static so Chipmunk knows it only needs to
// calculate collision information for it once when it is added.
// Do not change the postion of a static shape after adding it.
cpSpaceAddStaticShape(space, ground);
// Add a moving circle object.
cpFloat radius = 15.0f;
cpFloat mass = 10.0f;
// This time we need to give a mass and moment of inertia when creating the circle.
cpBody *ballBody = cpBodyNew(mass, cpMomentForCircle(mass, 0.0f, radius, cpvzero));
// Set some parameters of the body:
// For more info: http://code.google.com/p/chipmunk-physics/wiki/cpBody
ballBody->p = cpv(0, -240 + radius+5);
// Add the body to the space so it will be simulated and move around.
cpSpaceAddBody(space, ballBody);
// Add a circle shape for the ball.
// Shapes are always defined relative to the center of gravity of the body they are attached to.
// When the body moves or rotates, the shape will move with it.
// Additionally, all of the cpSpaceAdd*() functions return the thing they added so you can create and add in one go.
cpShape *ballShape = cpSpaceAddShape(space, cpCircleShapeNew(ballBody, radius, cpvzero));
ballShape->e = 0.0f; ballShape->u = 0.9f;
return space;
}
开发者ID:18702515007xjy,项目名称:cocos2d,代码行数:57,代码来源:Simple.c
示例9: init
static cpSpace *
init(void)
{
ChipmunkDemoMessageString = "One way platforms are trivial in Chipmunk using a very simple collision callback.";
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 10);
cpSpaceSetGravity(space, cpv(0, -100));
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(-320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(320,-240), cpv(320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
// Add our one way segment
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-160,-100), cpv(160,-100), 10.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLISION_TYPE_ONE_WAY);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
// We'll use the data pointer for the OneWayPlatform struct
platformInstance.n = cpv(0, 1); // let objects pass upwards
cpShapeSetUserData(shape, &platformInstance);
// Add a ball to test it out
cpFloat radius = 15.0f;
body = cpSpaceAddBody(space, cpBodyNew(10.0f, cpMomentForCircle(10.0f, 0.0f, radius, cpvzero)));
cpBodySetPosition(body, cpv(0, -200));
cpBodySetVelocity(body, cpv(0, 170));
shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius, cpvzero));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.9f);
cpShapeSetCollisionType(shape, 2);
cpCollisionHandler *handler = cpSpaceAddWildcardHandler(space, COLLISION_TYPE_ONE_WAY);
handler->preSolveFunc = PreSolve;
return space;
}
开发者ID:00dazam,项目名称:FlappyBird-SpriteBuilder,代码行数:56,代码来源:OneWay.c
示例10: init
static cpSpace *
init(void)
{
cpSpace *space = cpSpaceNew();
space->iterations = 10;
space->gravity = cpv(0, -GRAVITY);
// space->sleepTimeThreshold = 1000;
space->enableContactGraph = cpTrue;
cpBody *body, *staticBody = space->staticBody;
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(-320,240), 0.0f));
shape->e = 1.0f; shape->u = 1.0f;
shape->layers = NOT_GRABABLE_MASK;
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(320,-240), cpv(320,240), 0.0f));
shape->e = 1.0f; shape->u = 1.0f;
shape->layers = NOT_GRABABLE_MASK;
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f));
shape->e = 1.0f; shape->u = 1.0f;
shape->layers = NOT_GRABABLE_MASK;
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,240), cpv(320,240), 0.0f));
shape->e = 1.0f; shape->u = 1.0f;
shape->layers = NOT_GRABABLE_MASK;
// Set up the player
cpFloat radius = 25.0f;
body = cpSpaceAddBody(space, cpBodyNew(1.0f, INFINITY));
body->p = cpv(0, -200);
body->velocity_func = playerUpdateVelocity;
playerBody = body;
shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius, cpvzero));
shape->e = 0.0f; shape->u = 0.0f;
shape->collision_type = 1;
playerShape = shape;
// Add some boxes to jump on
for(int i=0; i<6; i++){
for(int j=0; j<3; j++){
body = cpSpaceAddBody(space, cpBodyNew(4.0f, INFINITY));
body->p = cpv(100 + j*60, -200 + i*60);
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, 50, 50));
shape->e = 0.0f; shape->u = 0.7f;
}
}
return space;
}
开发者ID:1103785815,项目名称:wizardwar,代码行数:54,代码来源:Player.c
示例11: init
static cpSpace *
init(void)
{
ChipmunkDemoMessageString = "Sticky collisions using the cpArbiter data pointer.";
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 10);
cpSpaceSetGravity(space, cpv(0, -1000));
cpSpaceSetCollisionSlop(space, 2.0);
cpBody *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-340,-260), cpv(-340, 260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv( 340,-260), cpv( 340, 260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-340,-260), cpv( 340,-260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-340, 260), cpv( 340, 260), 20.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
cpShapeSetLayers(shape, NOT_GRABABLE_MASK);
for(int i=0; i<200; i++){
cpFloat mass = 0.15f;
cpFloat radius = 10.0f;
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForCircle(mass, 0.0f, radius, cpvzero)));
cpBodySetPos(body, cpv(cpflerp(-150.0f, 150.0f, frand()), cpflerp(-150.0f, 150.0f, frand())));
cpShape *shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius + STICK_SENSOR_THICKNESS, cpvzero));
cpShapeSetFriction(shape, 0.9f);
cpShapeSetCollisionType(shape, COLLIDE_STICK_SENSOR);
}
cpSpaceAddCollisionHandler(space, COLLIDE_STICK_SENSOR, COLLIDE_STICK_SENSOR, NULL, StickyPreSolve, NULL, StickySeparate, NULL);
return space;
}
开发者ID:Adefy,项目名称:AdefyiOS,代码行数:54,代码来源:Sticky.c
示例12: add_ball
static cpBody *
add_ball(cpVect pos)
{
cpBody *body = cpSpaceAddBody(space, cpBodyNew(1.0f, cpMomentForCircle(1.0f, 30, 0, cpvzero)));
body->p = pos;
cpShape *shape = cpSpaceAddShape(space, cpCircleShapeNew(body, 30, cpvzero));
shape->e = 0.0f; shape->u = 0.5f;
return body;
}
开发者ID:hit1983,项目名称:cocos2d-iphone,代码行数:11,代码来源:Pump.c
示例13: createBody
cpShape *cpSpaceSerializer::createCircle(TiXmlElement *elm)
{
cpShape *shape;
cpBody *body = createBody(elm);
cpFloat radius = createValue<cpFloat>("radius", elm);
cpVect offset = createPoint("offset", elm);
shape = cpCircleShapeNew(body, radius, offset);
return shape;
}
开发者ID:Ben-G,项目名称:MGWU-Chipmunk,代码行数:12,代码来源:cpSpaceSerializer.cpp
示例14: cpCircleShapeNew
void fff::kitty::Configure(){
fff::SetOriginByLua(game.vm, sprite, "kitty");
fff::SetOriginByLua(game.vm, flames[0], "flames");
flames[1].SetOrigin( flames[0].GetOrigin() );
flames[0].SetTexture(*game.textures["flames"]);
flames[1].SetTexture(*game.textures["flames"]);
flames[1].FlipX(true);
burst.SetBuffer(*game.soundbuffers["burstinflames"]);
shape = cpCircleShapeNew(body, fff::GetRadiusByLua(game.vm, "kitty"), (cpVect){0.f, 0.f} );
cpShapeSetUserData(shape, this);
cpShapeSetCollisionType(shape, fff::collisions::types::kitty);
}
开发者ID:teritriano,项目名称:ftf,代码行数:12,代码来源:kitty.cpp
示例15: add_ball
static cpBody *
add_ball(cpVect pos)
{
cpBody *body = cpSpaceAddBody(space, cpBodyNew(1.0f, cpMomentForCircle(1.0f, 30, 0, cpvzero)));
cpBodySetPos(body, pos);
cpShape *shape = cpSpaceAddShape(space, cpCircleShapeNew(body, 30, cpvzero));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.5f);
return body;
}
开发者ID:50Cubes,项目名称:ClusterFear,代码行数:12,代码来源:Pump.c
示例16: addBall
static cpBody *
addBall(cpVect pos, cpVect boxOffset)
{
cpFloat radius = 15.0f;
cpFloat mass = 1.0f;
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForCircle(mass, 0.0f, radius, cpvzero)));
body->p = cpvadd(pos, boxOffset);
cpShape *shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius, cpvzero));
shape->e = 0.0f; shape->u = 0.7f;
return body;
}
开发者ID:Avant-Flux,项目名称:chipmunk,代码行数:13,代码来源:Joints.c
示例17: price
Coin::Coin(int p) : price(p)
{
#if STATIC_OBJECT == 1
coinBody = cpBodyNewStatic();
#else
coinBody = cpBodyNew(INFINITY, INFINITY);
#endif
coinShape = cpCircleShapeNew(coinBody, COIN_R, cpv(0,0));
//CCLog("coin shape %x", coinShape);
coinShape->collision_type = GameScreen::COIN_COLLISION;
//coinBody->
coinBody->v = cpv(0, absV);
}
开发者ID:LitQoo,项目名称:SportsWorldCupOriginal,代码行数:13,代码来源:BS2Coin.cpp
示例18: Human
Human* World::addHuman(float size) {
Human* h=new Human();
cpShape* shape=cpCircleShapeNew(h->body,size,cpvzero);
shape->e=0.5;
shape->u=0.2;
h->shape=shape;
humans.push_back(h);
return h;
}
开发者ID:damir00,项目名称:zac,代码行数:13,代码来源:world.cpp
示例19: init
static cpSpace *
init(void)
{
cpSpace *space = cpSpaceNew();
cpSpaceSetIterations(space, 30);
cpSpaceSetGravity(space, cpv(0, -100));
cpSpaceSetSleepTimeThreshold(space, 0.5f);
cpSpaceSetCollisionSlop(space, 0.5f);
cpBody *body, *staticBody = cpSpaceGetStaticBody(space);
cpShape *shape;
// Create segments around the edge of the screen.
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(-320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(320,-240), cpv(320,240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
shape = cpSpaceAddShape(space, cpSegmentShapeNew(staticBody, cpv(-320,-240), cpv(320,-240), 0.0f));
cpShapeSetElasticity(shape, 1.0f);
cpShapeSetFriction(shape, 1.0f);
cpShapeSetFilter(shape, NOT_GRABBABLE_FILTER);
// Add lots of boxes.
for(int i=0; i<14; i++){
for(int j=0; j<=i; j++){
body = cpSpaceAddBody(space, cpBodyNew(1.0f, cpMomentForBox(1.0f, 30.0f, 30.0f)));
cpBodySetPosition(body, cpv(j*32 - i*16, 300 - i*32));
shape = cpSpaceAddShape(space, cpBoxShapeNew(body, 30.0f, 30.0f, 0.5f));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.8f);
}
}
// Add a ball to make things more interesting
cpFloat radius = 15.0f;
body = cpSpaceAddBody(space, cpBodyNew(10.0f, cpMomentForCircle(10.0f, 0.0f, radius, cpvzero)));
cpBodySetPosition(body, cpv(0, -240 + radius+5));
shape = cpSpaceAddShape(space, cpCircleShapeNew(body, radius, cpvzero));
cpShapeSetElasticity(shape, 0.0f);
cpShapeSetFriction(shape, 0.9f);
return space;
}
开发者ID:ConfusedReality,项目名称:pkg_game-engine_chipmunk,代码行数:51,代码来源:PyramidStack.c
示例20: init
static cpSpace *
init(void)
{
QUERY_START = cpvzero;
space = cpSpaceNew();
cpSpaceSetIterations(space, 5);
{ // add a fat segment
cpFloat mass = 1.0f;
cpFloat length = 100.0f;
cpVect a = cpv(-length/2.0f, 0.0f), b = cpv(length/2.0f, 0.0f);
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForSegment(mass, a, b)));
cpBodySetPos(body, cpv(0.0f, 100.0f));
cpSpaceAddShape(space, cpSegmentShapeNew(body, a, b, 20.0f));
}
{ // add a static segment
cpSpaceAddShape(space, cpSegmentShapeNew(cpSpaceGetStaticBody(space), cpv(0, 300), cpv(300, 0), 0.0f));
}
{ // add a pentagon
cpFloat mass = 1.0f;
const int NUM_VERTS = 5;
cpVect verts[NUM_VERTS];
for(int i=0; i<NUM_VERTS; i++){
cpFloat angle = -2*M_PI*i/((cpFloat) NUM_VERTS);
verts[i] = cpv(30*cos(angle), 30*sin(angle));
}
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForPoly(mass, NUM_VERTS, verts, cpvzero)));
cpBodySetPos(body, cpv(50.0f, 50.0f));
cpSpaceAddShape(space, cpPolyShapeNew(body, NUM_VERTS, verts, cpvzero));
}
{ // add a circle
cpFloat mass = 1.0f;
cpFloat r = 20.0f;
cpBody *body = cpSpaceAddBody(space, cpBodyNew(mass, cpMomentForCircle(mass, 0.0f, r, cpvzero)));
cpBodySetPos(body, cpv(100.0f, 100.0f));
cpSpaceAddShape(space, cpCircleShapeNew(body, r, cpvzero));
}
return space;
}
开发者ID:50Cubes,项目名称:ClusterFear,代码行数:51,代码来源:Query.c
注:本文中的cpCircleShapeNew函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论