Sponsored Content
Full Discussion: Simple Chess Clock
Top Forums Programming Simple Chess Clock Post 302928074 by wisecracker on Monday 8th of December 2014 05:58:36 PM
Old 12-08-2014
I must be mis-interpreting your requirement...
How about this?
Code:
timer=0
count=0
totaltime=0
# 1 second delay with keyboard override.
delay()
{
	read -n1 -s -t1 keyboard
}
read -p "Press any key to start:- " -n1
while true
do
	keyboard=""
	delay
	timer=$((timer+1))
	count=$((count+1))
	totaltime=$((totaltime+1))
	echo "Total elapsed time = $totaltime."
	if [ "$keyboard" == "q" ] || [ "$keyboard" == "Q" ]
	then
		echo "Quit..."
		exit 0
	fi
	if [ "$keyboard" == "r" ] || [ "$keyboard" == "R" ]
	then
		read -p "Reset! Press any key to start:- " -n1
		timer=0
		count=0
		totaltime=0
	fi
	if [ "$keyboard" == "s" ] || [ "$keyboard" == "S" ]
	then
		echo "Start timer..."
		count=$timer
		timer=0
	fi
	if [ "$keyboard" == "f" ] || [ "$keyboard" == "F" ]
	then
		echo "Finish timer..."
		echo "Number of seconds = $timer..."
		echo "Timer count = $count..."
		timer=0
	fi
done

Results:-
Code:
AMIGA:barrywalker~/Desktop/Code/Shell> ./timer.sh
Press any key to start:- 
Total elapsed time = 1.
Total elapsed time = 2.
Total elapsed time = 3.
Start timer...
Total elapsed time = 4.
Total elapsed time = 5.
Finish timer...
Number of seconds = 2...
Timer count = 5...
Total elapsed time = 6.
Total elapsed time = 7.
Total elapsed time = 8.
Start timer...
Total elapsed time = 9.
Total elapsed time = 10.
Total elapsed time = 11.
Total elapsed time = 12.
Total elapsed time = 13.
Finish timer...
Number of seconds = 5...
Timer count = 8...
Total elapsed time = 14.
Total elapsed time = 15.
Quit...
AMIGA:barrywalker~/Desktop/Code/Shell> _

 

5 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

chess perl program questions

Hello guys, While going over the book, I ran into this chess program and I have few questions 1) on line 40), why is not $chessboard-> ) ??? 40 unless (defined $chessboard->) { 2) 20 foreach my $i (reverse (0..7)) { #Row 1 #!/usr/bin/perl -w 2 # 3 # 4 5 ... (1 Reply)
Discussion started by: hankooknara
1 Replies

2. Forum Support Area for Unregistered Users & Account Problems

Chess at the UNIX Forums.

Just to let you know, we have installed Chess at the UNIX forums: Chess Club - The UNIX Forums (0 Replies)
Discussion started by: Neo
0 Replies

3. UNIX for Dummies Questions & Answers

A Simple Clock, Well Maybe Not That Simple...

The attachment says it all really... It is a DEMO at a glance digital readout using the "date" command to make it useful... For a Mocbook Pro 13", OSX 10.7.5, but may well work on Linux variants too. Enjoy... #!/bin/bash # # Clock.sh # A bash DEMO to create a 6 x 7 character set... (4 Replies)
Discussion started by: wisecracker
4 Replies

4. What is on Your Mind?

Chess Players: Which Online Resources (and Software) Do You Use and Why?

Hi Chess Players, Which Online Resources (and Software) Do You Use and Why? As for me, I use chessgames.com and chessbase.com; but currently I'm using chessgames.com the most; I like exploring openings in the chessgames.com opening explorer. For analysis on the desktop (Mac) or iPhone I... (8 Replies)
Discussion started by: Neo
8 Replies

5. What is on Your Mind?

How to Play Chess in Facebook Messenger

Have you ever wondered to play chess while you chat with your friends? Facebook has made this possible. FB keeps coming up with more and more new ideas for its users but this time it is a more intellectual one. Facebook has built a build-in-functionality in Facebook messenger, in which you just... (0 Replies)
Discussion started by: Neo
0 Replies
OCLOCK(1)						      General Commands Manual							 OCLOCK(1)

NAME
oclock - round X clock SYNOPSIS
oclock [-option ... ] DESCRIPTION
Oclock simply displays the current time on an analog display. OPTIONS
-fg color choose a different color for the both hands and the jewel of the clock -bg color choose a different color for the background. -jewel color choose a different color for the jewel on the clock. -minute color choose a different color for the minute hand of the clock. -hour color choose a different color for the hour hand of the clock. -backing { WhenMapped Always NotUseful } selects an appropriate level of backing store. -geometry geometry define the initial window geometry; see X(7). -display display specify the display to use; see X(7). -bd color choose a different color for the window border. -bw width choose a different width for the window border. As the Clock widget changes its border around quite a bit, this is most usefully set to zero. -shape causes the clock to use the Shape extension to create an oval window. This is the default unless the shapeWindow resource is set to false. -noshape causes the clock to not reshape itself and ancestors to exactly fit the outline of the clock. -transparent causes the clock to consist only of the jewel, the hands, and the border. COLORS
If you would like your clock to be viewable in color, include the following in the #ifdef COLOR section you read with xrdb: *customization: -color This will cause oclock to pick up the colors in the app-defaults color customization file: /usr/X11R6/lib/X11/app-defaults/Clock-color. Below are the default colors: Clock*Background: grey Clock*BorderColor: light blue Clock*hour: yellow Clock*jewel: yellow Clock*minute: yellow SEE ALSO
X(7), X Toolkit documentation AUTHOR
Keith Packard, MIT X Consortium XFree86 Version 4.7.0 OCLOCK(1)
All times are GMT -4. The time now is 12:49 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy