File: testtimer.pl

package info (click to toggle)
sdlperl 2.2.5-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 2,136 kB
  • ctags: 3,024
  • sloc: perl: 12,278; objc: 168; ansic: 53; makefile: 23
file content (31 lines) | stat: -rw-r--r-- 635 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/usr/bin/env perl

use SDL;
use SDL::Timer;
use SDL::Event;

die "usage: $0\n" if in($ARGV[0], qw/ -? -h --help/);

SDL::Init(SDL_INIT_TIMER);

print STDERR "Waiting 4 seconds\n";
SDL::Delay(4000);

$a = new SDL::Timer sub { my $timer = shift;
			  print STDERR "Timer A: $$timer{-times} runs\n" }, 
		-delay => 1000, 
		-times => 10;

$b = new SDL::Timer sub { print STDERR "Timer B: ", ++$i,"\n" }, -delay => 3000;
			
$c = new SDL::Timer sub { print STDERR "Timer C: restarting Timer A\n"; $a->run(1000,10) },
		-delay => 19000,
		-times => 1;

SDL::Delay(30000);

print STDERR "Cleaning up...\n";
SDL::Delay(300);

SDL::Quit();