1 /* $Id: walls.h,v 5.3 2001/05/27 16:37:06 bertg Exp $ 2 * 3 * XPilot, a multiplayer gravity war game. Copyright (C) 1991-2001 by 4 * 5 * Bj�rn Stabell <bjoern@xpilot.org> 6 * Ken Ronny Schouten <ken@xpilot.org> 7 * Bert Gijsbers <bert@xpilot.org> 8 * Dick Balaska <dick@xpilot.org> 9 * 10 * This program is free software; you can redistribute it and/or modify 11 * it under the terms of the GNU General Public License as published by 12 * the Free Software Foundation; either version 2 of the License, or 13 * (at your option) any later version. 14 * 15 * This program is distributed in the hope that it will be useful, 16 * but WITHOUT ANY WARRANTY; without even the implied warranty of 17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 18 * GNU General Public License for more details. 19 * 20 * You should have received a copy of the GNU General Public License 21 * along with this program; if not, write to the Free Software 22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 23 */ 24 25 #ifndef WALLS_H 26 #define WALLS_H 27 28 #ifndef CLICK_H 29 #include "click.h" 30 #endif 31 32 extern char walls_version[]; 33 34 /* 35 * Wall collision detection and bouncing. 36 * 37 * The wall collision detection routines depend on repeatability 38 * (getting the same result even after some "neutral" calculations) 39 * and an exact determination whether a point is in space, 40 * inside the wall (crash!) or on the edge. 41 * This will be hard to achieve if only floating point would be used. 42 * However, a resolution of a pixel is a bit rough and ugly. 43 * Therefore a fixed point sub-pixel resolution is used called clicks. 44 */ 45 46 #define FLOAT_TO_INT(F) ((F) < 0 ? -(int)(0.5f-(F)) : (int)((F)+0.5f)) 47 #define DOUBLE_TO_INT(D) ((D) < 0 ? -(int)(0.5-(D)) : (int)((D)+0.5)) 48 49 typedef enum { 50 NotACrash = 0, 51 CrashUniverse = 0x01, 52 CrashWall = 0x02, 53 CrashTarget = 0x04, 54 CrashTreasure = 0x08, 55 CrashCannon = 0x10, 56 CrashUnknown = 0x20, 57 CrashWormHole = 0x40, 58 CrashWallSpeed = 0x80, 59 CrashWallNoFuel = 0x100, 60 CrashWallAngle = 0x200 61 } move_crash_t; 62 63 typedef enum { 64 NotABounce = 0, 65 BounceHorLo = 0x01, 66 BounceHorHi = 0x02, 67 BounceVerLo = 0x04, 68 BounceVerHi = 0x08, 69 BounceLeftDown = 0x10, 70 BounceLeftUp = 0x20, 71 BounceRightDown = 0x40, 72 BounceRightUp = 0x80, 73 BounceEdge = 0x0100 74 } move_bounce_t; 75 76 typedef struct { 77 int edge_wrap; 78 int edge_bounce; 79 int wall_bounce; 80 int cannon_crashes; 81 int target_crashes; 82 int treasure_crashes; 83 int wormhole_warps; 84 int phased; 85 object *obj; 86 player *pl; 87 } move_info_t; 88 89 typedef struct { 90 const move_info_t *mip; 91 move_crash_t crash; 92 move_bounce_t bounce; 93 clpos pos; 94 vector vel; 95 clvec todo; 96 clvec done; 97 int dir; 98 int cannon; 99 int wormhole; 100 int target; 101 int treasure; 102 } move_state_t; 103 104 struct move_parameters { 105 click_t click_width; /* Map width in clicks */ 106 click_t click_height; /* Map width in clicks */ 107 108 int max_shielded_angle; /* max player bounce angle */ 109 int max_unshielded_angle; /* max player bounce angle */ 110 111 unsigned long obj_bounce_mask; /* which objects bounce? */ 112 unsigned long obj_cannon_mask; /* objects crash cannons? */ 113 unsigned long obj_target_mask; /* object target hit? */ 114 unsigned long obj_treasure_mask; /* objects treasure crash? */ 115 }; 116 117 void Move_segment(move_state_t *ms); 118 119 #endif 120