├── CHANGES ├── MANIFEST ├── README ├── asciiquarium └── gpl.txt /CHANGES: -------------------------------------------------------------------------------- 1 | Changes for Asciiquarium 2 | 3 | Version 1.1 4 | - Add new fish species 5 | 6 | Version 1.0 7 | - Initial public release 8 | -------------------------------------------------------------------------------- /MANIFEST: -------------------------------------------------------------------------------- 1 | CHANGES 2 | MANIFEST 3 | README 4 | asciiquarium 5 | gpl.txt 6 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | Asciiquarium v1.1 2 | by Kirk Baucom 3 | http://www.robobunny.com 4 | 5 | Asciiquarium is an aquarium/sea animation in ASCII art. 6 | 7 | Installation 8 | ------------ 9 | 10 | Asciiquarium is a single perl script, so all you have to do is make sure 11 | it's executable and put it somewhere convenient, like /usr/local/bin or 12 | /usr/local/games. 13 | 14 | Ubuntu 15 | ------ 16 | 17 | Out-of-the-box ubuntu doesn't satisfy the Requirements below, so 18 | here's how to get them: 19 | 1) Get perl's curses package which is available from apt: 20 | sudo apt-get install libcurses-perl 21 | 2) Run 22 | cpan 23 | at the shell. Agree to the defaults for everything. 24 | To leave cpan, type 25 | quit 26 | 3) Type 27 | sudo cpan Term::Animation 28 | 29 | Requirements 30 | ------------ 31 | 32 | You must have the Term::Animation module, which you can get from 33 | http://www.cpan.org. The Term::Animation module also requires the Curses 34 | module, which you can also get from CPAN. This program will only run on 35 | platforms that have a Curses library (so it won't work on Windows, but 36 | you might get it to run under cygwin). 37 | 38 | Usage 39 | ----- 40 | 41 | Command line arguments: 42 | -c "classic" mode, only show species from Asciiquarium 1.0 43 | 44 | While running: 45 | q quit 46 | r redraw (will recreate all entities) 47 | p toggle pause 48 | 49 | Contributors 50 | ------------ 51 | 52 | New fish species backported from the Android live wallpaper and 53 | other minor improvements by Claudio Matsuoka. 54 | 55 | Pretty much all of the ASCII art was done by Joan Stark: 56 | http://www.geocities.com/SoHo/7373/ 57 | 58 | Anything that she didn't do, I don't have a source for. 59 | -------------------------------------------------------------------------------- /asciiquarium: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env perl 2 | # 3 | ############################################################################# 4 | # Asciiquarium - An aquarium animation in ASCII art 5 | # 6 | # This program displays an aquarium/sea animation using ASCII art. 7 | # It requires the module Term::Animation, which requires Curses. You 8 | # can get both modules from http://search.cpan.org. Asciiquarium will 9 | # only run on platforms with a curses library, so Windows is not supported. 10 | # 11 | # The current version of this program is available at: 12 | # 13 | # http://robobunny.com/projects/asciiquarium 14 | # 15 | ############################################################################# 16 | # Author: 17 | # Kirk Baucom 18 | # 19 | # Contributors: 20 | # Joan Stark: http://www.geocities.com/SoHo/7373/ 21 | # most of the ASCII art 22 | # 23 | # Claudio Matsuoka 24 | # improved marine biodiversity (backported from the Asciiquarium Live 25 | # Wallaper for Android) 26 | # https://market.android.com/details?id=org.helllabs.android.asciiquarium 27 | # 28 | # License: 29 | # 30 | # Copyright (C) 2003 Kirk Baucom (kbaucom@schizoid.com) 31 | # 32 | # This program is free software; you can redistribute it and/or 33 | # modify it under the terms of the GNU General Public License 34 | # as published by the Free Software Foundation; either version 2 35 | # of the License, or (at your option) any later version. 36 | # 37 | # This program is distributed in the hope that it will be useful, 38 | # but WITHOUT ANY WARRANTY; without even the implied warranty of 39 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 40 | # GNU General Public License for more details. 41 | # 42 | # You should have received a copy of the GNU General Public License 43 | # along with this program; if not, write to the Free Software 44 | # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 45 | ############################################################################# 46 | 47 | use Term::Animation 2.0; 48 | use Term::Animation::Entity; 49 | use Data::Dumper; 50 | use Curses; 51 | use Getopt::Std; 52 | use strict; 53 | use warnings; 54 | 55 | my $version = "1.1"; 56 | my $new_fish = 1; 57 | my $new_monster = 1; 58 | 59 | our $opt_c; 60 | getopts('c'); 61 | 62 | if ($opt_c) { # 'classic' mode 63 | $new_fish = 0; 64 | $new_monster = 0; 65 | } 66 | 67 | my @random_objects = init_random_objects(); 68 | 69 | # the Z depth at which certain items occur 70 | my %depth = ( 71 | # no gui yet 72 | guiText => 0, 73 | gui => 1, 74 | 75 | # under water 76 | shark => 2, 77 | fish_start => 3, 78 | fish_end => 20, 79 | seaweed => 21, 80 | castle => 22, 81 | 82 | # waterline 83 | water_line3 => 2, 84 | water_gap3 => 3, 85 | water_line2 => 4, 86 | water_gap2 => 5, 87 | water_line1 => 6, 88 | water_gap1 => 7, 89 | water_line0 => 8, 90 | water_gap0 => 9, 91 | ); 92 | 93 | main(); 94 | 95 | ####################### MAIN ####################### 96 | 97 | sub main { 98 | 99 | my $anim = Term::Animation->new(); 100 | 101 | # set the wait time for getch 102 | halfdelay(1); 103 | #nodelay(1); 104 | 105 | $anim->color(1); 106 | 107 | my $start_time = time; 108 | my $paused = 0; 109 | while(1) { 110 | 111 | add_environment($anim); 112 | add_castle($anim); 113 | add_all_seaweed($anim); 114 | add_all_fish($anim); 115 | random_object(undef, $anim); 116 | 117 | $anim->redraw_screen(); 118 | 119 | my $nexttime = 0; 120 | 121 | while(1) { 122 | my $in = lc(getch()); 123 | 124 | if ( $in eq 'q' ) { quit(); } # Exit 125 | elsif( $in eq 'r' ) { last; } # Redraw (will recreate all objects) 126 | elsif( $in eq 'p' ) { $paused = !$paused; } 127 | 128 | $anim->animate() unless($paused); 129 | } 130 | $anim->update_term_size(); 131 | $anim->remove_all_entities(); 132 | 133 | } 134 | 135 | } 136 | 137 | sub add_environment { 138 | my ($anim) = @_; 139 | 140 | my @water_line_segment = ( 141 | q{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}, 142 | q{^^^^ ^^^ ^^^ ^^^ ^^^^ }, 143 | q{^^^^ ^^^^ ^^^ ^^ }, 144 | q{^^ ^^^^ ^^^ ^^^^^^ } 145 | ); 146 | 147 | # tile the segments so they stretch across the screen 148 | my $segment_size = length($water_line_segment[0]); 149 | my $segment_repeat = int($anim->width()/$segment_size) + 1; 150 | foreach my $i (0..$#water_line_segment) { 151 | $water_line_segment[$i] = $water_line_segment[$i]x$segment_repeat; 152 | } 153 | 154 | foreach my $i (0..$#water_line_segment) { 155 | $anim->new_entity( 156 | name => "water_seg_$i", 157 | type => "waterline", 158 | shape => $water_line_segment[$i], 159 | position => [ 0, $i+5, $depth{'water_line' . $i} ], 160 | default_color => 'cyan', 161 | depth => 22, 162 | physical => 1, 163 | ); 164 | } 165 | } 166 | 167 | sub add_castle { 168 | my ($anim) = @_; 169 | my $castle_image = q{ 170 | T~~ 171 | | 172 | /^\ 173 | / \ 174 | _ _ _ / \ _ _ _ 175 | [ ]_[ ]_[ ]/ _ _ \[ ]_[ ]_[ ] 176 | |_=__-_ =_|_[ ]_[ ]_|_=-___-__| 177 | | _- = | =_ = _ |= _= | 178 | |= -[] |- = _ = |_-=_[] | 179 | | =_ |= - ___ | =_ = | 180 | |= []- |- /| |\ |=_ =[] | 181 | |- =_ | =| | | | |- = - | 182 | |_______|__|_|_|_|__|_______| 183 | }; 184 | 185 | my $castle_mask = q{ 186 | RR 187 | 188 | yyy 189 | y y 190 | y y 191 | y y 192 | 193 | 194 | 195 | yyy 196 | yy yy 197 | y y y y 198 | yyyyyyy 199 | }; 200 | 201 | $anim->new_entity( 202 | name => "castle", 203 | shape => $castle_image, 204 | color => $castle_mask, 205 | position => [ $anim->width()-32, $anim->height()-13, $depth{'castle'} ], 206 | default_color => 'BLACK', 207 | ); 208 | } 209 | 210 | sub add_all_seaweed { 211 | my ($anim) = @_; 212 | # figure out how many seaweed to add by the width of the screen 213 | my $seaweed_count = int($anim->width() / 15); 214 | for (1..$seaweed_count) { 215 | add_seaweed(undef, $anim); 216 | } 217 | } 218 | 219 | sub add_seaweed { 220 | my ($old_seaweed, $anim) = @_; 221 | my @seaweed_image = ('',''); 222 | my $height = int(rand(4)) + 3; 223 | for my $i (1..$height) { 224 | my $left_side = $i%2; 225 | my $right_side = !$left_side; 226 | $seaweed_image[$left_side] .= "(\n"; 227 | $seaweed_image[$right_side] .= " )\n"; 228 | } 229 | my $x = int(rand($anim->width()-2)) + 1; 230 | my $y = $anim->height() - $height; 231 | my $anim_speed = rand(.05) + .25; 232 | $anim->new_entity( 233 | name => 'seaweed' . rand(1), 234 | shape => \@seaweed_image, 235 | position => [ $x, $y, $depth{'seaweed'} ], 236 | callback_args => [ 0, 0, 0, $anim_speed ], 237 | die_time => time() + int(rand(4*60)) + (8*60), # seaweed lives for 8 to 12 minutes 238 | death_cb => \&add_seaweed, 239 | default_color => 'green', 240 | ); 241 | } 242 | 243 | # add an air bubble to a fish 244 | sub add_bubble { 245 | my ($fish, $anim) = @_; 246 | 247 | my $cb_args = $fish->callback_args(); 248 | my @fish_size = $fish->size(); 249 | my @fish_pos = $fish->position(); 250 | my @bubble_pos = @fish_pos; 251 | 252 | # moving right 253 | if($cb_args->[0] > 0) { 254 | $bubble_pos[0] += $fish_size[0]; 255 | } 256 | $bubble_pos[1] += int($fish_size[1] / 2); 257 | # bubble always goes on top of the fish 258 | $bubble_pos[2]--; 259 | 260 | $anim->new_entity( 261 | shape => [ '.', 'o', 'O', 'O', 'O' ], 262 | type => 'bubble', 263 | position => \@bubble_pos, 264 | callback_args => [ 0, -1, 0, .1 ], 265 | die_offscreen => 1, 266 | physical => 1, 267 | coll_handler => \&bubble_collision, 268 | default_color => 'CYAN', 269 | ); 270 | } 271 | 272 | sub bubble_collision { 273 | my ($bubble, $anim) = @_; 274 | my $collisions = $bubble->collisions(); 275 | foreach my $col_obj (@{$collisions}) { 276 | if($col_obj->type eq 'waterline') { 277 | $bubble->kill(); 278 | last; 279 | } 280 | } 281 | 282 | } 283 | 284 | sub add_all_fish { 285 | my ($anim) = @_; 286 | # figure out how many fish to add by the size of the screen, 287 | # minus the stuff above the water 288 | my $screen_size = ($anim->height() - 9) * $anim->width(); 289 | my $fish_count = int($screen_size / 350); 290 | for (1..$fish_count) { 291 | add_fish(undef, $anim); 292 | } 293 | } 294 | 295 | sub add_fish { 296 | my @parm = @_; 297 | 298 | if ($new_fish) { 299 | if (int(rand(12)) > 8) { 300 | add_new_fish(@parm); 301 | } else { 302 | add_old_fish(@parm); 303 | } 304 | } else { 305 | add_old_fish(@parm); 306 | } 307 | } 308 | 309 | sub add_new_fish { 310 | my ($old_fish, $anim) = @_; 311 | my @fish_image = ( 312 | 313 | q{ 314 | \\ 315 | / \\ 316 | >=_('> 317 | \\_/ 318 | / 319 | }, 320 | q{ 321 | 1 322 | 1 1 323 | 663745 324 | 111 325 | 3 326 | }, 327 | q{ 328 | / 329 | / \\ 330 | <')_=< 331 | \\_/ 332 | \\ 333 | }, 334 | q{ 335 | 2 336 | 111 337 | 547366 338 | 111 339 | 3 340 | }, 341 | q{ 342 | , 343 | \}\\ 344 | \\ .' `\\ 345 | \}\}< ( 6> 346 | / `, .' 347 | \}/ 348 | ' 349 | }, 350 | q{ 351 | 2 352 | 22 353 | 6 11 11 354 | 661 7 45 355 | 6 11 11 356 | 33 357 | 3 358 | }, 359 | q{ 360 | , 361 | /\{ 362 | /' `. / 363 | <6 ) >\{\{ 364 | `. ,' \\ 365 | \\\{ 366 | ` 367 | }, 368 | q{ 369 | 2 370 | 22 371 | 11 11 6 372 | 54 7 166 373 | 11 11 6 374 | 33 375 | 3 376 | }, 377 | q{ 378 | \\'`. 379 | ) \\ 380 | (`.??????_.-`' ' '`-. 381 | \\ `.??.` (o) \\_ 382 | > >< ((( ( 383 | / .`??`._ /_| /' 384 | (.`???????`-. _ _.-` 385 | /__/' 386 | 387 | }, 388 | q{ 389 | 1111 390 | 1 1 391 | 111 11111 1 1111 392 | 1 11 11 141 11 393 | 1 11 777 5 394 | 1 11 111 333 11 395 | 111 111 1 1111 396 | 11111 397 | 398 | }, 399 | q{ 400 | .'`/ 401 | / ( 402 | .-'` ` `'-._??????.') 403 | _/ (o) '.??.' / 404 | ) ))) >< < 405 | `\\ |_\\ _.'??'. \\ 406 | '-._ _ .-'???????'.) 407 | `\\__\\ 408 | }, 409 | q{ 410 | 1111 411 | 1 1 412 | 1111 1 11111 111 413 | 11 141 11 11 1 414 | 5 777 11 1 415 | 11 333 111 11 1 416 | 1111 1 111 111 417 | 11111 418 | }, 419 | q{ 420 | ,--,_ 421 | __ _\\.---'-. 422 | \\ '.-" // o\\ 423 | /_.'-._ \\\\ / 424 | `"--(/"` 425 | }, 426 | q{ 427 | 22222 428 | 66 121111211 429 | 6 6111 77 41 430 | 6661111 77 1 431 | 11113311 432 | }, 433 | q{ 434 | _,--, 435 | .-'---./_ __ 436 | /o \\\\ "-.' / 437 | \\ // _.-'._\\ 438 | `"\\)--"` 439 | }, 440 | q{ 441 | 22222 442 | 112111121 66 443 | 14 77 1116 6 444 | 1 77 1111666 445 | 11331111 446 | }, 447 | ); 448 | 449 | add_fish_entity($anim, @fish_image); 450 | } 451 | 452 | sub add_old_fish { 453 | my ($old_fish, $anim) = @_; 454 | my @fish_image = ( 455 | 456 | q{ 457 | \ 458 | ...\.., 459 | \ /' \ 460 | >= ( ' > 461 | / \ / / 462 | `"'"'/'' 463 | }, 464 | q{ 465 | 2 466 | 1112111 467 | 6 11 1 468 | 66 7 4 5 469 | 6 1 3 1 470 | 11111311 471 | }, 472 | q{ 473 | / 474 | ,../... 475 | / '\ / 476 | < ' ) =< 477 | \ \ / \ 478 | `'\'"'"' 479 | }, 480 | q{ 481 | 2 482 | 1112111 483 | 1 11 6 484 | 5 4 7 66 485 | 1 3 1 6 486 | 11311111 487 | }, 488 | q{ 489 | \ 490 | \ /--\ 491 | >= (o> 492 | / \__/ 493 | / 494 | }, 495 | q{ 496 | 2 497 | 6 1111 498 | 66 745 499 | 6 1111 500 | 3 501 | }, 502 | q{ 503 | / 504 | /--\ / 505 | ::::::::;;\\\\\ 535 | ''\\\\\\\\\'' ';\ 536 | }, 537 | q{ 538 | 222 539 | 1122211 666 540 | 4111111111666 541 | 51111111111666 542 | 113333311 666 543 | }, 544 | q{ 545 | __ 546 | ><_'> 547 | ' 548 | }, 549 | q{ 550 | 11 551 | 61145 552 | 3 553 | }, 554 | q{ 555 | __ 556 | <'_>< 557 | ` 558 | }, 559 | q{ 560 | 11 561 | 54116 562 | 3 563 | }, 564 | q{ 565 | ..\, 566 | >=' ('> 567 | '''/'' 568 | }, 569 | q{ 570 | 1121 571 | 661 745 572 | 111311 573 | }, 574 | q{ 575 | ,/.. 576 | <') `=< 577 | ``\``` 578 | }, 579 | q{ 580 | 1211 581 | 547 166 582 | 113111 583 | }, 584 | q{ 585 | \ 586 | / \ 587 | >=_('> 588 | \_/ 589 | / 590 | }, 591 | q{ 592 | 2 593 | 1 1 594 | 661745 595 | 111 596 | 3 597 | }, 598 | q{ 599 | / 600 | / \ 601 | <')_=< 602 | \_/ 603 | \ 604 | }, 605 | q{ 606 | 2 607 | 1 1 608 | 547166 609 | 111 610 | 3 611 | }, 612 | q{ 613 | ,\ 614 | >=('> 615 | '/ 616 | }, 617 | q{ 618 | 12 619 | 66745 620 | 13 621 | }, 622 | q{ 623 | /, 624 | <')=< 625 | \` 626 | }, 627 | q{ 628 | 21 629 | 54766 630 | 31 631 | }, 632 | q{ 633 | __ 634 | \/ o\ 635 | /\__/ 636 | }, 637 | q{ 638 | 11 639 | 61 41 640 | 61111 641 | }, 642 | q{ 643 | __ 644 | /o \/ 645 | \__/\ 646 | }, 647 | q{ 648 | 11 649 | 14 16 650 | 11116 651 | }, 652 | ); 653 | 654 | add_fish_entity($anim, @fish_image); 655 | } 656 | 657 | sub add_fish_entity { 658 | my $anim = shift; 659 | my @fish_image = @_; 660 | 661 | # 1: body 662 | # 2: dorsal fin 663 | # 3: flippers 664 | # 4: eye 665 | # 5: mouth 666 | # 6: tailfin 667 | # 7: gills 668 | 669 | my @colors = ('c','C','r','R','y','Y','b','B','g','G','m','M'); 670 | my $fish_num = int(rand($#fish_image/2)); 671 | my $fish_index = $fish_num * 2; 672 | my $speed = rand(2) + .25; 673 | my $depth = int(rand($depth{'fish_end'} - $depth{'fish_start'})) + $depth{'fish_start'}; 674 | my $color_mask = $fish_image[$fish_index+1]; 675 | $color_mask =~ s/4/W/gm; 676 | $color_mask = rand_color($color_mask); 677 | 678 | if($fish_num % 2) { 679 | $speed *= -1; 680 | } 681 | my $fish_object = Term::Animation::Entity->new( 682 | type => 'fish', 683 | shape => $fish_image[$fish_index], 684 | auto_trans => 1, 685 | color => $color_mask, 686 | position => [ 0, 0, $depth ], 687 | callback => \&fish_callback, 688 | callback_args => [ $speed, 0, 0 ], 689 | die_offscreen => 1, 690 | death_cb => \&add_fish, 691 | physical => 1, 692 | coll_handler => \&fish_collision, 693 | ); 694 | 695 | my $max_height = 9; 696 | my $min_height = $anim->height() - $fish_object->{'HEIGHT'}; 697 | $fish_object->{'Y'} = int(rand($min_height - $max_height)) + $max_height; 698 | if($fish_num % 2) { 699 | $fish_object->{'X'} = $anim->width()-2; 700 | } else { 701 | $fish_object->{'X'} = 1 - $fish_object->{'WIDTH'}; 702 | } 703 | $anim->add_entity($fish_object); 704 | } 705 | 706 | sub fish_callback { 707 | my ($fish, $anim) = @_; 708 | if(int(rand(100)) > 97) { 709 | add_bubble($fish, $anim); 710 | } 711 | return $fish->move_entity($anim); 712 | } 713 | sub fish_collision { 714 | my ($fish, $anim) = @_; 715 | my $collisions = $fish->collisions(); 716 | foreach my $col_obj (@{$collisions}) { 717 | if($col_obj->type eq 'teeth' && $fish->height <= 5) { 718 | add_splat($anim, $col_obj->position()); 719 | $fish->kill(); 720 | last; 721 | } 722 | } 723 | } 724 | 725 | sub add_splat { 726 | my ($anim, $x, $y, $z) = @_; 727 | my @splat_image = ( 728 | q# 729 | 730 | . 731 | *** 732 | ' 733 | 734 | #, 735 | q# 736 | 737 | ",*;` 738 | "*,** 739 | *"'~' 740 | 741 | #, 742 | q# 743 | , , 744 | " ","' 745 | *" *'" 746 | " ; . 747 | 748 | #, 749 | q# 750 | * ' , ' ` 751 | ' ` * . ' 752 | ' `' ",' 753 | * ' " * . 754 | " * ', ' 755 | #, 756 | ); 757 | 758 | $anim->new_entity( 759 | shape => \@splat_image, 760 | position => [ $x - 4, $y - 2, $z-2 ], 761 | default_color => 'RED', 762 | callback_args => [ 0, 0, 0, .25 ], 763 | transparent => ' ', 764 | die_frame => 15, 765 | ); 766 | } 767 | 768 | sub add_shark { 769 | my ($old_ent, $anim) = @_; 770 | my @shark_image = ( 771 | q# 772 | __ 773 | ( `\ 774 | ,??????????????????????????) `\ 775 | ;' `.????????????????????????( `\__ 776 | ; `.?????????????__..---'' `~~~~-._ 777 | `. `.____...--'' (b `--._ 778 | > _.-' .(( ._ ) 779 | .`.-`--...__ .-' -.___.....-(|/|/|/|/' 780 | ;.'?????????`. ...----`.___.',,,_______......---' 781 | '???????????'-' 782 | #, 783 | q# 784 | __ 785 | /' ) 786 | /' (??????????????????????????, 787 | __/' )????????????????????????.' `; 788 | _.-~~~~' ``---..__?????????????.' ; 789 | _.--' b) ``--...____.' .' 790 | ( _. )). `-._ < 791 | `\|\|\|\|)-.....___.- `-. __...--'-.'. 792 | `---......_______,,,`.___.'----... .'?????????`.; 793 | `-`???????????` 794 | #, 795 | ); 796 | 797 | 798 | my @shark_mask = ( 799 | q# 800 | 801 | 802 | 803 | 804 | 805 | cR 806 | 807 | cWWWWWWWW 808 | 809 | 810 | #, 811 | q# 812 | 813 | 814 | 815 | 816 | 817 | Rc 818 | 819 | WWWWWWWWc 820 | 821 | 822 | #, 823 | ); 824 | 825 | my $dir = int(rand(2)); 826 | my $x = -53; 827 | my $y = int(rand($anim->height() - (10 + 9))) + 9; 828 | my $teeth_x = -9; 829 | my $teeth_y = $y + 7; 830 | my $speed = 2; 831 | if($dir) { 832 | $speed *= -1; 833 | $x = $anim->width()-2; 834 | $teeth_x = $x + 9; 835 | } 836 | 837 | $anim->new_entity( 838 | type => 'teeth', 839 | shape => "*", 840 | position => [ $teeth_x, $teeth_y, $depth{'shark'}+1 ], 841 | depth => $depth{'fish_end'} - $depth{'fish_start'}, 842 | callback_args => [ $speed, 0, 0 ], 843 | physical => 1, 844 | ); 845 | 846 | $anim->new_entity( 847 | type => "shark", 848 | color => $shark_mask[$dir], 849 | shape => $shark_image[$dir], 850 | auto_trans => 1, 851 | position => [ $x, $y, $depth{'shark'} ], 852 | default_color => 'WHITE', 853 | callback_args => [ $speed, 0, 0 ], 854 | die_offscreen => 1, 855 | death_cb => \&shark_death, 856 | default_color => 'CYAN', 857 | ); 858 | 859 | } 860 | 861 | # when a shark dies, kill the "teeth" too, the associated 862 | # entity that does the actual collision 863 | sub shark_death { 864 | my ($shark, $anim) = @_; 865 | my $teeth = $anim->get_entities_of_type('teeth'); 866 | foreach my $obj (@{$teeth}) { 867 | $anim->del_entity($obj); 868 | } 869 | random_object($shark, $anim); 870 | } 871 | 872 | sub add_ship { 873 | my ($old_ent, $anim) = @_; 874 | 875 | my @ship_image = ( 876 | q{ 877 | | | | 878 | )_) )_) )_) 879 | )___))___))___)\ 880 | )____)____)_____)\\\ 881 | _____|____|____|____\\\\\__ 882 | \ / 883 | }, 884 | q{ 885 | | | | 886 | (_( (_( (_( 887 | /(___((___((___( 888 | //(_____(____(____( 889 | __///____|____|____|_____ 890 | \ / 891 | }); 892 | 893 | my @ship_mask = ( 894 | q{ 895 | y y y 896 | 897 | w 898 | ww 899 | yyyyyyyyyyyyyyyyyyyywwwyy 900 | y y 901 | }, 902 | q{ 903 | y y y 904 | 905 | w 906 | ww 907 | yywwwyyyyyyyyyyyyyyyyyyyy 908 | y y 909 | }); 910 | 911 | my $dir = int(rand(2)); 912 | my $x = -24; 913 | my $speed = 1; 914 | if($dir) { 915 | $speed *= -1; 916 | $x = $anim->width()-2; 917 | } 918 | 919 | $anim->new_entity( 920 | color => $ship_mask[$dir], 921 | shape => $ship_image[$dir], 922 | auto_trans => 1, 923 | position => [ $x, 0, $depth{'water_gap1'} ], 924 | default_color => 'WHITE', 925 | callback_args => [ $speed, 0, 0 ], 926 | die_offscreen => 1, 927 | death_cb => \&random_object, 928 | ); 929 | } 930 | 931 | sub add_whale { 932 | my ($old_ent, $anim) = @_; 933 | my @whale_image = ( 934 | q{ 935 | .-----: 936 | .' `. 937 | ,????/ (o) \ 938 | \`._/ ,__) 939 | }, 940 | q{ 941 | :-----. 942 | .' `. 943 | / (o) \????, 944 | (__, \_.'/ 945 | }); 946 | my @whale_mask = ( 947 | q{ 948 | C C 949 | CCCCCCC 950 | C C C 951 | BBBBBBB 952 | BB BB 953 | B B BWB B 954 | BBBBB BBBB 955 | }, 956 | q{ 957 | C C 958 | CCCCCCC 959 | C C C 960 | BBBBBBB 961 | BB BB 962 | B BWB B B 963 | BBBB BBBBB 964 | } 965 | ); 966 | 967 | my @water_spout = ( 968 | q{ 969 | 970 | 971 | : 972 | },q{ 973 | 974 | : 975 | : 976 | },q{ 977 | . . 978 | -:- 979 | : 980 | },q{ 981 | . . 982 | .-:-. 983 | : 984 | },q{ 985 | . . 986 | '.-:-.` 987 | ' : ' 988 | },q{ 989 | 990 | .- -. 991 | ; : ; 992 | },q{ 993 | 994 | 995 | ; ; 996 | }); 997 | 998 | 999 | my $dir = int(rand(2)); 1000 | my $x; 1001 | my $speed = 1; 1002 | my $spout_align; 1003 | my @whale_anim; 1004 | my @whale_anim_mask; 1005 | 1006 | if($dir) { 1007 | $spout_align = 1; 1008 | $speed *= -1; 1009 | $x = $anim->width()-2; 1010 | } else { 1011 | $spout_align = 11; 1012 | $x = -18; 1013 | } 1014 | 1015 | # no water spout 1016 | for (1..5) { 1017 | push(@whale_anim, "\n\n\n" . $whale_image[$dir]); 1018 | push(@whale_anim_mask, $whale_mask[$dir]); 1019 | } 1020 | 1021 | # animate water spout 1022 | foreach my $spout_frame (@water_spout) { 1023 | my $whale_frame = $whale_image[$dir]; 1024 | my $aligned_spout_frame; 1025 | $aligned_spout_frame = join("\n" . ' 'x$spout_align, split("\n", $spout_frame)); 1026 | $whale_frame = $aligned_spout_frame . $whale_image[$dir]; 1027 | push(@whale_anim, $whale_frame); 1028 | push(@whale_anim_mask, $whale_mask[$dir]); 1029 | } 1030 | 1031 | $anim->new_entity( 1032 | color => \@whale_anim_mask, 1033 | shape => \@whale_anim, 1034 | auto_trans => 1, 1035 | position => [ $x, 0, $depth{'water_gap2'} ], 1036 | default_color => 'WHITE', 1037 | callback_args => [ $speed, 0, 0, 1 ], 1038 | die_offscreen => 1, 1039 | death_cb => \&random_object, 1040 | ); 1041 | 1042 | } 1043 | 1044 | sub add_monster { 1045 | my @parm = @_; 1046 | 1047 | if ($new_monster) { 1048 | add_new_monster(@parm); 1049 | } else { 1050 | add_old_monster(@parm); 1051 | } 1052 | } 1053 | 1054 | sub add_new_monster { 1055 | my ($old_ent, $anim) = @_; 1056 | my @monster_image = ( 1057 | [ 1058 | " 1059 | _???_?????????????????????_???_???????_a_a 1060 | _{.`=`.}_??????_???_??????_{.`=`.}_????{/ ''\\_ 1061 | _????{.' _ '.}????{.`'`.}????{.' _ '.}??{| ._oo) 1062 | { \\??{/ .'?'. \\}??{/ .-. \\}??{/ .'?'. \\}?{/ | 1063 | ", 1064 | " 1065 | _???_????????????????????_a_a 1066 | _??????_???_??????_{.`=`.}_??????_???_??????{/ ''\\_ 1067 | { \\????{.`'`.}????{.' _ '.}????{.`'`.}????{| ._oo) 1068 | \\ \\??{/ .-. \\}??{/ .'?'. \\}??{/ .-. \\}???{/ | 1069 | " 1070 | ],[ 1071 | " 1072 | a_a_???????_???_?????????????????????_???_ 1073 | _/'' \\}????_{.`=`.}_??????_???_??????_{.`=`.}_ 1074 | (oo_. |}??{.' _ '.}????{.`'`.}????{.' _ '.}????_ 1075 | | \\}?{/ .'?'. \\}??{/ .-. \\}??{/ .'?'. \\}??/ } 1076 | ", 1077 | " 1078 | a_a_????????????????????_ _ 1079 | _/'' \\}??????_???_??????_{.`=`.}_??????_???_??????_ 1080 | (oo_. |}????{.`'`.}????{.' _ '.}????{.`'`.}????/ } 1081 | | \\}???{/ .-. \\}??{/ .'?'. \\}??{/ .-. \\}??/ / 1082 | " 1083 | ]); 1084 | 1085 | my @monster_mask = ( 1086 | q{ W W 1087 | 1088 | 1089 | 1090 | },q{ 1091 | W W 1092 | 1093 | 1094 | 1095 | }); 1096 | my $dir = int(rand(2)); 1097 | my $x; 1098 | my $speed = 2; 1099 | if($dir) { 1100 | $speed *= -1; 1101 | $x = $anim->width()-2; 1102 | } else { 1103 | $x = -54 1104 | } 1105 | my @monster_anim_mask; 1106 | for(1..2) { push(@monster_anim_mask, $monster_mask[$dir]); } 1107 | 1108 | $anim->new_entity( 1109 | shape => $monster_image[$dir], 1110 | auto_trans => 1, 1111 | color => \@monster_anim_mask, 1112 | position => [ $x, 2, $depth{'water_gap2'} ], 1113 | callback_args => [ $speed, 0, 0, .25 ], 1114 | death_cb => \&random_object, 1115 | die_offscreen => 1, 1116 | default_color => 'GREEN', 1117 | ); 1118 | } 1119 | 1120 | sub add_old_monster { 1121 | my ($old_ent, $anim) = @_; 1122 | my @monster_image = ( 1123 | [ 1124 | q{ 1125 | ____ 1126 | __??????????????????????????????????????????/ o \ 1127 | / \????????_?????????????????????_???????/ ____ > 1128 | _??????| __ |?????/ \????????_????????/ \????| | 1129 | | \?????| || |????| |?????/ \?????| |???| | 1130 | },q{ 1131 | ____ 1132 | __?????????/ o \ 1133 | _?????????????????????_???????/ \?????/ ____ > 1134 | _???????/ \????????_????????/ \????| __ |???| | 1135 | | \?????| |?????/ \?????| |???| || |???| | 1136 | },q{ 1137 | ____ 1138 | __????????????????????/ o \ 1139 | _??????????????????????_???????/ \????????_???????/ ____ > 1140 | | \??????????_????????/ \????| __ |?????/ \????| | 1141 | \ \???????/ \?????| |???| || |????| |???| | 1142 | },q{ 1143 | ____ 1144 | __???????????????????????????????/ o \ 1145 | _??????????_???????/ \????????_??????????????????/ ____ > 1146 | | \???????/ \????| __ |?????/ \????????_??????| | 1147 | \ \?????| |???| || |????| |?????/ \????| | 1148 | } 1149 | ],[ 1150 | q{ 1151 | ____ 1152 | / o \??????????????????????????????????????????__ 1153 | < ____ \???????_?????????????????????_????????/ \ 1154 | | |????/ \????????_????????/ \?????| __ |??????_ 1155 | | |???| |?????/ \?????| |????| || |?????/ | 1156 | },q{ 1157 | ____ 1158 | / o \?????????__ 1159 | < ____ \?????/ \???????_?????????????????????_ 1160 | | |???| __ |????/ \????????_????????/ \???????_ 1161 | | |???| || |???| |?????/ \?????| |?????/ | 1162 | },q{ 1163 | ____ 1164 | / o \????????????????????__ 1165 | < ____ \???????_????????/ \???????_??????????????????????_ 1166 | | |????/ \?????| __ |????/ \????????_??????????/ | 1167 | | |???| |????| || |???| |?????/ \???????/ / 1168 | },q{ 1169 | ____ 1170 | / o \???????????????????????????????__ 1171 | < ____ \??????????????????_????????/ \???????_??????????_ 1172 | | |??????_????????/ \?????| __ |????/ \???????/ | 1173 | | |????/ \?????| |????| || |???| |?????/ / 1174 | } 1175 | ]); 1176 | 1177 | my @monster_mask = ( 1178 | q{ 1179 | 1180 | W 1181 | 1182 | 1183 | 1184 | },q{ 1185 | 1186 | W 1187 | 1188 | 1189 | 1190 | }); 1191 | my $dir = int(rand(2)); 1192 | my $x; 1193 | my $speed = 2; 1194 | if($dir) { 1195 | $speed *= -1; 1196 | $x = $anim->width()-2; 1197 | } else { 1198 | $x = -64 1199 | } 1200 | my @monster_anim_mask; 1201 | for(1..4) { push(@monster_anim_mask, $monster_mask[$dir]); } 1202 | 1203 | $anim->new_entity( 1204 | shape => $monster_image[$dir], 1205 | auto_trans => 1, 1206 | color => \@monster_anim_mask, 1207 | position => [ $x, 2, $depth{'water_gap2'} ], 1208 | callback_args => [ $speed, 0, 0, .25 ], 1209 | death_cb => \&random_object, 1210 | die_offscreen => 1, 1211 | default_color => 'GREEN', 1212 | ); 1213 | } 1214 | 1215 | sub add_big_fish { 1216 | my @parm = @_; 1217 | 1218 | if ($new_fish) { 1219 | if (int(rand(3)) > 1) { 1220 | add_big_fish_2(@parm); 1221 | } else { 1222 | add_big_fish_1(@parm); 1223 | } 1224 | } else { 1225 | add_big_fish_1(@parm); 1226 | } 1227 | } 1228 | 1229 | sub add_big_fish_1 { 1230 | my ($old_ent, $anim) = @_; 1231 | 1232 | my @big_fish_image = ( 1233 | q{ 1234 | ______ 1235 | `""-. `````-----.....__ 1236 | `. . . `-. 1237 | : . . `. 1238 | ,?????: . . _ : 1239 | : `.???: (@) `._ 1240 | `. `..' . =`-. .__) 1241 | ; . = ~ : .-" 1242 | .' .'`. . . =.-' `._ .' 1243 | : .'???: . .' 1244 | '???.' . . . .-' 1245 | .'____....----''.'=.' 1246 | ""?????????????.'.' 1247 | ''"'` 1248 | },q{ 1249 | ______ 1250 | __.....-----''''' .-""' 1251 | .-' . . .' 1252 | .' . . : 1253 | : _ . . :?????, 1254 | _.' (@) :???.' : 1255 | (__. .-'= . `..' .' 1256 | "-. : ~ = . ; 1257 | `. _.' `-.= . . .'`. `. 1258 | `. . :???`. : 1259 | `-. . . . `.???` 1260 | `.=`.``----....____`. 1261 | `.`.?????????????"" 1262 | '`"`` 1263 | }); 1264 | 1265 | my @big_fish_mask = ( 1266 | q{ 1267 | 111111 1268 | 11111 11111111111111111 1269 | 11 2 2 111 1270 | 1 2 2 11 1271 | 1 1 2 2 1 1 1272 | 1 11 1 1W1 111 1273 | 11 1111 2 1111 1111 1274 | 1 2 1 1 1 111 1275 | 11 1111 2 2 1111 111 11 1276 | 1 11 1 2 11 1277 | 1 11 2 2 2 111 1278 | 111111111111111111111 1279 | 11 1111 1280 | 11111 1281 | },q{ 1282 | 111111 1283 | 11111111111111111 11111 1284 | 111 2 2 11 1285 | 11 2 2 1 1286 | 1 1 2 2 1 1 1287 | 111 1W1 1 11 1 1288 | 1111 1111 2 1111 11 1289 | 111 1 1 1 2 1 1290 | 11 111 1111 2 2 1111 11 1291 | 11 2 1 11 1 1292 | 111 2 2 2 11 1 1293 | 111111111111111111111 1294 | 1111 11 1295 | 11111 1296 | }); 1297 | 1298 | 1299 | my $dir = int(rand(2)); 1300 | my $x; 1301 | my $speed = 3; 1302 | if($dir) { 1303 | $x = $anim->width()-1; 1304 | $speed *= -1; 1305 | } else { 1306 | $x = -34; 1307 | } 1308 | my $max_height = 9; 1309 | my $min_height = $anim->height() - 15; 1310 | my $y = int(rand($min_height - $max_height)) + $max_height; 1311 | my $color_mask = rand_color($big_fish_mask[$dir]); 1312 | $anim->new_entity( 1313 | shape => $big_fish_image[$dir], 1314 | auto_trans => 1, 1315 | color => $color_mask, 1316 | position => [ $x, $y, $depth{'shark'} ], 1317 | callback_args => [ $speed, 0, 0 ], 1318 | death_cb => \&random_object, 1319 | die_offscreen => 1, 1320 | default_color => 'YELLOW', 1321 | ); 1322 | 1323 | } 1324 | 1325 | sub add_big_fish_2 { 1326 | my ($old_ent, $anim) = @_; 1327 | 1328 | my @big_fish_image = ( 1329 | q{ 1330 | _ _ _ 1331 | .='\\ \\ \\`"=, 1332 | .'\\ \\ \\ \\ \\ \\ \\ 1333 | \\'=._?????/ \\ \\ \\_\\_\\_\\_\\_\\ 1334 | \\'=._'.??/\\ \\,-"`- _ - _ - '-. 1335 | \\`=._\\|'.\\/- _ - _ - _ - _- \\ 1336 | ;"= ._\\=./_ -_ -_ \{`"=_ @ \\ 1337 | ;="_-_=- _ - _ - \{"=_"- \\ 1338 | ;_=_--_., \{_.=' .-/ 1339 | ;.="` / ';\\ _. _.-` 1340 | /_.='/ \\/ /;._ _ _\{.-;`/"` 1341 | /._=_.'???'/ / / / /\{.= / 1342 | /.=' ??????`'./_/_.=`\{_/ 1343 | },q{ 1344 | _ _ _ 1345 | ,="`/ / /'=. 1346 | / / / / / / /'. 1347 | /_/_/_/_/_/ / / \\?????_.='/ 1348 | .-' - _ - _ -`"-,/ /\\??.'_.='/ 1349 | / -_ - _ - _ - _ -\\/.'|/_.=`/ 1350 | / @ _="`\} _- _- _\\.=/_. ="; 1351 | / -"_="\} - _ - _ -=_-_"=; 1352 | \\-. '=._\} ,._--_=_; 1353 | `-._ ._ /;' \\ `"=.; 1354 | `"\\`;-.\}_ _ _.;\\ \\/ \\'=._\\ 1355 | \\ =.\}\\ \\ \\ \\ \\'???'._=_.\\ 1356 | \\_\}`=._\\_\\.'`???????'=.\\ 1357 | }); 1358 | 1359 | my @big_fish_mask = ( 1360 | q{ 1361 | 1 1 1 1362 | 1111 1 11111 1363 | 111 1 1 1 1 1 1 1364 | 11111 1 1 1 11111111111 1365 | 1111111 11 111112 2 2 2 2 111 1366 | 111111111112 2 2 2 2 2 2 22 1 1367 | 111 1111 12 22 22 11111 W 1 1368 | 11111112 2 2 2 2 111111 1 1369 | 111111111 11111 111 1370 | 11111 11111 11 1111 1371 | 111111 11 1111 1 111111111 1372 | 1111111 11 1 1 1 1111 1 1373 | 1111 1111111111111 1374 | },q{ 1375 | 1 1 1 1376 | 11111 1 1111 1377 | 1 1 1 1 1 1 111 1378 | 11111111111 1 1 1 11111 1379 | 111 2 2 2 2 211111 11 1111111 1380 | 1 22 2 2 2 2 2 2 211111111111 1381 | 1 W 11111 22 22 2111111 111 1382 | 1 111111 2 2 2 2 21111111 1383 | 111 11111 111111111 1384 | 1111 11 111 1 11111 1385 | 111111111 1 1111 11 111111 1386 | 1 1111 1 1 1 11 1111111 1387 | 1111111111111 1111 1388 | }); 1389 | 1390 | my $dir = int(rand(2)); 1391 | my $x; 1392 | my $speed = 2.5; 1393 | if($dir) { 1394 | $x = $anim->width()-1; 1395 | $speed *= -1; 1396 | } else { 1397 | $x = -33; 1398 | } 1399 | my $max_height = 9; 1400 | my $min_height = $anim->height() - 14; 1401 | my $y = int(rand($min_height - $max_height)) + $max_height; 1402 | my $color_mask = rand_color($big_fish_mask[$dir]); 1403 | $anim->new_entity( 1404 | shape => $big_fish_image[$dir], 1405 | auto_trans => 1, 1406 | color => $color_mask, 1407 | position => [ $x, $y, $depth{'shark'} ], 1408 | callback_args => [ $speed, 0, 0 ], 1409 | death_cb => \&random_object, 1410 | die_offscreen => 1, 1411 | default_color => 'YELLOW', 1412 | ); 1413 | } 1414 | 1415 | sub init_random_objects { 1416 | #return ( \&add_shark ); 1417 | return ( 1418 | \&add_ship, 1419 | \&add_whale, 1420 | \&add_monster, 1421 | \&add_big_fish, 1422 | \&add_shark, 1423 | ); 1424 | } 1425 | 1426 | # add one of the random objects to the screen 1427 | sub random_object { 1428 | my ($dead_object, $anim) = @_; 1429 | my $sub = int(rand(scalar(@random_objects))); 1430 | $random_objects[$sub]->($dead_object, $anim); 1431 | } 1432 | 1433 | sub dprint { 1434 | open(D, ">>", "debug"); 1435 | print D @_, "\n"; 1436 | close(D); 1437 | } 1438 | 1439 | sub sighandler { 1440 | my ($sig) = @_; 1441 | if($sig eq 'INT') { quit(); } 1442 | elsif($sig eq 'WINCH') { 1443 | # ignore SIGWINCH, only redraw when requested 1444 | } 1445 | else { quit("Exiting with SIG$sig"); } 1446 | } 1447 | 1448 | sub quit { 1449 | my ($mesg) = @_; 1450 | print STDERR $mesg, "\n" if(defined($mesg)); 1451 | exit; 1452 | } 1453 | 1454 | 1455 | sub initialize { 1456 | # this may be paranoid, but i don't want to leave 1457 | # the user's terminal in a state that they might not 1458 | # know how to fix if we die badly 1459 | foreach my $sig (keys %SIG) { 1460 | $SIG{$sig} = 'sighandler' unless(defined($SIG{$sig})); 1461 | } 1462 | } 1463 | 1464 | 1465 | sub center { 1466 | my ($width, $mesg) = @_; 1467 | my $l = length($mesg); 1468 | if($l < $width) { 1469 | return ' 'x(int(($width - length($mesg))/2)) . $mesg; 1470 | } 1471 | elsif($l > $width) { 1472 | return(substr($mesg, 0, ($width - ($l + 3))) . "..."); 1473 | } 1474 | else { 1475 | return $mesg; 1476 | } 1477 | } 1478 | 1479 | sub rand_color { 1480 | my ($color_mask) = @_; 1481 | my @colors = ('c','C','r','R','y','Y','b','B','g','G','m','M'); 1482 | foreach my $i (1..9) { 1483 | my $color = $colors[int(rand($#colors))]; 1484 | $color_mask =~ s/$i/$color/gm; 1485 | } 1486 | return $color_mask; 1487 | } 1488 | 1489 | sub VERSION_MESSAGE { 1490 | print "asciiquarium $version\n"; 1491 | exit; 1492 | } 1493 | -------------------------------------------------------------------------------- /gpl.txt: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc. 5 | 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Library General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | 294 | Copyright (C) 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License 307 | along with this program; if not, write to the Free Software 308 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 309 | 310 | 311 | Also add information on how to contact you by electronic and paper mail. 312 | 313 | If the program is interactive, make it output a short notice like this 314 | when it starts in an interactive mode: 315 | 316 | Gnomovision version 69, Copyright (C) year name of author 317 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 318 | This is free software, and you are welcome to redistribute it 319 | under certain conditions; type `show c' for details. 320 | 321 | The hypothetical commands `show w' and `show c' should show the appropriate 322 | parts of the General Public License. Of course, the commands you use may 323 | be called something other than `show w' and `show c'; they could even be 324 | mouse-clicks or menu items--whatever suits your program. 325 | 326 | You should also get your employer (if you work as a programmer) or your 327 | school, if any, to sign a "copyright disclaimer" for the program, if 328 | necessary. Here is a sample; alter the names: 329 | 330 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 331 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 332 | 333 | , 1 April 1989 334 | Ty Coon, President of Vice 335 | 336 | This General Public License does not permit incorporating your program into 337 | proprietary programs. If your program is a subroutine library, you may 338 | consider it more useful to permit linking proprietary applications with the 339 | library. If this is what you want to do, use the GNU Library General 340 | Public License instead of this License. 341 | --------------------------------------------------------------------------------