perlfangkuai.pl man page on Fedora
[printable version]
PERLTETRIS(1) User Contributed Perl Documentation PERLTETRIS(1)
NAME
tetris - A tetris game
SYNOPSIS
perl tetris.pl
CONFIGURATION
The configuration file should be the file with name ".tetris" under
HOME directory. Another option is using Tetris/Config.pm in any
directory of @INC.
Here is an example of configuration:
# -*- perl -*-
%Config = (
%Config,
'start_level' => 3,
'down_step' => 2,
'keybindings' => {
%{$Config{keybindings}},
ord('j') => \&move_left,
ord('l') => \&move_right,
ord('k') => \&rotate,
ord('n') => \&new_game,
}
);
push @$shapes, shape_from_string(<<SHAPE);
0 0 8 0 0 8 0 0 0 8 8 8 0 0 0 8
0 0 8 0 0 8 8 8 0 0 8 0 0 8 8 8
0 8 8 8 0 8 0 0 0 0 8 0 0 0 0 8
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SHAPE
push @$shapes, shape_from_string(<<SHAPE);
0 0 9 0 0 0 0 0 0 0 0 0 0 0 9 0
0 0 9 9 0 0 9 9 0 9 9 0 0 9 9 0
0 0 0 0 0 0 9 0 0 0 9 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
SHAPE
The key specification can get from this script:
use Gtk2::Gdk::Keysyms;
use Glib qw/TRUE FALSE/;
use Gtk2 -init;
my $window = Gtk2::Window->new ('toplevel');
$window->signal_connect (delete_event => sub { Gtk2->main_quit });
$window->signal_connect('key-press-event' => \&show_key);
my $label = Gtk2::Label->new();
$label->set_markup("<span foreground=\"blue\" size=\"x-large\">Type something on the keyboard!</span>");
$window->add ($label);
$window->show_all;
$window->set_position ('center-always');
Gtk2->main;
sub show_key {
my ($widget,$event,$parameter)= @_;
my $key_nr = $event->keyval();
foreach my $key (keys %Gtk2::Gdk::Keysyms) {
my $key_compare = $Gtk2::Gdk::Keysyms{$key};
if ($key_compare == $key_nr) {
print "'$key' => $key_nr,\n";
}
}
return FALSE;
}
Code to run after the GUI setup, add to code ref $after_load_function.
perl v5.14.1 2011-07-25 PERLTETRIS(1)
[top]
List of man pages available for Fedora
Copyright (c) for man pages and the logo by the respective OS vendor.
For those who want to learn more, the polarhome community provides shell access and support.
[legal]
[privacy]
[GNU]
[policy]
[cookies]
[netiquette]
[sponsors]
[FAQ]
Polarhome, production since 1999.
Member of Polarhome portal.
Based on Fawad Halim's script.
....................................................................
|
Vote for polarhome
|