1 2 /*************************************************************************** 3 location.h - Location on a level map 4 ------------------- 5 begin : Mon May 12 2003 6 copyright : (C) 2003 by Gabor Torok 7 email : cctorok@yahoo.com 8 ***************************************************************************/ 9 10 /*************************************************************************** 11 * * 12 * This program is free software; you can redistribute it and/or modify * 13 * it under the terms of the GNU General Public License as published by * 14 * the Free Software Foundation; either version 2 of the License, or * 15 * (at your option) any later version. * 16 * * 17 ***************************************************************************/ 18 19 #ifndef LOCATION_H 20 #define LOCATION_H 21 #pragma once 22 23 #include "render.h" 24 #include "texture.h" 25 26 class Effect; 27 class RenderedItem; 28 class Shape; 29 class RenderedCreature; 30 class Texture; 31 32 /** 33 *@author Gabor Torok 34 */ 35 36 /// extra display information 37 38 class DisplayInfo { 39 public: 40 GLfloat red, green, blue; 41 GLfloat offset_x, offset_y, offset_z; 42 DisplayInfo()43 DisplayInfo() { 44 reset(); 45 } 46 ~DisplayInfo()47 ~DisplayInfo() { 48 } 49 reset()50 inline void reset() { 51 red = green = blue = 1.0f; 52 offset_x = offset_y = offset_z = 0.0f; 53 } 54 copy(DisplayInfo * di)55 inline void copy( DisplayInfo *di ) { 56 if ( di ) { 57 red = di->red; 58 green = di->green; 59 blue = di->blue; 60 offset_x = di->offset_x; 61 offset_y = di->offset_y; 62 offset_z = di->offset_z; 63 } else { 64 reset(); 65 } 66 } 67 }; 68 69 /// The ground texture on an outdoor map location. 70 71 class OutdoorTexture { 72 public: 73 float offsetX, offsetY, width, height; // measured in map units 74 float angle; 75 bool horizFlip, vertFlip; 76 Texture texture; 77 int outdoorThemeRef; 78 OutdoorTexture()79 OutdoorTexture() 80 : offsetX( 0 ) 81 , offsetY( 0 ) 82 , width( 2 ) 83 , height( 2 ) 84 , angle( 0 ) 85 , horizFlip( false ) 86 , vertFlip( false ) 87 , texture() 88 , outdoorThemeRef( -1 ) { 89 } 90 }; 91 92 /// A location on the level map and its contents. 93 94 class Location { 95 public: 96 // shapes 97 Uint16 x, y, z; 98 float heightPos; 99 Shape *shape; 100 RenderedItem *item; 101 RenderedCreature *creature; 102 Color *outlineColor; 103 float angleX, angleY, angleZ; 104 float moveX, moveY, moveZ; 105 int texIndex; 106 Location()107 Location() { 108 this->creature = NULL; 109 this->heightPos = 0; 110 this->item = NULL; 111 this->outlineColor = NULL; 112 this->shape = NULL; 113 this->x = this->y = this->z = 0; 114 this->angleX = this->angleY = this->angleZ = 0; 115 this->moveX = this->moveY = this->moveZ = 0; 116 this->texIndex = -1; 117 } 118 }; 119 120 /// Controls effects on a specific map location. 121 122 class EffectLocation { 123 public: 124 Uint16 x, y, z; 125 GLuint effectDuration; 126 GLuint damageEffectCounter; 127 Effect *effect; 128 int effectType; 129 GLuint effectDelay; 130 bool forever; 131 float heightPos; 132 133 // effects setEffectType(int n)134 inline void setEffectType( int n ) { 135 this->effectType = n; 136 } getEffectType()137 inline int getEffectType() { 138 return effectType; 139 } getEffect()140 inline Effect *getEffect() { 141 return effect; 142 } getDamageEffect()143 inline int getDamageEffect() { 144 return damageEffectCounter; 145 } resetDamageEffect()146 inline void resetDamageEffect() { 147 damageEffectCounter = SDL_GetTicks(); 148 } isEffectOn()149 inline bool isEffectOn() { 150 return ( forever || SDL_GetTicks() - damageEffectCounter < effectDuration + effectDelay ? true : false ); 151 } isInDelay()152 inline bool isInDelay() { 153 return ( SDL_GetTicks() - damageEffectCounter < effectDelay ? true : false ); 154 } setEffectDelay(GLuint n)155 inline void setEffectDelay( GLuint n ) { 156 this->effectDelay = n; 157 } getEffectDelay()158 inline GLuint getEffectDelay() { 159 return effectDelay; 160 } 161 DECLARE_NOISY_OPENGL_SUPPORT(); 162 }; 163 164 #endif 165 166