Games-GUI-Battleship

 view release on metacpan or  search on metacpan

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

package Games::GUI::Battleship;

use v5.38;
use experimental 'signatures';
use feature 'try';
no warnings 'experimental::try';
use Carp qw(croak);

use Prima qw(Application MsgBox Cairo);
use Cairo;
use Time::HiRes qw(time);

use Games::GUI::Battleship::Ship;
use Games::GUI::Battleship::Board;
use Games::GUI::Battleship::Renderer;
use Games::GUI::Battleship::AI;

=pod

=head1 NAME

Games::GUI::Battleship - Play a game of Battleship through a GUI

=head1 VERSION

Version 1.0

=head1 SYNOPSIS

    battleship
    
=head1 DESCRIPTION

Play a game of Battleship against a computer opponent. It uses L<Prima> for the GUI and L<Cairo> for the graphics.

=for HTML <p>
<img src="https://github.com/mjohnson108/p5-Games-GUI-Battleship/blob/e80cfa124775dada0a0cefe168e3b980cfb3d7e4/examples/POD/battleship_screenshot.png?raw=true" alt="Screenshot of Battleship program" width="650">
</p>

=head2 Menus

=head3 Game

The I<New Game> option will start a new game at a given difficulty level.

I<Randomize Fleet> will reset any ongoing game and deploy your vessels in a random layout, bypassing the need for manually placing the vessels.

I<Reset Fleet> will reset the game.

I<Exit> exits the game.

=head3 Difficulty

Select the level of difficulty. There are three different settings, each backed by an "AI" with different play strategies.

=head3 Radar

Use I<Radar Sweep Effect> to toggle the scanning radar visual effect.

I<Speed> gives options on the speed of the radar sweep.

=head3 Help

I<How to Play> shows a short instructions dialog.

=head3 About 

shows a small about dialog.
    
=head2 How to play

Place vessels by clicking the mouse in the left grid. The game will highlight where the vessel will be placed. Use the space bar, "R" key, or right-click the mouse to rotate the vessel before placement.

Once all vessels are placed, click empty cells in the right grid to launch attacks on the opponent. The cell will record a hit or miss icon. Take turns trading attacks with the computer opponent until there is a winner.

=head1 SEE ALSO

L<Prima>

L<Logic::Relational>

=head1 AUTHOR

Matt Johnson, C<< <mjohnson at affectivesilicon.com> >>

=head1 AI

This game was developed with assistance from Gemini Flash 3.8.

=head1 LICENSE AND COPYRIGHT

This software is Copyright (c) 2026 by Matt Johnson.

This is free software, licensed under:

  The GNU General Public License, Version 3, June 2007

    
=cut



( run in 1.017 second using v1.01-cache-2.11-cpan-364913b4093 )