1 /* 2 XorGramana Copyright 2009 James W. Morris, james@jwm-art.net 3 4 This file is part of XorGramana. 5 6 XorGramana is free software: you can redistribute it and/or modify 7 it under the terms of the GNU General Public License as published by 8 the Free Software Foundation, either version 3 of the License, or 9 (at your option) any later version. 10 11 XorGramana is distributed in the hope that it will be useful, 12 but WITHOUT ANY WARRANTY; without even the implied warranty of 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 GNU General Public License for more details. 15 16 You should have received a copy of the GNU General Public License 17 along with XorGramana. If not, see <http://www.gnu.org/licenses/>. 18 */ 19 #ifndef _PLAYER_H 20 #define _PLAYER_H 21 22 #include "actions.h" 23 #include "map.h" 24 25 enum PLAY_STATE 26 { 27 PLAY_CONTINUE, /* no movement, as such */ 28 PLAY_PROCESS_MOVE, /* process movement */ 29 PLAY_SWAP, /* player swap */ 30 PLAY_QUIT, /* user quit */ 31 PLAY_ZERO_MOVES, /* all moves depleted */ 32 PLAY_GOTCHA, /* player death */ 33 PLAY_COMPLETE, /* masks collected, exit reached */ 34 PLAY_RECORD=0x80 /* record move to replay - or'd with above values if appropriate */ 35 }; 36 37 struct xor_player 38 { 39 ctr_t move_no; /* no longer decrementing from max_moves, due to mask pickup * 40 * incrementing the noof moves available. */ 41 ctr_t masks_collected; 42 unsigned player : 1; /* set = player 2, not set = player 1 */ 43 unsigned p0_alive : 1; 44 unsigned p1_alive : 1; 45 unsigned wall_vis : 1; 46 unsigned replay : 1; 47 unsigned have_map : 4; /* 1 bit set for each piece collected */ 48 } player; 49 50 void player_init(); 51 52 53 /* 54 see map.h map.c for xor_map definition. see actions.h for 55 values for move variable passed to player_move. 56 */ 57 58 /* player move, initiates player movement, but does not move player */ 59 enum PLAY_STATE player_move(su_t move); 60 61 /* player_process_move 62 63 moves player - and thing that player pushes - if any. 64 return values: 65 a) 0 if object player can push is blocked 66 b) a new xor_move pointer 67 if object can be pushed - pointer is the xor_move 68 for object to be pushed. 69 c) the same xor_move pointer as player's xor_move 70 if there is nothing to push 71 72 */ 73 struct xor_move* player_process_move(struct xor_move* pmv); 74 enum PLAY_STATE player_process_old_pos(struct xor_move* pmv); 75 enum PLAY_STATE pushed_process_new_pos(struct xor_move* omv); 76 77 /* player_process_collect 78 processes collection of objects by player, 79 ie masks (and sad masks/switch), map-pieces. 80 refers to the xor_move (rather than map) for 81 identification of object. 82 */ 83 void player_process_collect(struct xor_move* pmv); 84 void player_death(su_t icon); 85 void player_process_map_pc(struct xor_move* pmv); 86 87 #endif 88