| Class | Joyau::Drawable |
| In: |
Drawable.cpp
|
| Parent: | Object |
Returns a Drawable’s bounding rect.
/*
Returns a Drawable's bounding rect.
*/
VALUE Drawable_boundingRect(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
Rect rect = ref.boundingRect();
return createObject(getClass("Rect"), rect);
}
Cancels all the moves done since the last call to clear move. May be called once a collision occur.
/*
Cancels all the moves done since the last call to clear move.
May be called once a collision occur.
*/
VALUE Drawable_cancelMove(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
ref.cancelMove();
return Qnil;
}
Clears all the moves done since the last call to this function. They can no longer be cancelled.
/*
Clears all the moves done since the last call to this function. They can no
longer be cancelled.
*/
VALUE Drawable_clearMove(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
ref.clearMove();
return Qnil;
}
Returns whether two items collide.
/*
call-seq: collide(item)
collide?(item)
Returns whether two items collide.
*/
VALUE Drawable_collide(VALUE self, VALUE item)
{
if (!rb_obj_is_kind_of(item, getClass("Drawable")))
rb_raise(rb_eTypeError, "Can't convert %s into Joyau::Drawable",
rb_obj_classname(item));
Drawable &ref = getRef<Drawable>(self);
RubyDrawable val(item);
if (ref.collide(val))
return Qtrue;
return Qfalse;
}
Draws the drawable, and clear its moves.
/*
Draws the drawable, and clear its moves.
*/
VALUE Drawable_draw(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
ref.clearMove(); // So, we don't have to change the draw methods
ref.draw();
return Qnil;
}
Returns a drawable’s height.
/*
Returns a drawable's height.
*/
VALUE Drawable_getH(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
return INT2FIX(ref.getH());
}
Returns a drawable’s width.
/*
Returns a drawable's width.
*/
VALUE Drawable_getW(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
return INT2FIX(ref.getW());
}
Returns a drawable’s abscissa.
/*
Returns a drawable's abscissa.
*/
VALUE Drawable_getX(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
return INT2FIX(ref.getX());
}
Returns a drawable’s ordinate.
/*
Returns a drawable's ordinate.
*/
VALUE Drawable_getY(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
return INT2FIX(ref.getY());
}
Returns whether a point is on the drawable.
/*
call-seq: isOn(x, y)
is_on?(x, y)
Returns whether a point is on the drawable.
*/
VALUE Drawable_isOn(VALUE self, VALUE x, VALUE y)
{
Drawable &ref = getRef<Drawable>(self);
int _x = FIX2INT(x);
int _y = FIX2INT(y);
if (ref.isOn(_x, _y))
return Qtrue;
return Qfalse;
}
Moves a drawable.
/*
call-seq: move(x, y)
Moves a drawable.
*/
VALUE Drawable_move(VALUE self, VALUE x, VALUE y)
{
Drawable &ref = getRef<Drawable>(self);
int _x = FIX2INT(x);
int _y = FIX2INT(y);
ref.move(_x, _y);
return Qnil;
}
Returns the difference between the actual abscissa, and the one when clearMove was called.
/*
Returns the difference between the actual abscissa, and the one when
clearMove was called.
*/
VALUE Drawable_movedX(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
return INT2FIX(ref.getMovedX());
}
Returns the difference between the actual ordinate, and the one when clearMove was called.
/*
Returns the difference between the actual ordinate, and the one when
clearMove was called.
*/
VALUE Drawable_movedY(VALUE self)
{
Drawable &ref = getRef<Drawable>(self);
return INT2FIX(ref.getMovedY());
}
Sets a drawable’s position.
/*
call-seq: pos=(p)
Sets a drawable's position.
*/
VALUE Drawable_setPoint(VALUE self, VALUE p)
{
if (!rb_obj_is_kind_of(p, getClass("Point")))
rb_raise(rb_eTypeError, "Can't convert %s into Joyau::Point",
rb_obj_classname(p));
Drawable &ref = getRef<Drawable>(self);
Point &pRef = getRef<Point>(p);
ref.setPos(pRef);
return p;
}
Sets a drawable’s position.
/*
call-seq: setPos(x, y)
Sets a drawable's position.
*/
VALUE Drawable_setPos(VALUE self, VALUE x, VALUE y)
{
Drawable &ref = getRef<Drawable>(self);
int _x = FIX2INT(x);
int _y = FIX2INT(y);
ref.setPos(_x, _y);
return Qnil;
}