Unix/Linux Go Back    


Shell Programming and Scripting BSD, Linux, and UNIX shell scripting — Post awk, bash, csh, ksh, perl, php, python, sed, sh, shell scripts, and other shell scripting languages questions here.

Tetris Game -- based on a shell script (new algorithm)

Shell Programming and Scripting


Tags
tetris game shell algorithm yongye

Reply    
 
Thread Tools Search this Thread Display Modes
    #36  
Old Unix and Linux 03-08-2012
complex.invoke's Unix or Linux Image
complex.invoke complex.invoke is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 14 June 2017, 9:31 AM EDT
Location: BeiJing China
Posts: 236
Thanks: 6
Thanked 29 Times in 8 Posts
Updated 6.0 Beta1
Sponsored Links
    #37  
Old Unix and Linux 03-11-2012
tip78 tip78 is offline
Users Awaiting Email Confirmation
 
Join Date: Sep 2009
Last Activity: 13 March 2015, 11:44 AM EDT
Posts: 109
Thanks: 1
Thanked 11 Times in 11 Posts
tetris.txt contains 5 version
is it possible to make usual figures?
Sponsored Links
    #38  
Old Unix and Linux 03-11-2012
complex.invoke's Unix or Linux Image
complex.invoke complex.invoke is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 14 June 2017, 9:31 AM EDT
Location: BeiJing China
Posts: 236
Thanks: 6
Thanked 29 Times in 8 Posts
Quote:
Originally Posted by tip78 View Post
tetris.txt contains 5 version
is it possible to make usual figures?
what do you mean?
    #39  
Old Unix and Linux 03-12-2012
tip78 tip78 is offline
Users Awaiting Email Confirmation
 
Join Date: Sep 2009
Last Activity: 13 March 2015, 11:44 AM EDT
Posts: 109
Thanks: 1
Thanked 11 Times in 11 Posts
Quote:
Originally Posted by huaihaizi3 View Post
what do you mean?
i mean

Code:
xx
xx

xx
x
x

x
xx
 x

xxxx

 x
xxx

etc
Sponsored Links
    #40  
Old Unix and Linux 03-12-2012
complex.invoke's Unix or Linux Image
complex.invoke complex.invoke is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 14 June 2017, 9:31 AM EDT
Location: BeiJing China
Posts: 236
Thanks: 6
Thanked 29 Times in 8 Posts
Quote:
Originally Posted by tip78 View Post
i mean

Code:
xx
xx

xx
x
x

x
xx
 x

xxxx

 x
xxx

etc
The variable mrx defines the unit of the pieces, the current value of mrx is [];
if you replace [] with xx (double x) ; then the []will become xx, [][][][] will become xxxxxxxx etc, this way, you needn't to change anything else to the code, but if you want to change the code just as you have said that get

Code:
[]
[][]
[]

to

Code:
x
xx
x

(replace the [] with single x), you must to change a lot of the source code(the value of the elements of the box arrays and some coordinates transformation functions),
as you can see that, the current subtraction between arbitrary vertical coordinates of the pieces is 2n, in your way ,the value of subtraction is n!

Last edited by rbatte1; 03-06-2017 at 09:47 AM.. Reason: Added CODE & ICODE tags for clarity.
Sponsored Links
    #41  
Old Unix and Linux 03-12-2012
Scrutinizer's Unix or Linux Image
Scrutinizer Scrutinizer is offline Forum Staff  
Moderator
 
Join Date: Nov 2008
Last Activity: 27 July 2017, 2:13 PM EDT
Location: Amsterdam
Posts: 11,494
Thanks: 494
Thanked 3,322 Times in 2,930 Posts
Cool script. As others have noted echo varies to much across implementations (even within bash), use the sure-fire portable printf instead to make your script more reliable.
If you run this on your code:

Code:
sed 's/echo -e \("[^"]*\)/printf \1\\n/g;s/echo -ne\{0,1\}/printf/g' tetris_script > new_tetris_script

Then it should replace problematic echo -e with printf and then it gives visible output on OSX too. But one problem remaining is that not all signal traps are supported on every OS (for example signal 34):
On OSX from bash:


Code:
$ kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL
 5) SIGTRAP	 6) SIGABRT	 7) SIGEMT	 8) SIGFPE
 9) SIGKILL	10) SIGBUS	11) SIGSEGV	12) SIGSYS
13) SIGPIPE	14) SIGALRM	15) SIGTERM	16) SIGURG
17) SIGSTOP	18) SIGTSTP	19) SIGCONT	20) SIGCHLD
21) SIGTTIN	22) SIGTTOU	23) SIGIO	24) SIGXCPU
25) SIGXFSZ	26) SIGVTALRM	27) SIGPROF	28) SIGWINCH
29) SIGINFO	30) SIGUSR1	31) SIGUSR2

On Linux from bash:

Code:
$ kill -l
 1) SIGHUP	 2) SIGINT	 3) SIGQUIT	 4) SIGILL	 5) SIGTRAP
 6) SIGABRT	 7) SIGBUS	 8) SIGFPE	 9) SIGKILL	10) SIGUSR1
11) SIGSEGV	12) SIGUSR2	13) SIGPIPE	14) SIGALRM	15) SIGTERM
16) SIGSTKFLT	17) SIGCHLD	18) SIGCONT	19) SIGSTOP	20) SIGTSTP
21) SIGTTIN	22) SIGTTOU	23) SIGURG	24) SIGXCPU	25) SIGXFSZ
26) SIGVTALRM	27) SIGPROF	28) SIGWINCH	29) SIGIO	30) SIGPWR
31) SIGSYS	34) SIGRTMIN	35) SIGRTMIN+1	36) SIGRTMIN+2	37) SIGRTMIN+3
38) SIGRTMIN+4	39) SIGRTMIN+5	40) SIGRTMIN+6	41) SIGRTMIN+7	42) SIGRTMIN+8
43) SIGRTMIN+9	44) SIGRTMIN+10	45) SIGRTMIN+11	46) SIGRTMIN+12	47) SIGRTMIN+13
48) SIGRTMIN+14	49) SIGRTMIN+15	50) SIGRTMAX-14	51) SIGRTMAX-13	52) SIGRTMAX-12
53) SIGRTMAX-11	54) SIGRTMAX-10	55) SIGRTMAX-9	56) SIGRTMAX-8	57) SIGRTMAX-7
58) SIGRTMAX-6	59) SIGRTMAX-5	60) SIGRTMAX-4	61) SIGRTMAX-3	62) SIGRTMAX-2
63) SIGRTMAX-1	64) SIGRTMAX


Last edited by Scrutinizer; 03-12-2012 at 05:20 AM..
The Following User Says Thank You to Scrutinizer For This Useful Post:
Sponsored Links
    #42  
Old Unix and Linux 03-12-2012
complex.invoke's Unix or Linux Image
complex.invoke complex.invoke is offline
Registered User
 
Join Date: Nov 2009
Last Activity: 14 June 2017, 9:31 AM EDT
Location: BeiJing China
Posts: 236
Thanks: 6
Thanked 29 Times in 8 Posts
Quote:
Originally Posted by Scrutinizer View Post
Cool script. As others have noted echo varies to much across implementations (even within bash), use the sure-fire portable printf instead to make your script more reliable


Will apply your good advices to the next version!
Thanks!
Sponsored Links
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Linux More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Is there picture based game under linux terminal? vistastar UNIX for Dummies Questions & Answers 18 09-02-2011 12:57 AM
text based football game? dadoprso UNIX for Dummies Questions & Answers 1 04-22-2010 12:32 PM
calling 'n' number of shell scripts based on dependency in one shell script. shashi369 Shell Programming and Scripting 1 11-03-2009 04:31 PM
Need to Write Shell Script based off of this shell command Rally_Point Shell Programming and Scripting 3 06-10-2009 05:19 PM
Shell Script Poker Game earnstaf Shell Programming and Scripting 8 03-11-2008 11:46 AM



All times are GMT -4. The time now is 02:54 PM.