comp.lang.ada
 help / color / mirror / Atom feed
From: mfb@mbunix.mitre.org (Michael F Brenner)
Subject: Re: Tic-Tac-Toe
Date: 1997/04/25
Date: 1997-04-25T00:00:00+00:00	[thread overview]
Message-ID: <5jqcjb$m19@top.mitre.org> (raw)
In-Reply-To: 01bc506c$00d54c40$33bad084@REMINGOLE.uqam.ca


> I would like help on building a program that plays tic-tac-toe
> My main problem is on the grafical interface.
> Since a usual game or board has 9 boxes, I want to make them coincide with
> the numeric pad  on the rigth.
> 1 2 3
> 4 5 6
> 7 8 9
> The x's and o' would alternate.

I would like to help you with your main problem, which you identify as
grafically making the 9 boxes coincide with the numerical pad on the right.

Since you did not state which compiler or operating system you are on,
I will assume that you are on DOS running gnat. Then the keys can be 
mapped as follows.

First, get keystrokes with the command text_io.get (ch), where
ch has been declared to be of type character. With the numerical
lock on, they keys map to the characters '1' through '9'. With the
numberical lock off the keys generate two bytes each, with the first
byte being binary zero. The second byte is as follows:

7 (home) gives 71
8 (up)   gives 72
9 (pgup) gives 73
4 (left) gives 75 
5 (mid)  gives 76
6 (rt)   gives 77 
1 (end)  gives 79
2 (down) gives 80
3 (pgdn) gives 81

To map them to the graphics you have chosen for the nine slots, use
an associative array or other data structure with similar functionality.





       reply	other threads:[~1997-04-25  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <01bc506c$00d54c40$33bad084@REMINGOLE.uqam.ca>
1997-04-25  0:00 ` Michael F Brenner [this message]
1997-04-26  0:00 ` Tic-Tac-Toe Jerry van Dijk
1997-04-26  0:00 Tic-Tac-Toe Sam Harbaugh, Palm Bay, Florida
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox