1
0
mirror of https://github.com/abakh/nbsdgames.git synced 2024-06-08 17:20:41 +00:00
This commit is contained in:
untakenstupidnick 2019-08-18 01:12:16 +04:30
parent ab7dbb4195
commit cb12eee7f7
3 changed files with 43 additions and 17 deletions

View File

@ -1,5 +1,4 @@
# New BSD Games
<!To anyone who has been involved in development of this readme system: FUCK Y'ALL ! WHAT KIND OF HELLISH SHIT IS THIS?!?!?!?!??>
*You have a computing machine from 1980's and you wonder how you can use it? <br/>
You deal with a GUI-less machine at work and are looking for ways to kill time? <br/>
You are the DSL developer and have cancelled the project because you lacked games? <br/>
@ -10,10 +9,7 @@
**Don't worry** anymore as you've got nbsdgames now!
I originally made these in hope of them being added to NetBSD ( but the few i talked to preferred to have games in the repositories rather than in /usr/games itself) .
They natively run on Linux, BSD, MacOS and are known to work on Windows as well (using PDCurses, thanks to Laura Michaels for providing advice).
The difficulty and/or dimensions are adjustable through simple command line options (exprience hexadecimal sudoku and 8x8 fifteen puzzles!).
I originally made these in hope of them becoming added to NetBSD (but the few i talked to preferred to have games in the repositories rather than in /usr/games itself).
These include:
@ -29,13 +25,33 @@ These include:
* Fifteen
* Memoblocks (or Memory blocks. A similar game was included in Windows 7)
## Features
* Modern looking TUI
* Color
* Mouse support
* Multiplayer (not network)
* Each game containing help pages on the controls and the gameplay
* Very permissive license (Public Domain equivalent)
* Clean code with documentation
* Small size, with the deb package being less than 50 KB as I write this
* Low in dependencies and very simple build, even in comparison to bsdgames
* Low in CPU usage (Low if you are playing against AI, virtually nothing otherwise)
* Low as possible in memory footprint
* Diversity, you will like one at least
* Portability
* Flexiblity
They natively run on Linux, BSD, MacOS and are known to work on Windows as well (using PDCurses, thanks to Laura Michaels for providing advice).
The difficulty and/or dimensions are adjustable through simple command line options, you can play a minesweeper game that take hours to complete, or exprience hexadecimal sudoku and 8x8 fifteen-like puzzles!
## Prerequisites
* git (optional)
* POSIX make (optional)
* A C compiler with C99 enabled
* The standard library
* libncurses (the dev package if you are on debian-based distros)
* ncurses (libncurses5-dev if you are on debian-based distros)
## How to run
@ -48,7 +64,7 @@ Like this:
``` sh
git clone https://github.com/untakenstupidnick/nbsdgames
cd ~/nbsdgames/sources
cd ./nbsdgames/sources
export PREFIX= ~/bin
make install
```
@ -67,6 +83,8 @@ It's been made available for openSUSE thanks to Jan Brezina: https://build.opens
## How to contribute
Oh, so kind! You can...
* Share these with your friends
* Tell me your feature requests, bug reports, games you want to be added etc. (think of games in spirit of those already included and look if there is already not a good terminal game for it)
* Tell me your feature requests, bug reports, games you want to be added etc. (Think of games in spirit of those already included and look if there is not a good terminal game for it already)
* Make a package for your distro (or put it on repos and tell me afterwards)
* Tell me if you're interested in porting it to non-Unix (Possible in theory since there is PDCurses for SDL, and SDL for everything)
* With mouse support, PDCurses, SDL and NDK existing, now it is possible to port it to Android proper, feel free to tell me if you are doing it.
* Pull requests are of course, welcome too!

View File

@ -323,14 +323,16 @@ void turn_shift(void){
erase();
}
byte shoot(bool turn, byte y , byte x){
if( y<0 || x<0 || y>9 || x>9 ){ //didn't shoot at all
return NOTHING;
}
byte s = game[!turn][y][x];
if(s==HIT || s==MISS)
return NOTHING;
if(s>0){
game[!turn][y][x]=HIT;
return 1;
}
else if(s==HIT || s==MISS || y<0 || x<0 || y>9 || x>9 ){ //didn't shoot at all
return NOTHING;
}
else{
game[!turn][y][x]=MISS;
return 0;
@ -347,7 +349,7 @@ void sink_announce(bool side){
}
}
//there is no instance of 'type' in the opponet's board
if( ( (1 << type) | sunk[!side] ) != sunk[!side] ){
if( ( (1 << type) | sunk[!side] ) != sunk[!side] ){//if it is not yet announced as sunk
sunk[!side] |= (1 << type);
if(computer[side]){
lastinrowy=lastinrowx=firstinrowy=firstinrowx=-1;
@ -375,12 +377,14 @@ void you_sunk(bool side){
just_sunk[!side]=0;
}
void cheat(bool side){
/* its actually an anti-cheat, the player can place all their ships adjacent to the others and in the same direction,
/* its actually an anti-cheat, the player can place all their ships adjacent to one another and in the same direction,
and the algorithm will often play in a way that it will be left with one or two isolated tiles being unshot (with their respective ships being shot before).
in a such a situation a human will *very easily* find the tiles with logical thinking, but the computer shoots randomly and it will take such a long time for it
that it will often lose the winning game.
this function still doesn't make a win,it's randomly executed.*/
this function still doesn't make a win,it's randomly executed.
if i implemented the logical thinking thing, it would become a difficult, unenjoyable game.*/
byte y,x;
for(y=0;y<10;y++){
for(x=0;x<10;x++){
@ -537,7 +541,7 @@ int main(void){
computer[0]=0;
}
Start:
firstinrowy=firstinrowx=lastinrowy=lastinrowx=goindirection=-1;
firstinrowy=firstinrowx=lastinrowy=lastinrowx=goindirection=NOTHING;
shotinvain=0;
sunk[0]=sunk[1]=0;
memset(game,SEA,200);
@ -595,7 +599,7 @@ int main(void){
sigint_handler(EXIT_SUCCESS);
if( input=='\n'){
byte r=shoot(turn,py,px-10);
if(r != -1){
if(r != NOTHING){
goto Turn;
}
}

View File

@ -232,7 +232,11 @@ void sigint_handler(int x){
}
void mouseinput(int sy, int sx){
MEVENT m;
getmouse(&m);
#ifdef PDCURSES
nc_getmouse(&m);
#else
getmouse(&m);
#endif
if( m.y < (3+1+size+s)-sy && m.x<(2*s+1)-sx ){//it's a shame to include math.h only for round() but it was the only moral way to make gcc shut up
py= round( (float)(size*(m.y-4-sy))/(size+1) );//these are derived from the formulas in draw() by simple algebra
px=(m.x-1-sx)/2;