Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
ok, I'm not talking about neon lights or something :P
I'm writing a small perl clone of PONG -- you know, the game everyone played at least once
this is the code so far:
#!/usr/bin/perl $|=1; use Term::ReadKey; ($w, $h) = GetTerminalSize; ReadMode 3; $x1 = 3; $y1 = 3; $dx = 0.05; $dy = 0.05; print "\e[H"; print "\n" x ($h-2); print " " x ($w/2-5); print "##########\r"; $x=($w/2-5); while (1) { $key = ReadKey -1; if ($key eq "d") {$x++; if ($x>($w-10)) {$x=($w-10)}; print "\e[H"; print "\n" x ($h-2); print "\r"; pri +nt "\e[K"; print " " x $x; print "##########\r";} if ($key eq "a") {$x--; if ($x<0) {$x=0}; print "\e[H"; print "\n" x ($h-2); print "\r"; pri +nt "\e[K"; print " " x $x; print "##########\r"; } print "\e[H"; for (0..($h-3)) {print " " x ($w); print "\n"} print "\e[H\n\n\n"; print "\n" x $y1; print "\r\e[K"; print " " x $x1; + print "O\r"; $x1 = ($x1 + $dx); $y1 = ($y1 + $dy); if ( ($y1)>=($h-5) || $y1<=0) {$dy *= -1} if ( ($x1)>=($w-1) || $x1<=0) {$dx *= -1} } ReadMode 0;
yes - there isn't any "my" or strict or warnigns... but that's not the problem. and yes - the ball bounce in its own way, don't caring about the pad
before go ahead, I've got this problem, when you run that code, the cursor of the ball made everything "flashing" and make the game annoying
how can I avoid this annoying flashing ?
(sorry for my bad english)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: "flashing"-like stuff
by zentara (Cardinal) on Sep 24, 2011 at 16:55 UTC | |
by Anonymous Monk on Sep 24, 2011 at 18:28 UTC | |
|
Re: "flashing"-like stuff
by MidLifeXis (Monsignor) on Sep 25, 2011 at 18:54 UTC | |
by Anonymous Monk on Sep 26, 2011 at 17:35 UTC | |
|
Re: "flashing"-like stuff
by Anonymous Monk on Sep 24, 2011 at 16:18 UTC |