Games-GUI-Battleship

 view release on metacpan or  search on metacpan

lib/Games/GUI/Battleship.pm  view on Meta::CPAN

    return;
}

sub set_sweep_speed ( $self, $speed ) {
    return unless exists $SWEEP_PERIODS{$speed};
    $self->{radar_sweep_speed} = $speed;
    $self->update_radar_menu;
    return;
}

sub update_radar_menu ($self) {
    return unless $self->{window} && $self->{window}->menu;
    my $menu = $self->{window}->menu;

    if ( $self->{radar_sweep_enabled} ) {
        $menu->check('sweep_toggle');
    }
    else {
        $menu->uncheck('sweep_toggle');
    }

lib/Games/GUI/Battleship.pm  view on Meta::CPAN

sub rotate_placement_ship ($self) {
    $self->{placement_dir} = ( $self->{placement_dir} eq 'H' ) ? 'V' : 'H';
    if ( $self->{ghost_ship} ) {
        $self->{ghost_ship}->set_dir( $self->{placement_dir} );
        $self->{ghost_valid} =
          $self->{player_board}->can_place_ship( $self->{ghost_ship} );
    }
    return;
}

sub update_placement_ghost ( $self, $col, $row ) {
    if ( !defined $col || !defined $row ) {
        $self->{ghost_ship}  = undef;
        $self->{ghost_valid} = 0;
        return;
    }

    my $type =
      $Games::GUI::Battleship::Ship::FLEET_ORDER[ $self->{placement_idx} ];
    return unless $type;

lib/Games/GUI/Battleship/Renderer.pm  view on Meta::CPAN

}

sub player_origin ($self) {
    return @{ $self->{player_origin} };
}

sub opponent_origin ($self) {
    return @{ $self->{opponent_origin} };
}

sub update_layout ( $self, $vp_w, $vp_h ) {
    $self->{vp_w} = $vp_w;
    $self->{vp_h} = $vp_h;

    my $w_factor = $vp_w / 940;

    # Header height scales smoothly with window height and width
    my $header_h = int( 72 + ( $vp_h - 600 ) * 0.05 + ( $vp_w - 900 ) * 0.035 );
    $header_h = max( 74, min( 170, $header_h ) );

    # Footer height scales with height and width



( run in 1.086 second using v1.01-cache-2.11-cpan-f1796dc4e6b )