home *** CD-ROM | disk | FTP | other *** search
/ MORE WinGames / WINGAMES.iso / winpool / definiti.h < prev    next >
C/C++ Source or Header  |  1992-12-22  |  7KB  |  322 lines

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