I solved this way:
#!/usr/bin/perl start: $|=1; use Term::ReadKey; ReadMode 3; ($w, $h) = GetTerminalSize; $n = 0.97; #AI sternght $l = 10; #difficulty $x1 = $w/2; $y1 = $h/2; @dxs = (-0.09, -0.08, -0.07, -0.06, -0.05, 0.05, 0.06, 0.07, 0.08, 0.0 +9); @d = (0.05, -0.05); $dx = $d[rand @d]; $dy = $d[rand @d]; $x = $w/2-5; while (1) { $key = ReadKey -1; if ($key eq "d") {$x++; $x = $w-10 if $x > $w-10} if ($key eq "a") {$x--; $x = 0 if $x < 0} $s = " " x (($x1-5)*$n) . "[========]"; $s .= "\n" x $y1 . " " x $x1 . "o"; $s .= "\n" x ($h-$y1-4) . " " x $x . "[========]\n\nyou:\t\t$you\ncomp +uter:\t$pc\n\r"; print $s; $dx *= -1 if $x1 >= $w-1 || $x1 <= 0; $dy *= -1 if ($y1 >= $h-5 && $x1 > $x && $x1 < $x+10) || ($y1 <= 1 && + $x1 > (($x1-5)*$n) && $x1 < (($x1+5)*$n)); $dx = $dxs[$x1-$x] if ($y1 >= $h-5 && $x1 > $x && $x1 < $x+10) || ($y +1 <= 1 && $x1 > (($x1-5)*$n) && $x1 < (($x1+5)*$n)); $x1 += $dx; $y1 += $dy; if ($y1 < 0) {ReadMode 0; ++$you; sleep 1; goto start} if ($y1 > $h-4) {ReadMode 0; ++$pc; sleep 1; goto start} select(undef, undef, undef, 0.005/$l); system('clear'); } ReadMode 0;
saving everything inside $s (: now it works perfectly (it has some minor bugs, but whatever)

In reply to Re^2: "flashing"-like stuff by Anonymous Monk
in thread "flashing"-like stuff by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.