Code Monkey home page Code Monkey logo

bash2048's Introduction

[DEPRECATED] This Repository is No Longer Maintained

Notice: This project is no longer being maintained or updated. It may contain outdated or obsolete information, and the functionality may be broken or buggy. Use at your own risk.

Bash implementation of popular 2048 game. Controlled with arrow keys.

Bugs: https://github.com/mydzor/bash2048/issues

bash2048's People

Contributors

abijith-kp avatar acpmasquerade avatar dacamp avatar derekschrock avatar josefzila avatar sadasant avatar thewisenerd avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bash2048's Issues

Performance

It's a bit slow for larger grids (20x20).
It could be improved by avoiding $(command), which creates a subshell. Most importantly within tight loops.

Example of performance improvement:

182 function apply_push {
183   printf "\n\ninput: $1 key\n" >&3
184   declare -i i=0
185   while [ $i -le $index_max ]; do
186     declare -i j=0
187     while [ $j -le $index_max ]; do
188       flag_skip=0
189       let increment_max=index_max-j
190       declare -i k=1
191       while [ $k -le $increment_max ]; do
192         let flag_skip && break
193         push_pieces $i $j $k $1 $2
194         k=$k+1
195       done~
196       j=$j+1
197     done
198     i=$i+1
199   done

Can l play it without saving it?

It doesn't work using
curl -s https://raw.githubusercontent.com/mydzor/bash2048/master/bash2048.sh | bash
or
curl -s https://raw.githubusercontent.com/mydzor/bash2048/master/bash2048.sh | sponge | bash

[PATCH] Add score

Attached is a patch that adds a score to the game.
It also replaces all occureces of "echo" with printf for compatibility and adds a trap handler for SIGINT wich calls "end_game()"

hjkl

diff --git a/bash2048.sh b/bash2048.sh
index bba4d73..ae7c507 100755
--- a/bash2048.sh
+++ b/bash2048.sh
@@ -209,6 +209,13 @@ function key_react {
         D) apply_push left;;
       esac
     }
+  } || {
+    case $REPLY in
+      k) apply_push up;;
+      j) apply_push down;;
+      l) apply_push right;;
+      h) apply_push left;;
+    esac
   }
 }

Don't directly close the terminal

In Ubuntu, when the target is reached or there are no moves, the terminal just exits. There's not time to look at the text echoed!

High scores

Hi,

I thought it'd be cool if the user can see/save his highscores. What do you think of this feature?
I could eventually open a PR if you feel it is interesting.

Regards

game quits

the script closes instantly when the game is lost

Layout breaks down at 16384

Bash 2048 v1.1 (https://github.com/mydzor/bash2048) pieces=14 target=1048576 score=211020

/------+------+------+------+------\
|      |    2 |      |      |      |
|------+------+------+------+------|
|    2 |   64 |      |      |      |
|------+------+------+------+------|
|   16 |    4 |    4 |      |      |
|------+------+------+------+------|
|   64 |   16 |    8 |    2 |      |
|------+------+------+------+------|
| 16384 |    4 |   64 |    8 |      |
\------+------+------+------+------/

If you allow large targets, you should adapt the cell width

Tiles disappear

Might have to do with combining them, moving up and to the right.

Otherwise, neat.

"Time played" function

Do you remember the old(er) games that displayed how long you played the game in the end screen?

Would be nice if bash2048 would show the play time at the end screen (Game Over and Win).

(OSX): Tiles are broken

The board appears like this:
`
/------|------|------|------\

------ ------ ------ ------
2
------ ------ ------ ------
4
------ ------ ------ ------/
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.