#!/usr/bin/env perl # # testtimer.pl # # Copyright (C) 2005 David J. Goehrig # # ------------------------------------------------------------------------------ # # This library is free software; you can redistribute it and/or # modify it under the terms of the GNU Lesser General Public # License as published by the Free Software Foundation; either # version 2.1 of the License, or (at your option) any later version. # # This library is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # Lesser General Public License for more details. # # You should have received a copy of the GNU Lesser General Public # License along with this library; if not, write to the Free Software # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA # # ------------------------------------------------------------------------------ # # Please feel free to send questions, suggestions or improvements to: # # David J. Goehrig # dgoehrig@cpan.org # use SDL; use SDL::Timer; die "usage: $0\n" if in($ARGV[0], qw/ -? -h --help/); SDL::Init(SDL_INIT_EVERYTHING()); 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();