home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Collection of Education
/
collectionofeducationcarat1997.iso
/
GAMES
/
CAROM10.ZIP
/
CAROMSRC.ZIP
/
BALLFULL.H
< prev
next >
Wrap
C/C++ Source or Header
|
1994-08-13
|
5KB
|
158 lines
/*
Copyright (c) 1994 Csaba Mßrkus. All rights reserved.
E-mail: ethcms@duna.ericsson.se
Addr.: H-9600 Sßrvßr, Szatmßr u. 4, Hungary
Permission to use, copy, modify, and distribute this software and its
documentation for any purpose, without fee, and without written agreement
is hereby granted, provided that the above copyright notice and the
following two paragraphs appear in all copies of this software.
IN NO EVENT SHALL THE AUTHOR BE LIABLE TO ANY PARTY FOR
DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE AUTHOR HAS
BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
THE AUTHOR DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE AUTHOR HAS
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS
OR MODIFICATIONS.
*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <windows.h>
extern HGLOBAL hglbShotHistory;
/* Number of balls:
*/
#define N 3
/* Time resolution
*/
#define TIME_SLOT (1.0 / (2 * 18.2))
/* Gravity
If you want to process gravity effects, activate the next #define
*/
// #define GRAVITY_HANDLED
#ifdef GRAVITY_HANDLED
#define GRAVITY_SPEED_PER_SECOND (981.0 * 0)
#endif
/* Rolling
*/
#define MU_ROLLING 0.0025
#define ROLLING_SPEED_PER_SECOND (MU_ROLLING * 9810.0 * 1.0)
/* Friction
*/
#define MU_FRICTION 0.045
#define FRICTION_SPEED_PER_SECOND (MU_FRICTION * 9810.0 / 1.0)
/* Ratio to which the rotation of a ball decreases when it hits the cushion.
That is, if the rotation speed is V before the collision, it will be
(1-ROTATION_CONVERT_RATIO)*V afterward.
*/
#define ROTATION_CONVERT_RATIO 0.75
/* Maximum starting speed is 100 * POWER_SCALE mm/sec:
*/
#define POWER_SCALE 30.0
/* Maximum vertical spin speed is VER_SPIN_RATIO * starting speed:
*/
#define VER_SPIN_RATIO 1.0
/* Maximum horizontal rotation speed is HOR_SPIN_RATIO * starting speed:
*/
#define HOR_SPIN_RATIO 0.67
/* If you want to reflect the spin of balls when they're hitting the cushion
activate this #define:
*/
/* #define SPIN_REFLECTION
*/
#define TABLE_LENGTH 2845.0 /* [mm] Rule: 2840 +- 5 mm */
#define TABLE_WIDTH 1422.5 /* [mm] Rule: 1420 +- 5 mm */
#define CUSHION_WIDTH 40.0 /* Width of rubber cushion */
#define CUSHION_HEIGHT 37.0 /* [mm] Rule: 37 +- 1 mm */
#define BALL_DIAMETER 61.0 /* [mm] Rule: 61.0 - 61.5 mm */
#define BALL_MASS 210.0 /* [g] Rule: 205 - 220 g */
#define WOOD_WIDTH 80.0 /* Width of wooden frame */
/* Position of the top spot: */
#define TOP_SPOT_X (2133.75 + WOOD_WIDTH + CUSHION_WIDTH)
#define TOP_SPOT_Y (711.25 + WOOD_WIDTH + CUSHION_WIDTH)
/* Position of the middle spot: */
#define MIDDLE_SPOT_X (1422.50 + WOOD_WIDTH + CUSHION_WIDTH)
#define MIDDLE_SPOT_Y (711.25 + WOOD_WIDTH + CUSHION_WIDTH)
/* Position of bottom left-hand spot: */
#define BOTTOML_SPOT_X (711.25 + WOOD_WIDTH + CUSHION_WIDTH)
#define BOTTOML_SPOT_Y (889.25 + WOOD_WIDTH + CUSHION_WIDTH)
/* Position of bottom middle spot: */
#define BOTTOMM_SPOT_X (711.25 + WOOD_WIDTH + CUSHION_WIDTH)
#define BOTTOMM_SPOT_Y (711.25 + WOOD_WIDTH + CUSHION_WIDTH)
/* Position of bottom right-hand spot: */
#define BOTTOMR_SPOT_X (711.25 + WOOD_WIDTH + CUSHION_WIDTH)
#define BOTTOMR_SPOT_Y (533.25 + WOOD_WIDTH + CUSHION_WIDTH)
#define BALL_RADIUS (BALL_DIAMETER / 2.0) /* Radius of balls */
/* Multiplier to convert float numbers to unsigned:
*/
#define FIXED_MULT 16.0
/* For outline balls, comment out this:
*/
// #define SOLID_BALLS
/* Location of cushions:
*/
#define LEFT (WOOD_WIDTH + CUSHION_WIDTH)
#define RIGHT (WOOD_WIDTH + CUSHION_WIDTH + TABLE_LENGTH)
#define BOTTOM (WOOD_WIDTH + CUSHION_WIDTH)
#define TOP (WOOD_WIDTH + CUSHION_WIDTH + TABLE_WIDTH)
/* Location of cushions with respect to the radius of the balls
("C_" refers to "C"enter of balls...):
*/
#define C_LEFT (LEFT + BALL_RADIUS)
#define C_RIGHT (RIGHT - BALL_RADIUS)
#define C_BOTTOM (BOTTOM + BALL_RADIUS)
#define C_TOP (TOP - BALL_RADIUS)
/* Data structure to store information on one particular ball:
*/
typedef struct {
float x; /* X Location [mm] */
float y; /* Y Location [mm] */
float r; /* Radius [mm] */
float m; /* Mass [g] */
char *colour; /* Colour name */
char *name; /* Name [text] */
float v; /* Speed [mm/s] */
unsigned a; /* Direction [rad] */
float sv; /* Spin speed [mm/s] (on the surface) */
unsigned sa;/* Spin angle [rad] */
float rv; /* Rotation speed [mm/s] (on the surface) */
} ball_data;
extern ball_data ball[N];
/* Global variables used for recognizing the event of a "carom".
*/
extern int iscarom[N];
extern int cushion_counter;
/* develop_balls
This is the heart of the "biliardness" of the program.
*/
void compute_all_phases(int spin_ver, int spin_hor,
int power, float direction,
int cueball, int *good_shot, int *extra_points,
int *first_ball);