here is an udated version, for better readability:
#!/usr/bin/perl $|=1; use Term::ReadKey; ReadMode 3; ($w, $h) = GetTerminalSize; #get size of the screen $x1 = 0; $y1 = 0; #ball start coordinates $dx = 0.05; $dy = 0.05; #increments to the ball coordinates $x = 0; #start position of the pad while (1) { $key = ReadKey -1; if ($key eq "d") {$x++; $x = $w-10 if $x > $w-10} #moving the pad to t +he right if ($key eq "a") {$x--; $x = 0 if $x < 0} #moving the pad to the l +eft print "\e[H"; print "\n" x ($h-2); print "\r\e[K"; print " " x $x; pri +nt "##########\r\e[H"; #drawing the pad at the bottom of the screen for (0..($h-3)) {print " " x ($w); print "\n"} #cleaning the screen ab +ove the pad print "\e[H\n\n\n"; print "\n" x $y1; print " " x $x1; print "O\r"; #d +rawing the ball $x1 += $dx; #update coordinates of the ball $y1 += $dy; $dx *= -1 if $x1 >= $w-1 || $x1 <= 0; #if the ball hits the left or ri +ght wall $dy *= -1 if $y1 <= 0 || ( $y1 >= $h-5 && $x1 > $x && $x1 < $x+10 ); # +if the ball hits the top wall or the pad if ($y1 > $h-4) {ReadMode 0; die "\nyou lose!\n"} #if the ball doesn't + hit the pad } ReadMode 0;
but the problem's still there, somewhere

In reply to Re: "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.