| 1 | /* |
| 2 | C-Dogs SDL |
| 3 | A port of the legendary (and fun) action/arcade cdogs. |
| 4 | Copyright (C) 1995 Ronny Wester |
| 5 | Copyright (C) 2003 Jeremy Chin |
| 6 | Copyright (C) 2003-2007 Lucas Martin-King |
| 7 | |
| 8 | This program is free software; you can redistribute it and/or modify |
| 9 | it under the terms of the GNU General Public License as published by |
| 10 | the Free Software Foundation; either version 2 of the License, or |
| 11 | (at your option) any later version. |
| 12 | |
| 13 | This program is distributed in the hope that it will be useful, |
| 14 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | GNU General Public License for more details. |
| 17 | |
| 18 | You should have received a copy of the GNU General Public License |
| 19 | along with this program; if not, write to the Free Software |
| 20 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 21 | |
| 22 | This file incorporates work covered by the following copyright and |
| 23 | permission notice: |
| 24 | |
| 25 | Copyright (c) 2013-2014, 2016-2021, 2023 Cong Xu |
| 26 | All rights reserved. |
| 27 | |
| 28 | Redistribution and use in source and binary forms, with or without |
| 29 | modification, are permitted provided that the following conditions are met: |
| 30 | |
| 31 | Redistributions of source code must retain the above copyright notice, this |
| 32 | list of conditions and the following disclaimer. |
| 33 | Redistributions in binary form must reproduce the above copyright notice, |
| 34 | this list of conditions and the following disclaimer in the documentation |
| 35 | and/or other materials provided with the distribution. |
| 36 | |
| 37 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
| 38 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 39 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 40 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE |
| 41 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 42 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 43 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS |
| 44 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN |
| 45 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
| 46 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE |
| 47 | POSSIBILITY OF SUCH DAMAGE. |
| 48 | */ |
| 49 | #pragma once |
| 50 | |
| 51 | #include "actors.h" |
| 52 | #include "draw/draw_buffer.h" |
| 53 | #include "gamedata.h" |
| 54 | #include "grafx_bg.h" |
| 55 | |
| 56 | typedef struct |
| 57 | { |
| 58 | const Pic *Head; |
| 59 | struct vec2i HeadOffset; |
| 60 | const Pic *HeadParts[HEAD_PART_COUNT]; |
| 61 | struct vec2i HeadPartOffsets[HEAD_PART_COUNT]; |
| 62 | const Pic *Body; |
| 63 | struct vec2i BodyOffset; |
| 64 | const Pic *Legs; |
| 65 | struct vec2i LegsOffset; |
| 66 | const Pic *Guns[MAX_BARRELS]; |
| 67 | struct vec2i GunOffsets[MAX_BARRELS]; |
| 68 | // In draw order |
| 69 | const Pic *OrderedPics[BODY_PART_COUNT + MAX_BARRELS - 1]; |
| 70 | struct vec2i OrderedOffsets[BODY_PART_COUNT + MAX_BARRELS - 1]; |
| 71 | bool IsDead; |
| 72 | bool IsDying; |
| 73 | color_t ShadowMask; |
| 74 | color_t Mask; |
| 75 | const CharSprites *Sprites; |
| 76 | } ActorPics; |
| 77 | |
| 78 | void DrawCharacterSimple( |
| 79 | const Character *c, const struct vec2i pos, const direction_e d, |
| 80 | const bool hilite, const bool showGun, const WeaponClass *gun); |
| 81 | void DrawHead( |
| 82 | SDL_Renderer *renderer, const Character *c, const direction_e dir, |
| 83 | const struct vec2i pos); |
| 84 | |
| 85 | const Pic *GetHeadPic( |
| 86 | const CharacterClass *c, const direction_e dir, const bool isGrimacing, |
| 87 | const CharColors *colors); |
| 88 | const Pic *GetHeadPartPic( |
| 89 | const char *name, const HeadPart hp, const direction_e dir, const bool isGrimacing, |
| 90 | const CharColors *colors); |
| 91 | ActorPics GetCharacterPics( |
| 92 | const Character *c, const direction_e dir, const direction_e legDir, |
| 93 | const ActorAnimation anim, const int frame, const WeaponClass *gun, |
| 94 | const gunstate_e barrelStates[MAX_BARRELS], const bool isGrimacing, |
| 95 | const color_t shadowMask, const color_t *mask, const CharColors *colors, |
| 96 | const int deadPic); |
| 97 | ActorPics GetCharacterPicsFromActor(const TActor *a); |
| 98 | void DrawActorPics( |
| 99 | const ActorPics *pics, const struct vec2i pos, const Rect2i bounds); |
| 100 | void DrawLaserSight( |
| 101 | const ActorPics *pics, const TActor *a, const struct vec2i picPos); |