Games-Minesweeper

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


0.5     
        - middle mousebutton support

0.4
        - moved from Audio::Play to SDL::Mixer
        - workaround for Gtk2::SimpleMenu problems

0.3
        - added sound support
        - load/save prefs

0.2   Wed Jul 16 14:31:53 2008
	- original version; created by h2xs 1.23 with options
		-X -c --skip-ppport -n Games::Minesweeper
        - initial release

TODO  view on Meta::CPAN

- middle mouse button support (0.5)

- audio support (done 0.3)

- save prefs (done 0.3)

- highscore support

- tile scaling support

lib/Games/Minesweeper.pm  view on Meta::CPAN

my ($smiley);
my ($field_width, $field_height, $field_mines) = (9, 9, 10);
my ($tile_width, $tile_height) = (16, 16);
my @mine_field;
my ($mine_count, $open);
my $audio = 0;
my $mc;
my $game_over = 0;
my $menu;

sub save_prefs () {
   my $hd = my_home File::HomeDir;
   my $rcfile = "$hd/.minesweeperrc\0";
   my $fh;
   open $fh, ">", $rcfile
      or do { warn "can't create $rcfile: $!\n"; return; };
   print $fh "$field_width $field_height $field_mines $audio\n";
}

sub load_prefs () {
   my $hd = my_home File::HomeDir;
   my $rcfile = "$hd/.minesweeperrc\0";
   my $fh;
   open $fh, "<", $rcfile
      or do { warn "can't open $rcfile: $!"; return; };
   my $line = <$fh>;
   if(my ($w,$h, $m, $a) = $line =~ m/^(\d+)\s+(\d+)\s+(\d+)\s+(\d+)/) {
      $audio = !!$a;
      $menu->get_widget ('/Game/Audio')->set_active ($audio);
      $w = 9 if $w < 9;

lib/Games/Minesweeper.pm  view on Meta::CPAN

                                           item_type => '<RadioItem>',
                                           groupid => 1,
                         },
                         Separator => { item_type => '<Separator>',
                         },
                         _Audio => { callback =>  sub { $audio = 0 + $menu->get_widget ('/Game/Audio')->get_active; },
                                     item_type => '<CheckItem>', 
                         },
                         Separator => { item_type => '<Separator>',
                         },
                         E_xit => { callback => sub { save_prefs; main_quit Gtk2; },
                                    accelerator => '<Alt>X',
                         },
                 ],
           },
           "_?" => { 
                 item_type => '<Branch>',
                 children => [
                     _About => { callback => sub { about_dialog; },
                                 accelerator => 'F1',
                               }

lib/Games/Minesweeper.pm  view on Meta::CPAN

      $hb->pack_start ($mc, 0, 0, 0);
      $hb->pack_start ($smiley, 1, 0, 0);
      $hb->pack_end ($l, 0, 0, 0);
      $vb->add ($hb);
      $vb->pack_start ($fixbox, 1, 0, 0);
      $f1->add ($vb);
      $v->add ($menu->{widget});
      $w->add_accel_group ($menu->{accel_group});
      $v->pack_start ($f1, 1, 0, 0);
      $w->add ($v);
      $w->signal_connect( destroy => sub { save_prefs; main_quit Gtk2; });
      $w->signal_connect( destroy => \&cleanup_cb);
      $d->realize;
      load_prefs;
      restart;
      $w;
}
1;



( run in 3.287 seconds using v1.01-cache-2.11-cpan-0bb4e1dffa6 )