home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ISV Strong Games
/
ISV_STRONG_GAMES.iso
/
desktop
/
polysaw
/
!PolySaw
/
source
/
h
/
polysaw
Wrap
Text File
|
1992-03-04
|
3KB
|
94 lines
#include <stdio.h>
#include "coords.h"
#include "wimp.h"
/******************************* CONSTANTS *****************************/
#define HS 20 /* Half the length of a Side of a square */
#define MAX_BOARD 32 /* side of main board in units of 2*HS */
#define MAX_PIECES 40
#define MAX_SQUARES 20
#define SQUARE_BIT 1
#define HOLE_BIT 2
#define PIECE_BIT 4
/**************************** STRUCTS ***************************/
typedef struct {
int nofunits;
coords_pointstr cog; /* centre of gravity to nearest HS */
coords_pointstr units[MAX_SQUARES]; /* square centres rel. to cog */
int unitpic[MAX_SQUARES]; /* initial sprite number 0-15 */
int rotflipstate; /* 2*(no of 1/4 turns) + (0 or 1) */
wimp_box box; /* bounding box (for any orientation) */
int movespin_rad; /* for splitting drags into move/spin */
} Polymo;
typedef struct {
int kind; /* 0 = not dragging, 1 = move, -1 =spin */
int piece; /* piece number 0, 1, ..., nofpieces-1 */
coords_pointstr start; /* start point of drag (in screen coords) */
coords_pointstr old; /* previous and current mouse posns */
coords_pointstr new; /* for updating drag (in screen coords)*/
int noflines;
wimp_box lines[4*MAX_SQUARES]; /* for outline of drag piece */
} DragState;
/****************** GLOBALS **********************************/
extern wimp_w tools_wh;
extern wimp_w board_wh;
extern wimp_wind * board_windefn;
extern Polymo piece[MAX_PIECES];
extern int nofpieces;
extern int pe_mode; /* play/edit mode */
extern char grid[MAX_BOARD][MAX_BOARD];
extern char filepath[]; /* save file path and window title */
extern int boardfiletype;
/************************** FUNCTIONS ******************************/
/* all non static functions are either called
FROM PolySaw or
INTO misc
*/
/* from EBUT in board_event_handler - polysaw to dragging or edit*/
void deal_with_play_but(coords_pointstr wrk, coords_pointstr mse,
wimp_bbits mse_b, wimp_box box);
void deal_with_squares_but(coords_pointstr wrk, wimp_bbits mse_b);
void deal_with_holes_but(coords_pointstr wrk, wimp_bbits mse_b);
void deal_with_jnsplt_but(coords_pointstr wrk, wimp_bbits mse_b);
/* ENULL - polysaw to dragging */
void update_drag(void);
/* EREDRAW - polysaw to redraw */
void redraw_board(wimp_w handle);
/* polysaw to file */
BOOL save_poly_board(char *filename, void *handle);
void load_file(void);
/* from various to misc */
void fill_out_polydefn(int p);
int roundtonearest(int a, int step);
int integer_sqrt(int x);
void force_piece_redraw(int p);
void force_grid_redraw(int row, int col);
int which_piece(coords_pointstr w);