#!/usr/bin/perl -w # 1999-06 # http://www.cyut.edu.tw/~ckhung/b/mi/ use Curses; initscr; cbreak; noecho; nodelay(1); keypad(1); getmaxyx($height, $width); addstr(0, 0, "press arrow keys to accelerate the cursor;"); addstr(1, 0, "press any other key to quit"); $u = $v = 0; $x = $y = 0; while (1) { while (($c = getch) eq ERR) { move($y, $x); $x += $u / 1000; $y += $v / 1000; $x += $width while $x < 0; $x -= $width while $x >= $width; $y += $height while $y < 0; $y -= $height while $y >= $height; } if ($c eq KEY_LEFT) { --$u; } elsif ($c eq KEY_RIGHT) { ++$u; } elsif ($c eq KEY_UP) { --$v; } elsif ($c eq KEY_DOWN) { ++$v; } else { last; } } endwin;