Game-Kezboard
view release on metacpan or search on metacpan
sub MOVE_NOP () { 2 } # a move that should not cause delays
# game state - picking cards, or are the cards being run?
sub STATE_PICK () { 0 }
sub STATE_BRUN () { 1 }
sub HERO () { 0 } # where in @animates the player lives (also ID)
sub GOAL () { 1 }
sub SCRAM () { 2 } # animate IDs
sub BOMB () { 3 }
sub XX () { 0 } # points, and @animates index slots
sub YY () { 1 }
sub IX () { 2 } # animate inertia
sub IY () { 3 }
sub ORIENT () { 4 } # animate orientation (if any)
sub SPRITE () { 5 } # array for sprite based on orientation
sub ID () { 6 }
sub NAME () { 7 }
sub DEAD () { 8 }
my $cards_played = ~0; # score (lower is better)
my @collisions;
$collisions[HERO][GOAL] = \&collide_hero_goal;
$collisions[HERO][SCRAM] = \&collide_hero_scram;
$collisions[HERO][BOMB] = \&collide_hero_bomb;
$collisions[GOAL][HERO] = \&collide_hero_goal;
$collisions[GOAL][SCRAM] = \&collide_gate_scram;
my $clicks; # quadtree foo
my @headings = (
[ 1, 0 ], # x,y vector
[ 0, -1 ],
[ -1, 0 ],
[ 0, 1 ],
push @animates,
make_animate( SCRAM, '??', random_point_unique(), 0, [$scrami] );
place_animate( $animates[-1] );
}
}
if ( $level >= 4 ) {
my $n = 29;
$n = 17 if $level == 5;
for ( 1 .. $n ) {
push @animates,
make_animate( BOMB, 'Bomb', random_point_unique(), 0, [$bombi] );
place_animate( $animates[-1] );
}
}
# NOTE you could instead first collect everything and shuffle here
# so that a new level (or a restart) starts from a clean deck
$deck->collect( 'discard', qw(board player) );
deal_cards();
describe_animate( $animates[HERO] );
$state = STATE_PICK;
( run in 0.410 second using v1.01-cache-2.11-cpan-e9daa2b36ef )