From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4199520a8d9ae4c5 X-Google-Attributes: gid103376,public From: mfb@mbunix.mitre.org (Michael F Brenner) Subject: Re: Tic-Tac-Toe Date: 1997/04/25 Message-ID: <5jqcjb$m19@top.mitre.org>#1/1 X-Deja-AN: 237282339 References: <01bc506c$00d54c40$33bad084@REMINGOLE.uqam.ca> Organization: The MITRE Corporation, Bedford Mass. Newsgroups: comp.lang.ada Date: 1997-04-25T00:00:00+00:00 List-Id: > 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.