Fedora Linux Support Community & Resources Center
  #1  
Old 28th November 2011, 12:30 PM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Thumbs up 【Tetris Game -- based on a shell script】(new algorithm)

Hi all, i have successfully developed a shell version of the Tetris Game based on a new algorithm few days ago all by myself, below is the link of the source code that i posted at a Linux/Unix forum the first in China:
http://bbs.chinaunix.net/thread-3614425-1-1.html
I'd love to know that someone can be able to optimize my source code and enhance it!
how to play with it?
Code:
bash Tetris_Game.sh [runlevel] [previewlevel] [speedlevel]
Attached Files
File Type: txt Tetris_Game.txt (18.0 KB, 222 views)
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}

Last edited by huaihaizi3; 17th April 2012 at 06:24 PM.
Reply With Quote
  #2  
Old 8th December 2011, 09:04 PM
Goddard Offline
Registered User
 
Join Date: Nov 2009
Posts: 39
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Thats pretty nifty. A shell script game Didn't know anyone did that. I will check it out.
__________________
Asus G73JW ROG-A3B7M
Intel Core i7 || 16GB RAM || 802.11n+BT || 2 x 500GB Hybrid Drives || Nvidia GTX 460M
Reply With Quote
  #3  
Old 8th December 2011, 10:39 PM
GoinEasy9 Offline
Registered User
 
Join Date: May 2009
Location: Manorville, New York, USA
Posts: 1,676
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

It works, although some of the symbols falling contain way to many nooks and crannies. I might try to reduce the symbol size if I get some time. My grandaughter should like this. Thanks.
__________________
Registered Linux User #348347
Have you been seduced by siduction? http://siduction.org/index.php
Running Fedora 19/20, siduction and openSUSE 13.1 with KDE
Reply With Quote
  #4  
Old 10th December 2011, 06:14 AM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Just as i have post that :
Features:
1.Pause/Resume!
2.Bomb is enabled(ID=23)!
3.Across area moving(ID=0)!
4.Customization is enabled under the given value range of coordinates!
5.Various kinds of color(64 kinds of color are available for randomly choose)!
6.Support 4-level preview(can preview the next 4 pieces generated randomly)!


The shape of the tetris is highly Customization, some of the shape are hard to fill up , this is the challenge and pleasure!
If you want to play the game more easily, just change the range of the ID of the boxes in a continuous range: from box0 to boxUPLIMIT, and change the value of of the num in $((RANDOM/num)), while num is the smallest number that can guarantee the value of $((RANDOM/num)) isn't greater than UPLIMIT when RANDOM is 32767! For instance, the current id of the boxes is from box0 to box27, and 1171 is the smallest number that can guarantee: 0 ≤ $((RANDOM/1171)) ≤ 27, as 32767/1171=27, and 32767/1170=28!
Tetris Game Version 3.0 Beta2 is coming soon!
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}

Last edited by huaihaizi3; 28th February 2012 at 03:40 AM.
Reply With Quote
  #5  
Old 10th December 2011, 10:54 PM
GoinEasy9 Offline
Registered User
 
Join Date: May 2009
Location: Manorville, New York, USA
Posts: 1,676
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Thanks for the update, it's interesting.
__________________
Registered Linux User #348347
Have you been seduced by siduction? http://siduction.org/index.php
Running Fedora 19/20, siduction and openSUSE 13.1 with KDE
Reply With Quote
  #6  
Old 12th December 2011, 03:20 AM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Tetris Game Version 3.0 Beta2 released!
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}
Reply With Quote
  #7  
Old 12th December 2011, 03:40 AM
bob Online
Administrator (yeah, back again)
 
Join Date: Jul 2004
Location: Colton, NY; Junction of Heaven & Earth (also Routes 56 & 68).
Age: 69
Posts: 22,234
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Well, it's a couple of weeks late, but gotta move the thread to Gamer's Lounge.
__________________
Linux & Beer - That TOTALLY Computes!
Registered Linux User #362651


Don't use any of my solutions on working computers or near small children.
Reply With Quote
  #8  
Old 12th December 2011, 06:59 AM
GoinEasy9 Offline
Registered User
 
Join Date: May 2009
Location: Manorville, New York, USA
Posts: 1,676
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Gonna have to take a look, thanks for posting the Beta2.
__________________
Registered Linux User #348347
Have you been seduced by siduction? http://siduction.org/index.php
Running Fedora 19/20, siduction and openSUSE 13.1 with KDE
Reply With Quote
  #9  
Old 14th December 2011, 05:27 AM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Code:
#!/bin/bash
      
for((i=32767/${1}; i>0; --i))
do 
      if (( 32767/i == ${1} && 32767/(i-1) == ${1}+1 )); then
            echo ${i}
            exit
      fi
done
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}
Reply With Quote
  #10  
Old 17th December 2011, 06:58 PM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Tetris Game Version 3.0 Beta3 released!
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}
Reply With Quote
  #11  
Old 25th December 2011, 10:30 AM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Tetris Game Version 3.0 ---Final Version released!
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}
Reply With Quote
  #12  
Old 25th December 2011, 12:23 PM
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,698
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Very nice, Chie chie for sharing
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Guide: Windows 8+ & Fedora 20+ Dualboot
Repo (sea-devel) :: Text User Interface (TUI), Video Handler Script (VHS), efi-helper, grub2-circled-nasa-themes, Essentials (blame, p, rmtf, rnd, siggen, screenshot...), (BETA) Dev-Scripts, (BETA) Fedora Account Scripts (FAS)

Last edited by sea; 25th December 2011 at 12:25 PM.
Reply With Quote
  #13  
Old 25th December 2011, 01:13 PM
smr54 Online
Registered User
 
Join Date: Jan 2010
Posts: 5,570
linuxchrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Doesn't work for me on CentOS or Arch. Different errors on each. It's possible that something got lost in the copying and pasting--I'd suggest that you make it available as an attachment or download or something so that one doesn't have to copy and paste it from the forum thread. (For example, with google chrome on CentOS 6, when I first did it, it included the line numbers when I pasted it into a text file).
Reply With Quote
  #14  
Old 25th December 2011, 01:23 PM
sea Online
"Shells" (of a sub world)
 
Join Date: May 2011
Location: Confoederatio Helvetica (Swissh)
Age: 34
Posts: 3,698
linuxfirefox
Re: 【Tetris Game -- based on a shell script】(new algorithm)

Quote:
Originally Posted by sea View Post
Very nice, Chie chie for sharing
Should have checked if its working, sadly its not..
Quote:
/ $ tetris
bash: /home/simon/bin/tetris: Permission denied
/ $ cd
~ $ cd bin
bin $ chmod +x tetris
bin $ tetris
/home/simon/bin/tetris: line 722: warning: here-document at line 7 delimited by end-of-file (wanted `EOF')
/home/simon/bin/tetris: line 7: ordxy: command not found
/home/simon/bin/tetris: line 7: m-1: command not found
/home/simon/bin/tetris: line 7: m+1: command not found
/home/simon/bin/tetris: line 7: radom: command not found
/home/simon/bin/tetris: line 7: racol: command not found
/home/simon/bin/tetris: line 7: radom: command not found
/home/simon/bin/tetris: line 7: racol: command not found
/home/simon/bin/tetris: line 7: radom: command not found
/home/simon/bin/tetris: line 7: racol: command not found
/home/simon/bin/tetris: line 7: dropa: command not found
/home/simon/bin/tetris: line 7: corev: command not found
/home/simon/bin/tetris: line 7: rmaxy: command not found
/home/simon/bin/tetris: line 7: rmaxx: command not found
bin $
__________________
Laptop: Toshiba satellite p50-a-11 CPU: Intel i7 8*2400 MHz GPU: GeForce GT 745M RAM: 8192 MB Distro: Fedora (Rawhide) DE: Awesome
Guide: Windows 8+ & Fedora 20+ Dualboot
Repo (sea-devel) :: Text User Interface (TUI), Video Handler Script (VHS), efi-helper, grub2-circled-nasa-themes, Essentials (blame, p, rmtf, rnd, siggen, screenshot...), (BETA) Dev-Scripts, (BETA) Fedora Account Scripts (FAS)
Reply With Quote
  #15  
Old 25th December 2011, 02:16 PM
huaihaizi3 Offline
Registered User
 
Join Date: Nov 2009
Location: BeiJing China
Age: 27
Posts: 27
windows_7chrome
Re: 【Tetris Game -- based on a shell script】(new algorithm)

My script is the shell version of the classic Tetris Game!
It runs pretty well under Fedora16, and you can see the screenshot from the link that i have already given above:
http://bbs.chinaunix.net/thread-3614425-1-1.html
just run the script as this:
Code:
bash Tetris_Game.sh
or
Code:
./Tetris_Game.sh


---------- Post added at 06:16 AM ---------- Previous post was at 06:02 AM ----------

I added the attachment!
__________________
Fibonacci(){ m=${1}; n=m; { { (( ${!n} == 1 )) && echo 0; } || { (( ${!n} == 2 )) && echo 1; }; } || echo $(($(Fibonacci $((${!n}-1)))+$(Fibonacci $((${!n}-2))))); }; Fibonacci ${1}
Reply With Quote
Reply

Tags
&#tetris, &#tetris, algorithm, based, game, script&#new, shell

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Shell script - actions based on file type MichaelS-R Programming & Packaging 3 5th December 2008 12:38 PM
call remote shell script within an expect script PhillyFloyd Programming & Packaging 2 16th October 2007 10:29 PM
starting a shell script inside a php script gw348 Using Fedora 6 23rd April 2007 09:30 PM
Shell game CrystalCowboy Using Fedora 0 4th April 2006 04:42 PM


Current GMT-time: 03:48 (Tuesday, 23-12-2014)

TopSubscribe to XML RSS for all Threads in all ForumsFedoraForumDotOrg Archive
logo

All trademarks, and forum posts in this site are property of their respective owner(s).
FedoraForum.org is privately owned and is not directly sponsored by the Fedora Project or Red Hat, Inc.

Privacy Policy | Term of Use | Posting Guidelines | Archive | Contact Us | Founding Members

Powered by vBulletin® Copyright ©2000 - 2012, vBulletin Solutions, Inc.

FedoraForum is Powered by RedHat
...Malaysian Food Street, Resorts World Sentosa - Liberia - Souq Waqif Art Center Travel Photos - Kempten Altstadt Travel Photos - Marina Baysands Hotel