tetris.md (5029B)
1 # The man page reading club: tetris(6) 2 3 *This post is part of a [series](../../series)* 4 5 Sometimes you just need to relax and have some fun :-) 6 7 ## Boredom 8 9 *"Phew, that was a long read!" you think as you reach the end of the 10 `sh(1)` manual page. After such an intense brain-workout you would 11 normally have a nice walk outside - but the Geiger counter on the wall 12 tells you that this might not be a good idea in this timeline. Your second 13 choice would be to have a beer and listen to some good music or watch a 14 movie, but none of these options is available in the bunker. It's almost 15 as if the nuclear winter is... bad?* 16 17 *You try to think what else you can do to ease your boredom. 18 There's no internet, no books, no videogames... wait a minute!* 19 20 ``` 21 $ man man 22 ``` 23 24 *You scroll down until you see the list of available sections, and 25 you find the one you were looking for:* 26 27 ``` 28 6 Games. 29 ``` 30 31 *Yes! You thought you saw this 32 [some time ago](https://sebastiano.tronto.net/blog/2022-05-29-man), 33 but you had ignored it. You also remember that the `intro(1)` page 34 mentioned analogous intoductory pages for each section. So you type:* 35 36 ``` 37 $ man 6 intro 38 ``` 39 40 *And so you discover that the folder `/usr/games` contains dozens of 41 games and other fun little programs. These are already installed in your 42 system, no need to download files or insert CD roms.* 43 44 *There is so much choice, so many games you have never heard of. But for 45 this time you decide to go with a classic.* 46 47 ## tetris(6) 48 49 *Follow along at [man.openbsd.org](https://man.openbsd.org/OpenBSD-7.1/tetris)* 50 51 Before starting the game it is better to learn the rules, so let's type 52 `man tetris` first! 53 54 ``` 55 DESCRIPTION 56 The tetris command runs a display-based game. The object is to fit 57 shapes together to form complete rows, which then vanish. When the 58 shapes fill up to the top, the game ends. 59 ``` 60 61 The default control keys are listed below: 62 63 ``` 64 j move left 65 k rotate 1/4 turn counterclockwise 66 l move right 67 <space> drop 68 p pause 69 q quit 70 ``` 71 72 Some of the options are quite straightforward: `-c` to play in "classic 73 mode", with a slightly different graphics and shapes that turn clockwise; 74 `-l` to specify a level; `-p` to show the next shape that will drop, in 75 exchange for a lower score; `-s` to print the highscores and exit. The 76 most interesting is `-k`: 77 78 ``` 79 -k keys 80 The default control keys can be changed using the -k option. The 81 keys argument must have the six keys in order; remember to quote 82 any space or tab characters from the shell. 83 ``` 84 85 The sections PLAY and SCORING explain the gameplay and the criteria for 86 assigning points. There is also an ENVIRONMENT section with a single line: 87 88 ``` 89 LOGNAME Name displayed in high score file. 90 ``` 91 92 This means that you can set that shell variable to have your score 93 saved in the `$HOME/.tetris.score` file under a different name - 94 this can be useful for example when lending your pc to someone else 95 to let them play. 96 97 ## Having fun 98 99 *"Enough of this reading, let's just play!"* 100 101 *You decide to remap the keys to play with your left hand, and to use the 102 old nick name you used on online forums, when the internet still existed. 103 And why not trying the "classic" mode as well?* 104 105 ``` 106 $ LOGNAME=porkynator tetris -c -k 'asd pq' 107 ``` 108 109 *And you start playing the night away* 110 111 ``` 112 Score: 47 [] [] 113 [] [] 114 [] [] 115 [] [] [] 116 [] [][] [] 117 [] [] [] 118 [] [] 119 [] [] 120 [] [] 121 [] [] 122 [] [] 123 [] [] 124 [] [] 125 [] [] 126 [] [] 127 [] [] 128 [] [][] 129 [][][] [][] 130 [][][][] [][] 131 [][][][] [][] 132 [][][][][][][][][][][][] 133 134 a - left s - rotate d - right <space> - drop p - pause q - quit 135 ``` 136 137 ## Conclusions 138 139 This was a short and unimportant post meant to cool down after last month's 140 double post on the shell. I'll take it as an excuse to mention that `/usr/games` 141 [won't be in the default `$PATH`](https://undeadly.org/cgi?action=article;sid=20220810120423) 142 starting from OpenBSD 7.2. If you want to have a fun tetris session, 143 in the future you might have to specify the full path 144 145 ``` 146 $ /usr/games/tetris 147 ``` 148 149 or just update your `$PATH`. 150 151 *Next in the series: [ed(1)](../2022-12-24-ed)*