Ejemplo n.º 1
0
static VALUE
rb_cpCircleInitialize(VALUE self, VALUE body, VALUE radius, VALUE offset)
{
	cpCircleShape *circle = (cpCircleShape *)SHAPE(self);
	
	cpCircleShapeInit(circle, BODY(body), NUM2DBL(radius), *VGET(offset));
	circle->shape.data = (void *)self;
	circle->shape.collision_type = Qnil;

	rb_ivar_set(self, id_body, body);
	
	return self;
}
Ejemplo n.º 2
0
/**
 * Initialize a bubble that will bounce around. 
 * \param b The bubble to initialize.
 * \param x The x location of the bubble.
 * \param y The y location of the bubble.
 * \param v_x The x velocity of the bubble.
 * \param v_y The y velocity of the bubble.
 * \param r The radius of the bubble.
 * \param l The bubble's life. 
 */
struct bubble *bubble_init(struct bubble *b, double x, double y, double v_x,
                           double v_y, double r, uint8_t l) {
	cpBody *body = cpBodyInit(&b->body, r,
	                          cpMomentForCircle(r, 0, r, cpv(0, 0)));
	if (!body) {
		ERR_ERRNO();
		return 0;
	}
	cpShape *shape = cpCircleShapeInit(&b->shape, body, r, cpv(0,0));
	if (!shape) {
		cpBodyDestroy(body);
		ERR_ERRNO();
		return 0;
	}
	cpBodySetVel(body, cpv(v_x, v_y));
	cpBodySetPos(body, cpv(x, y));
	shape->e = 1.0;
	shape->data = b;
	shape->collision_type = BUBBLE;
	b->l = l;
	return b;
}
Ejemplo n.º 3
0
cpShape *
cpCircleShapeNew(cpBody *body, cpFloat radius, cpVect offset)
{
	return (cpShape *)cpCircleShapeInit(cpCircleShapeAlloc(), body, radius, offset);
}
Ejemplo n.º 4
0
// From cpShape.h
void wrCircleShapeInit(cpCircleShape *circle, cpBody *body,
                       cpVect *offset, cpFloat radius) {
    cpCircleShapeInit(circle, body, radius, *offset);
}