home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / World_Of_Computer_Software-02-385-Vol-1of3.iso / x / xpool-10.zip / Xpool / definition.h < prev    next >
C/C++ Source or Header  |  1992-05-26  |  6KB  |  264 lines

  1.  
  2. /* I. ARIT 1992 Hidirbeyli,AYDIN,TR.  09400
  3.                 Golden,    CO,   USA. 80401
  4.  
  5.  
  6.   Copyright (C) 1992 Ismail ARIT
  7.  
  8.   This file  is distributed in the hope that it will be useful,
  9.   but without any warranty.  No author or distributor accepts
  10.   responsibility to anyone for the consequences of using it or for
  11.   whether it serves any particular purpose or works at all.
  12.  
  13.  
  14.   Everyone is granted permission to copy, modify and redistribute
  15.   this file under the following conditions:
  16.  
  17.      Permission is granted to anyone to make or distribute copies
  18.      of the source code, either as received or modified, in any
  19.      medium, provided that all copyright notices, permission and
  20.      nonwarranty notices are preserved, and that the distributor
  21.      grants the recipient permission for further redistribution as
  22.      permitted by this document.
  23.      No part of this program can be used in any commercial product.
  24.  
  25. */
  26.  
  27.  
  28. #include <stdlib.h>
  29. #include <math.h>
  30. #include <string.h>
  31.  
  32. #define MAX_OBJECTS 19
  33. #define MENU_FG           "Black"
  34. #define MENU_BG           "Gray" 
  35.  
  36. #define MENU_PRESS_COLOR   "Wheat" 
  37.  
  38. #define PANE_FG  "White"
  39. #define PANE_BG    "SkyBlue"
  40.  
  41. #define MY_BALLS_COLOR  "Red" 
  42.  
  43. #define YOUR_BALLS_COLOR "Blue"
  44.  
  45. #define STICK_COLOR  "Magenta"   /* no matter what you define, it looks
  46.                                     similar on screen with GXxor */
  47. #define WHITE_BALL  "White"
  48. #define BLACK_BALL  "Black"
  49.  
  50. #define BORDER_COLOR  "Brown"
  51.  
  52. #define MAIN_BG   "Wheat"   
  53. #define MAIN_FG   "Black"
  54. #define RED      "Red"
  55.  
  56. #define THREEBALL   3
  57. #define SIXTEENBALL 16
  58. #define MINSPEED    1    /* if you are under 1.00, you die ( I mean 'stop') */
  59. #define SPEEDLIMIT 50        /* don't worry, it's not for you */
  60. #define PAYLOAD    20  
  61. #define GRAVITY    10 
  62. #define DROPDEADFACTOR .001 /* this is friction */
  63. #define POCKETRADIOUS 25    /* this is not standard, I don't know the 
  64.                                                original size */ 
  65. #define MAXSTICKLENGHT   350   
  66. #define CHECKMOVEDENSITY 50
  67. #define MYTURN   1
  68. #define YOURTURN 0
  69. #define WHITE_BALL_LIMIT 550 /* if you want to move the white ball,
  70.                                  you can't pass this x limit */
  71.  
  72.  
  73. #define INCR         0.01
  74. #define FONT         "9x15"
  75. #define BORDER       1
  76. #define BUTTONCURSOR  30    /*  I guess this is for cross ptr */
  77. /*
  78. #define BUTTONCURSOR  XC_center_ptr
  79. */
  80.  
  81. #define STICK  1
  82. #define TRAJECTORY 0
  83.  
  84.  
  85.  
  86. #define DEBUG   0 
  87. #define YES     1
  88. #define NO      0
  89. #define OKEY    0 
  90. #define FRAMEDENSITY 17    /* how often you want to redraw moving balls */ 
  91. #define REACTION 1
  92. #define ACTION  0
  93. #define dprintf if(DEBUG)printf
  94. #define bitmapMode YES /* if you say NO, 
  95.                           you will see circles on the screen not bitmaps */ 
  96.  
  97.  
  98. /* if you want to refresh balls every time, comment out the following  */
  99. #define REFRESH_EVERY_TIME  
  100.  
  101.  
  102.  
  103.  
  104. #define class typedef struct
  105.  
  106.  
  107.  
  108. typedef struct Segment {
  109.     int     x,
  110.             y,
  111.             xx,
  112.             yy;
  113. }                       Segment;
  114.  
  115. typedef struct Velocity {
  116.     double  x,
  117.             y
  118.            ;
  119. }                       Velocity;
  120. typedef struct Location {
  121.     double  x,
  122.             y
  123.            ;
  124. }                       Location;
  125. typedef struct Distance {
  126.     double  amount,
  127.             x,
  128.             y;
  129. }                       Distance;
  130.  
  131. typedef struct Timing {
  132.     double  currenttime,
  133.             totaltime,
  134.             dt;
  135. }                       Timing;
  136.  
  137.  
  138. typedef struct Space {
  139.     float   xmin,
  140.             ymin,
  141.             xmax,
  142.             ymax;
  143. }                       Space;
  144.  
  145. typedef struct Force {
  146.     double  x,
  147.             y
  148.            ;
  149. }                       Force;
  150.  
  151.  
  152.  
  153. class Stick
  154. {
  155.  
  156.     unsigned int    color;
  157.     int     Visible;
  158.     int     Done;
  159.     int  type;
  160.     Segment Old, New;
  161.  
  162.     void (*Show) ();
  163.     void (*Hide) ();
  164.     void (*MoveTo) ();
  165.     void (*GetColor) ();
  166.     void (*DoneWithTheStick) ();
  167.     float   (*Lenght) ();
  168.  
  169.  
  170. } Stick;
  171.  
  172.  
  173.  
  174. class Ball
  175. {
  176.  
  177.     double  mass,
  178.             radius;
  179.     int     MyID;
  180.     double  Ip;
  181.  
  182.     Velocity CurrentV, OneStepBackV;
  183.     Location CurrentL, OneStepBackL, TwoStepBackL;
  184.     Location LastDrawingL;
  185.     Force CurrentF, OneStepBackF;
  186.     Timing mytime;
  187.     long     framecounter;
  188.     int     ListCounter;
  189.     int     mycolor,
  190.             erasecolor;
  191.     double  kConstant;
  192.     int     In;
  193.     int     Visible;
  194.     int     Stopped;
  195.     int     ShowOut;
  196.     int     NeedOneMoreDrawing;
  197.  
  198.     void (*MyColor_is) ();
  199.     void (*MyIDis) ();
  200.     void (*UpdateVelocity) ();
  201.     void (*UpdateLocation) ();
  202.     void (*UpdateForce) ();
  203.     void (*UpdateMe) ();
  204.     void (*MoveToNextLocation) ();
  205.     void (*Hide) ();
  206.     void (*Show) ();
  207.     void (*NewSpeed) ();
  208.  
  209.  
  210.  
  211. } Ball;
  212.  
  213.  
  214.  
  215.  
  216.  
  217. class Coordinator
  218. {
  219.  
  220.     Ball * Objects[MAX_OBJECTS];
  221.  
  222.     Ball * Pocket[6];   /* I assume we have 6 pockets */
  223.  
  224.     Space myspace;
  225.     Timing mytime;
  226.     int     NumberOfObjects;
  227.     int     ObjectCounter;
  228.     double  AllowableDmax;
  229.     double  kConstant;
  230.     int     GameType;
  231.     int     AllStopped;
  232.     long    Counter;
  233.  
  234.  
  235.     void (*ShowStaticPosition) ();
  236.     void (*HideStaticPosition) ();
  237.     void (*DrawPockets) ();
  238.     void (*GetGameType) ();
  239.     void (*UpDateObjectsInitials) ();
  240.     void (*GetTime) ();
  241.     void (*OpenSpaceForObjects) ();
  242.     int  (*RegisterThisObject) ();
  243.     void (*CheckInitialLocations) ();
  244.     void (*AdvanceOneStep) ();
  245.     void (*StartAction) ();
  246.     void (*GetBoundary) ();
  247.     void (*CheckSpeedsAndCalculateK) ();
  248.     void (*CheckObjectsForTheSpace) ();
  249.     void (*ShowObjects) ();
  250.     void (*AllowableBump) ();
  251.     void (*ArrangeBalls) ();
  252.     void (*CheckPockets) ();
  253.     void (*StillMoving) ();
  254.     void (*InitConfig) ();
  255.  
  256. } Coordinator;
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.