Robots: Difference between revisions

m
syntax highlighting fixup automation
m (J: reduce vertical space consumption on page here)
m (syntax highlighting fixup automation)
 
(4 intermediate revisions by one other user not shown)
Line 21:
=={{header|J}}==
 
This approximately emulates the bsd robots game. There's a few differences (the game board is larger and has an explicitly displayed junk border, to quit early you close the window, ...), but the fundamental mechanics and display should be pretty close.
<lang J>require'~addons/ide/qt/gl2.ijs'
 
We use two callbacks here: 'game_handler' to capture keyboard events, and 'sys_timer_z_' to capture timer events when the user uses the 'wait for game over' option.
 
<langsyntaxhighlight Jlang="j">require'~addons/ide/qt/gl2.ijs'
coinsert'jgl2'
 
Line 133 ⟶ 137:
}}
 
wd'pc game closeok; setp wh 1280 720; cc chase isidraw flush;pshow'
wd {{)n
start''</syntaxhighlight>
pc game closeok;
setp wh 1280 720;
cc chase isidraw flush;
pshow;
}}
start''</lang>
 
=={{header|Java}}==
Line 160 ⟶ 159:
(formerly Perl 6)
The bots single-mindedly chase you, taking the shortest path, ignoring obstacles. Use arrow keys to navigate your character(╂) around the board. Avoid bots(☗) and hazards(☢). "Kill" bots by causing them to crash into hazards or other bots. A dead bot creates another hazard. If you eliminate all of the bots on the board, another wave will spawn in random positions. If you touch a hazard or are touched by a bot, you die(†).
<syntaxhighlight lang="raku" perl6line>use Term::termios;
 
constant $saved = Term::termios.new(fd => 1).getattr;
Line 317 ⟶ 316:
print "\nSurvived " , $info , ' bots, but succumbed in the end.';
exit
}</langsyntaxhighlight>
{{out|Sample game}}
<pre>████████████████████████████████████████████████████████████████████████████████████████████████████
10,333

edits