ETH Zuerich - Startseite
Professur für CAAD

 


caad d-arch


Caad Teaching
 

 
Bachelor of Architecture: CAAD II ss07

 
Master of Advanced Studies
in Architecture, CAAD


 
DWF-Processing
Programmieren statt Zeichnen


 
Graustufen - Ein Atlas
Schweizer Wohngebäude als XML Daten


 
DWF- Denken in Systemen:
In Collaboration with the Technical University Vienna


 
Seminarwoche:
BlowUp


 
Archiv

 
Caad Projects
 

 
Theory
 
Design
 
Building
 
Practice

 
Related pages
 

 
Swiss Federal Institute of Technology Zurich
 
Institute of Building Technology
 
Faculty of Architecture

 
Other pages

 










hbt d-arch

MAS ETH ARCH/CAAD - 2005/06 - STUDENT PAGES
Master of Advanced Studies in Architecture, Specialization in Computer Aided Architectural Design | 065-0005/6
Supervision: Prof. Dr. Ludger Hovestadt, Philipp Schaerer
Chair of CAAD, ETH Zurich







TicTacTool script





plug-in mtTicTacTool



skript mtTicTacTool

please note:
the script looks really messy because i had no time to clean it up.
it also could have been shortened a lot if i would have used some more loops.
but please turn a blind eye to these mistakes...



PROCEDURE mtTicTacTool;

VAR
   FakeX, FakeY : INTEGER;
   ClickContr : BOOLEAN;
   Field1, Field2, Field3, Field4, Field5, Field6, Field7, Field8, Field9 : BOOLEAN;
   Cross1, Cross2, Cross3, Cross4 : BOOLEAN;
   Oval2, Oval3, Oval4, Oval5 : BOOLEAN;
   RowX, RowY : INTEGER;
   ClickX, ClickY : REAL;
   i,k : INTEGER;

{-----------------------------------------------------}

PROCEDURE InGrid(ClickContr : BOOLEAN);
BEGIN REPEAT
   GetPt(ClickX,ClickY);
      IF (ClickX<0) THEN ClickContr := FALSE
      ELSE BEGIN
         IF (ClickX>30) THEN ClickContr := FALSE
         ELSE BEGIN
            IF (ClickY<0) THEN ClickContr := FALSE
            ELSE BEGIN
               IF (ClickY>30) THEN ClickContr := FALSE
               ELSE ClickContr := TRUE;
            END;
         END;
      END;

      IF (ClickContr=FALSE) THEN AlrtDialog('Please click **INTO** the grid!');
   UNTIL (ClickContr = TRUE);
END;

{-----------------------------------------------------}
   
BEGIN;

{Fake mouseclick for script start by icon}
GetPt(FakeX,FakeY);


{##### draw grid #####}

PenSize(140);
PenFore(22222,22222,22222);

For k:=0 TO 2 DO BEGIN   
   For i:=0 TO 2 DO BEGIN

      Rect(i*10,k*10,i*10+10,k*10+10);

   END;
END;

Redrawall;
SetVCenter(15,15);
SetZoom(75);

{##### draw first oval #####}

AlrtDialog('Player 1: Please click into grid to start game!');

   InGrid(ClickContr);

PenFore(50000,10000,0);

Field1 := TRUE;
Field2 := TRUE;
Field3 := TRUE;
Field4 := TRUE;
Field5 := TRUE;
Field6 := TRUE;
Field7 := TRUE;
Field8 := TRUE;
Field9 := TRUE;
Cross1 := FALSE;
Cross2 := FALSE;
Cross3 := FALSE;
Cross4 := FALSE;
Oval2 := FALSE;
Oval3 := FALSE;
Oval4 := FALSE;
Oval5 := FALSE;

RowX := Trunc(ClickX/10);
RowY := Trunc(ClickY/10);

   IF (RowX=0) AND (RowY=0) THEN BEGIN
      Oval(2,2,8,8);
      Field1 := FALSE;
   END;
   IF (RowX=0) AND (RowY=1) THEN BEGIN
      Oval(2,12,8,18);
      Field2 := FALSE;
   END;
   IF (RowX=0) AND (RowY=2) THEN BEGIN
      Oval(2,22,8,28);
      Field3 := FALSE;
   END;
   IF (RowX=1) AND (RowY=0) THEN BEGIN
      Oval(12,2,18,8);
      Field4 := FALSE;
   END;
   IF (RowX=1) AND (RowY=1) THEN BEGIN
      Oval(12,12,18,18);
      Field5 := FALSE;
   END;
   IF (RowX=1) AND (RowY=2) THEN BEGIN
      Oval(12,22,18,28);
      Field6 := FALSE;
   END;
   IF (RowX=2) AND (RowY=0) THEN BEGIN
      Oval(22,2,28,8);
      Field7 := FALSE;
   END;
   IF (RowX=2) AND (RowY=1) THEN BEGIN
      Oval(22,12,28,18);
      Field8 := FALSE;
   END;
   IF (RowX=2) AND (RowY=2) THEN BEGIN
      Oval(22,22,28,28);
      Field9 := FALSE;
   END;

Redrawall;

{##### draw first cross #####}

AlrtDialog('Player 2: Please click into grid to set cross!');

REPEAT
   InGrid(ClickContr);

   PenFore(65535,35000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,2);
            Line(6,6);
            MoveTo(2,8);
            Line(6,-6);
            Field1 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,12);
            Line(6,6);
            MoveTo(2,18);
            Line(6,-6);
            Field2 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,22);
            Line(6,6);
            MoveTo(2,28);
            Line(6,-6);
            Field3 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,2);
            Line(6,6);
            MoveTo(12,8);
            Line(6,-6);
            Field4 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,12);
            Line(6,6);
            MoveTo(12,18);
            Line(6,-6);
            Field5 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,22);
            Line(6,6);
            MoveTo(12,28);
            Line(6,-6);
            Field6 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,2);
            Line(6,6);
            MoveTo(22,8);
            Line(6,-6);
            Field7 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,12);
            Line(6,6);
            MoveTo(22,18);
            Line(6,-6);
            Field8 := FALSE;
            Cross1 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,22);
            Line(6,6);
            MoveTo(22,28);
            Line(6,-6);
            Field9 := FALSE;
            Cross1 :=TRUE;
         END;
      END;

UNTIL (Cross1 =TRUE);

Redrawall;

{##### draw second oval #####}

AlrtDialog('Player 1: Please click into grid to set oval!');

REPEAT
   InGrid(ClickContr);

   PenFore(50000,10000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,2,8,8);
            Field1 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,12,8,18);
            Field2 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,22,8,28);
            Field3 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,2,18,8);
            Field4 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,12,18,18);
            Field5 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,22,18,28);
            Field6 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,2,28,8);
            Field7 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,12,28,18);
            Field8 := FALSE;
            Oval2 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,22,28,28);
            Field9 := FALSE;
            Oval2 :=TRUE;
         END;
      END;

UNTIL (Oval2 =TRUE);

Redrawall;

{##### draw second cross #####}

AlrtDialog('Player 2: Please click into grid to set cross!');

REPEAT
   InGrid(ClickContr);

   PenFore(65535,35000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,2);
            Line(6,6);
            MoveTo(2,8);
            Line(6,-6);
            Field1 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,12);
            Line(6,6);
            MoveTo(2,18);
            Line(6,-6);
            Field2 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,22);
            Line(6,6);
            MoveTo(2,28);
            Line(6,-6);
            Field3 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,2);
            Line(6,6);
            MoveTo(12,8);
            Line(6,-6);
            Field4 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,12);
            Line(6,6);
            MoveTo(12,18);
            Line(6,-6);
            Field5 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,22);
            Line(6,6);
            MoveTo(12,28);
            Line(6,-6);
            Field6 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,2);
            Line(6,6);
            MoveTo(22,8);
            Line(6,-6);
            Field7 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,12);
            Line(6,6);
            MoveTo(22,18);
            Line(6,-6);
            Field8 := FALSE;
            Cross2 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,22);
            Line(6,6);
            MoveTo(22,28);
            Line(6,-6);
            Field9 := FALSE;
            Cross2 :=TRUE;
         END;
      END;

UNTIL (Cross2 =TRUE);

Redrawall;

{##### draw third oval #####}

AlrtDialog('Player 1: Please click into grid to set oval!');

REPEAT
   InGrid(ClickContr);

   PenFore(50000,10000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,2,8,8);
            Field1 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,12,8,18);
            Field2 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,22,8,28);
            Field3 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,2,18,8);
            Field4 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,12,18,18);
            Field5 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,22,18,28);
            Field6 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,2,28,8);
            Field7 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,12,28,18);
            Field8 := FALSE;
            Oval3 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,22,28,28);
            Field9 := FALSE;
            Oval3 :=TRUE;
         END;
      END;

UNTIL (Oval3 =TRUE);

Redrawall;

{##### draw third cross #####}

AlrtDialog('Player 2: Please click into grid to set cross!');

REPEAT
   InGrid(ClickContr);

   PenFore(65535,35000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,2);
            Line(6,6);
            MoveTo(2,8);
            Line(6,-6);
            Field1 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,12);
            Line(6,6);
            MoveTo(2,18);
            Line(6,-6);
            Field2 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,22);
            Line(6,6);
            MoveTo(2,28);
            Line(6,-6);
            Field3 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,2);
            Line(6,6);
            MoveTo(12,8);
            Line(6,-6);
            Field4 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,12);
            Line(6,6);
            MoveTo(12,18);
            Line(6,-6);
            Field5 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,22);
            Line(6,6);
            MoveTo(12,28);
            Line(6,-6);
            Field6 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,2);
            Line(6,6);
            MoveTo(22,8);
            Line(6,-6);
            Field7 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,12);
            Line(6,6);
            MoveTo(22,18);
            Line(6,-6);
            Field8 := FALSE;
            Cross3 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,22);
            Line(6,6);
            MoveTo(22,28);
            Line(6,-6);
            Field9 := FALSE;
            Cross3 :=TRUE;
         END;
      END;

UNTIL (Cross3 =TRUE);

Redrawall;

{##### draw fourth oval #####}

AlrtDialog('Player 1: Please click into grid to set oval!');

REPEAT
   InGrid(ClickContr);

   PenFore(50000,10000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,2,8,8);
            Field1 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,12,8,18);
            Field2 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,22,8,28);
            Field3 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,2,18,8);
            Field4 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,12,18,18);
            Field5 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,22,18,28);
            Field6 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,2,28,8);
            Field7 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,12,28,18);
            Field8 := FALSE;
            Oval4 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,22,28,28);
            Field9 := FALSE;
            Oval4 :=TRUE;
         END;
      END;

UNTIL (Oval4 =TRUE);

Redrawall;

{##### draw fourth cross #####}

AlrtDialog('Player 2: Please click into grid to set cross!');

REPEAT
   InGrid(ClickContr);

   PenFore(65535,35000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,2);
            Line(6,6);
            MoveTo(2,8);
            Line(6,-6);
            Field1 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,12);
            Line(6,6);
            MoveTo(2,18);
            Line(6,-6);
            Field2 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(2,22);
            Line(6,6);
            MoveTo(2,28);
            Line(6,-6);
            Field3 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,2);
            Line(6,6);
            MoveTo(12,8);
            Line(6,-6);
            Field4 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,12);
            Line(6,6);
            MoveTo(12,18);
            Line(6,-6);
            Field5 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(12,22);
            Line(6,6);
            MoveTo(12,28);
            Line(6,-6);
            Field6 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,2);
            Line(6,6);
            MoveTo(22,8);
            Line(6,-6);
            Field7 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,12);
            Line(6,6);
            MoveTo(22,18);
            Line(6,-6);
            Field8 := FALSE;
            Cross4 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            MoveTo(22,22);
            Line(6,6);
            MoveTo(22,28);
            Line(6,-6);
            Field9 := FALSE;
            Cross4 :=TRUE;
         END;
      END;

UNTIL (Cross4 =TRUE);

Redrawall;

{##### draw fifth oval #####}

AlrtDialog('Player 1: Please click into grid to set oval!');

REPEAT
   InGrid(ClickContr);

   PenFore(50000,10000,0);

   RowX := Trunc(ClickX/10);
   RowY := Trunc(ClickY/10);

      IF (RowX=0) AND (RowY=0) THEN BEGIN
         IF (Field1=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,2,8,8);
            Field1 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=1) THEN BEGIN
         IF (Field2=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,12,8,18);
            Field2 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=0) AND (RowY=2) THEN BEGIN
         IF (Field3=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(2,22,8,28);
            Field3 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=0) THEN BEGIN
         IF (Field4=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,2,18,8);
            Field4 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=1) THEN BEGIN
         IF (Field5=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,12,18,18);
            Field5 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=1) AND (RowY=2) THEN BEGIN
         IF (Field6=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(12,22,18,28);
            Field6 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=0) THEN BEGIN
         IF (Field7=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,2,28,8);
            Field7 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=1) THEN BEGIN
         IF (Field8=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,12,28,18);
            Field8 := FALSE;
            Oval5 :=TRUE;
         END;
      END;
      IF (RowX=2) AND (RowY=2) THEN BEGIN
         IF (Field9=FALSE) THEN AlrtDialog('Field occupied - choose another!')
         ELSE BEGIN
            Oval(22,22,28,28);
            Field9 := FALSE;
            Oval5 :=TRUE;
         END;
      END;

UNTIL (Oval5 =TRUE);

Redrawall;

AlrtDialog('GAME OVER!')

END;

Run(mtTicTacTool);








-- NDSMartinTann - 15 Nov 2005

Revision r1.4 - 21 Nov 2005 - 23:52 - NDSMartinTann
Parents: WebHome > NDSMartinTann > Martinmodule01 > MartinModule01Mini-Assignment3
Copyright © 1999-2003 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.

This website has been archived and is no longer maintained.