-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgame.pl
executable file
·17 lines (15 loc) · 986 Bytes
/
game.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/usr/bin/perl
#
# Copyright © 2019 Olga Ustiuzhanina <[email protected]>
#
# This program is free software. It comes without any warranty, to
# the extent permitted by applicable law. You can redistribute it
# and/or modify it under the terms of the Do What The Fuck You Want
# To Public License, Version 2, as published by Sam Hocevar. See
# the COPYING file for more details.
#
# Folowing code is a complete and working roguelike game, in 400 characters.
# Requires 80x24 terminal and libcurses-perl module to be installed.
# See 'readable.pl' for annotated version of this code.
#
use Curses;for(@w=0..1920;@m=(-1,clear,80,-80,1);$l[$v]=2){addch$_^$p?("#",".",">",0,B)[$l[$_]]:"@"for@w;$p=$z if$l[$z=$p+$m[ord(getch)-104]]&3;$l[$z]%=3;if($l[$p]&2){@l=0*initscr;map{($_%80-$n%80)**2+abs($_-$n)/80<6?$l[$_]=rand 99<2?4%~($p=$_):1:0for@w,$n=$p+$n%4}0..99;1until$l[$v=rand@w]&$l[$p=rand@w]}$l[$_]&4?$l[$l[$n]==1&&$n^$p?$n:$_]=9|($n=$_+$m[rand 4+($l[$_]=1)]):0for@w;map$_=$_>3?4:$_,@l}