| 1 |
#!/usr/bin/env stap |
| 2 |
# Ping pong ball in tty window |
| 3 |
# Run in a xterm and resize window |
| 4 |
# Copyright (C) 2011 Masami Hiramatsu <[email protected]> |
| 5 |
# |
| 6 |
# This file is free software and is distributed under the terms of the GNU |
| 7 |
# General Public License (GPL); either version 2, or (at your option) any |
| 8 |
# later version. |
| 9 |
|
| 10 |
global Row, Col |
| 11 |
global dr = 1, dc = 1 |
| 12 |
|
| 13 |
probe begin { |
| 14 |
Row = game_tty_ws_row()/2; Col = game_tty_ws_col()/2 |
| 15 |
} |
| 16 |
|
| 17 |
probe timer.ms(50) { |
| 18 |
Row += dr; Col += dc |
| 19 |
if (Row >= game_tty_ws_row()) { |
| 20 |
dr = -dr; Row = game_tty_ws_row() |
| 21 |
} else if (Row <= 1) { |
| 22 |
dr = -dr; Row = 1 |
| 23 |
} |
| 24 |
if (Col >= game_tty_ws_col()) { |
| 25 |
dc = -dc; Col = game_tty_ws_col() |
| 26 |
} else if (Col <= 1) { |
| 27 |
dc = -dc; Col = 1 |
| 28 |
} |
| 29 |
ansi_clear_screen() |
| 30 |
ansi_cursor_move(Col, Row) |
| 31 |
print("@") |
| 32 |
} |
| 33 |
|
| 34 |
|