Commits

Anonymous committed e3017d1

Put vsleep($) into Console::Virtual.

Comments (0)

Files changed (2)

lib/console-virtual/Console/Virtual.pm

   @ISA = qw(Exporter);
   @EXPORT_OK = qw(&display &clrscr &clreol &gotoxy
                   &bold &inverse &normal
-                  &update_display &getkey &color);
+                  &update_display &getkey &color
+                  &vsleep);
 }
 
 %setup = ();
   require "Console/Color/$setup{color}.pm";
 }
 
+# This lets us do sub-second sleeps, if Time::HiRes is available.
+my $sleep = sub($) { sleep(shift); };
+my $found_time_hires = 0;
+foreach my $c (@INC)
+{
+  $found_time_hires = 1 if -r "$c/Time/HiRes.pm";
+}
+if ($found_time_hires) {
+  require Time::HiRes;
+  $sleep = sub($) { Time::HiRes::sleep(shift); };
+}
+sub vsleep($) {
+  &$sleep($_[0]);
+}
+
 1;
 
 ### END of Virtual.pm ###

script/ypsilax.pl

 
 use Console::Virtual 2007.1122
      qw(getkey display gotoxy clrscr clreol
-        normal inverse bold update_display color);
-
-# This lets us do sub-second sleeps, if Time::HiRes is available.
-my $sleep = sub($) { sleep(shift); };
-my $found_time_hires = 0;
-foreach my $c (@INC)
-{
-  $found_time_hires = 1 if -r "$c/Time/HiRes.pm";
-}
-if ($found_time_hires) {
-  require Time::HiRes;
-  $sleep = sub($) { Time::HiRes::sleep(shift); };
-}
+        normal inverse bold update_display color
+        vsleep);
 
 ### GLOBALS ###
 
     if ($result->[0] > 0) {
       draw_playfield($playfield);
       update_display();
-      &$sleep($delay / 1000);
+      vsleep($delay / 1000);
     }
   }
   if (++$turn % 1000 == 0) {
     debug "$turn reductions... ";
     draw_playfield($playfield);
     update_display();
-    &$sleep($delay / 1000);
+    vsleep($delay / 1000);
   }    
 }
 
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.