Box2D

 view release on metacpan or  search on metacpan

examples/breakable.pl  view on Meta::CPAN

# This example is a port of Breakable.h from the Box2D Testbed. Click
# the window to create a breakable.
use strict;
use warnings;
use Box2D;
use SDL;
use SDL::Video;
use SDL::Events qw(:type);
use SDLx::App;
use Math::Trig qw(:pi);

package Breakable;
use Moose;

use List::Util qw(max);
use namespace::autoclean;

# Initial coordinates, angle and size
has [qw( x y angle w h )] => (
    is       => 'ro',
    isa      => 'Num',
    required => 1,
);

has color => (
    is      => 'ro',
    isa     => 'ArrayRef[Int]',
    default => sub { [ 255, 255, 255 ] },
);

has world => (
    is       => 'ro',
    isa      => 'Box2D::b2World',
    required => 1,
);

has body1 => (
    is      => 'ro',
    isa     => 'Box2D::b2Body',
    lazy    => 1,
    builder => '_build_body1',
);

# Used after the break
has body2 => (
    is  => 'rw',
    isa => 'Box2D::b2Body',
);

has velocity => (
    is      => 'rw',
    isa     => 'Box2D::b2Vec2',
    default => sub { Box2D::b2Vec2->new( 0.0, 0.0 ) },
);

has angularVelocity => (
    is      => 'rw',
    isa     => 'Num',
    default => 0.0,
);

has shape1 => (
    is      => 'ro',
    isa     => 'Box2D::b2PolygonShape',
    lazy    => 1,
    builder => '_build_shape1',
);

has shape2 => (
    is      => 'ro',
    isa     => 'Box2D::b2PolygonShape',
    lazy    => 1,
    builder => '_build_shape2',
);

has piece1 => (



( run in 1.415 second using v1.01-cache-2.11-cpan-39bf76dae61 )