diff --git a/SoDlib/SoDLib.depend b/SoDlib/SoDLib.depend index 6d956ed..8e7f749 100644 --- a/SoDlib/SoDLib.depend +++ b/SoDlib/SoDLib.depend @@ -1 +1,591 @@ # depslib dependency file v1.0 +1396800264 source:d:\work\my\sod\sodlib\hgeanim.cpp + + +1396800288 d:\work\my\sod\hge181\include\hgeanim.h + "hgesprite.h" + +1396800288 d:\work\my\sod\hge181\include\hgesprite.h + "hge.h" + "hgerect.h" + +1396800288 d:\work\my\sod\hge181\include\hge.h + + +1396800288 d:\work\my\sod\hge181\include\hgerect.h + +1396800264 source:d:\work\my\sod\sodlib\hgecolor.cpp + + + +1396800288 d:\work\my\sod\hge181\include\hgecolor.h + "hge.h" + +1396800264 source:d:\work\my\sod\sodlib\hgefont.cpp + + + + +1396800288 d:\work\my\sod\hge181\include\hgefont.h + "hge.h" + "hgesprite.h" + +1397716650 source:d:\work\my\sod\sodlib\hgegui.cpp + + +1397730036 d:\work\my\sod\sodlib\include\hgegui.h + "hge.h" + "hgesprite.h" + "hgerect.h" + +1396800264 source:d:\work\my\sod\sodlib\hgeguictrls.cpp + + + + + +1396800288 d:\work\my\sod\hge181\include\hgeguictrls.h + "hge.h" + "hgesprite.h" + "hgefont.h" + "hgerect.h" + "hgegui.h" + +1397587904 d:\work\my\sod\hge181\include\hgegui.h + "hge.h" + "hgesprite.h" + "hgerect.h" + +1396800264 source:d:\work\my\sod\sodlib\hgerect.cpp + + + +1396800264 source:d:\work\my\sod\sodlib\hgesprite.cpp + + + +1396800271 source:d:\work\my\sod\sodlib\src\animation.cpp + "Animation.h" + +1396800264 d:\work\my\sod\sodlib\include\animation.h + + +1397405489 d:\work\my\sod\sodlib\include\sodlib.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1396800259 d:\work\my\sod\box2d\box2d.h + + + + + + + + + + + + + + + + + + + + + + + + + + + + +1396800260 d:\work\my\sod\box2d\common\b2settings.h + + + +1396800260 d:\work\my\sod\box2d\common\b2draw.h + + +1396800260 d:\work\my\sod\box2d\common\b2math.h + + + + + + +1396800260 d:\work\my\sod\box2d\common\b2timer.h + + +1396800259 d:\work\my\sod\box2d\collision\shapes\b2circleshape.h + + +1396800259 d:\work\my\sod\box2d\collision\shapes\b2shape.h + + + + +1396800260 d:\work\my\sod\box2d\common\b2blockallocator.h + + +1396800260 d:\work\my\sod\box2d\collision\b2collision.h + + + +1396800259 d:\work\my\sod\box2d\collision\shapes\b2edgeshape.h + + +1396800259 d:\work\my\sod\box2d\collision\shapes\b2chainshape.h + + +1396800259 d:\work\my\sod\box2d\collision\shapes\b2polygonshape.h + + +1396800260 d:\work\my\sod\box2d\collision\b2broadphase.h + + + + + +1396800260 d:\work\my\sod\box2d\collision\b2dynamictree.h + + + +1396800260 d:\work\my\sod\box2d\common\b2growablestack.h + + + +1396800260 d:\work\my\sod\box2d\collision\b2distance.h + + +1396800260 d:\work\my\sod\box2d\collision\b2timeofimpact.h + + + +1396800261 d:\work\my\sod\box2d\dynamics\b2body.h + + + + +1396800261 d:\work\my\sod\box2d\dynamics\b2fixture.h + + + + +1396800261 d:\work\my\sod\box2d\dynamics\b2worldcallbacks.h + + +1396800261 d:\work\my\sod\box2d\dynamics\b2timestep.h + + +1396800261 d:\work\my\sod\box2d\dynamics\b2world.h + + + + + + + +1396800260 d:\work\my\sod\box2d\common\b2stackallocator.h + + +1396800261 d:\work\my\sod\box2d\dynamics\b2contactmanager.h + + +1396800260 d:\work\my\sod\box2d\dynamics\contacts\b2contact.h + + + + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2distancejoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2joint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2frictionjoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2gearjoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2wheeljoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2mousejoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2prismaticjoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2pulleyjoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2revolutejoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2ropejoint.h + + +1396800261 d:\work\my\sod\box2d\dynamics\joints\b2weldjoint.h + + +1396800264 d:\work\my\sod\sodlib\include\tinyxml.h + + + + + + + + + "tinystr.h" + +1396800264 d:\work\my\sod\sodlib\include\tinystr.h + + + +1396800264 d:\work\my\sod\sodlib\include\muparser.h + + "muParserBase.h" + "muParserTemplateMagic.h" + +1396800264 d:\work\my\sod\sodlib\include\muparserbase.h + + + + + + + "muParserDef.h" + "muParserStack.h" + "muParserTokenReader.h" + "muParserBytecode.h" + "muParserError.h" + +1396800264 d:\work\my\sod\sodlib\include\muparserdef.h + + + + + "muParserFixes.h" + +1396800264 d:\work\my\sod\sodlib\include\muparserfixes.h + +1396800264 d:\work\my\sod\sodlib\include\muparserstack.h + + + + + "muParserError.h" + "muParserToken.h" + +1396800264 d:\work\my\sod\sodlib\include\muparsererror.h + + + + + + + "muParserDef.h" + +1396800264 d:\work\my\sod\sodlib\include\muparsertoken.h + + + + + + "muParserError.h" + "muParserCallback.h" + +1396800264 d:\work\my\sod\sodlib\include\muparsercallback.h + "muParserDef.h" + +1396800264 d:\work\my\sod\sodlib\include\muparsertokenreader.h + + + + + + + + + "muParserDef.h" + "muParserToken.h" + +1396800264 d:\work\my\sod\sodlib\include\muparserbytecode.h + + + + + "muParserDef.h" + "muParserError.h" + "muParserToken.h" + +1396800264 d:\work\my\sod\sodlib\include\muparsertemplatemagic.h + + "muParserError.h" + +1396800264 d:\work\my\sod\sodlib\include\exception.h + + + +1400870836 d:\work\my\sod\sodlib\include\game.h + + +1400622720 d:\work\my\sod\sodlib\include\conditionprototype.h + + +1396800264 d:\work\my\sod\sodlib\include\condition.h + + +1399327188 d:\work\my\sod\sodlib\include\effectaction.h + + +1400538047 d:\work\my\sod\sodlib\include\effectprototype.h + + +1400533750 d:\work\my\sod\sodlib\include\effect.h + + +1397717394 d:\work\my\sod\sodlib\include\characteractioncause.h + + +1397805132 d:\work\my\sod\sodlib\include\characteractioneffect.h + + +1400438363 d:\work\my\sod\sodlib\include\characteraction.h + + +1400535025 d:\work\my\sod\sodlib\include\characterhotspot.h + + +1400534014 d:\work\my\sod\sodlib\include\character.h + + +1396800264 d:\work\my\sod\sodlib\include\nonplayercharacter.h + + +1396800264 d:\work\my\sod\sodlib\include\playercharacter.h + + +1396800264 d:\work\my\sod\sodlib\include\groundline.h + + +1396800264 d:\work\my\sod\sodlib\include\platform.h + + +1400871091 d:\work\my\sod\sodlib\include\mapanimation.h + + +1396800264 d:\work\my\sod\sodlib\include\debugdraw.h + + +1397592908 d:\work\my\sod\sodlib\include\guiwindow.h + + + +1397730007 d:\work\my\sod\sodlib\include\hgeguimenuitem.h + + +1398288343 d:\work\my\sod\sodlib\include\hgeguieditablelabel.h + + +1400835852 source:d:\work\my\sod\sodlib\src\character.cpp + "Character.h" + +1400440291 source:d:\work\my\sod\sodlib\src\characteraction.cpp + "CharacterAction.h" + +1397718436 source:d:\work\my\sod\sodlib\src\characteractioncause.cpp + "CharacterActionCause.h" + +1397809509 source:d:\work\my\sod\sodlib\src\characteractioneffect.cpp + "CharacterActionEffect.h" + +1400536736 source:d:\work\my\sod\sodlib\src\characterhotspot.cpp + "CharacterHotSpot.h" + +1396800271 source:d:\work\my\sod\sodlib\src\condition.cpp + "Condition.h" + +1400623051 source:d:\work\my\sod\sodlib\src\conditionprototype.cpp + "ConditionPrototype.h" + +1396800271 source:d:\work\my\sod\sodlib\src\construction.cpp + "Construction.h" + +1396800264 d:\work\my\sod\sodlib\include\construction.h + + +1396800271 source:d:\work\my\sod\sodlib\src\debugdraw.cpp + "DebugDraw.h" + +1400627934 source:d:\work\my\sod\sodlib\src\effect.cpp + "Effect.h" + +1400525309 source:d:\work\my\sod\sodlib\src\effectaction.cpp + "EffectAction.h" + +1400627796 source:d:\work\my\sod\sodlib\src\effectprototype.cpp + "EffectPrototype.h" + +1396800271 source:d:\work\my\sod\sodlib\src\exception.cpp + "Exception.h" + +1400801701 source:d:\work\my\sod\sodlib\src\groundline.cpp + "GroundLine.h" + +1397595838 source:d:\work\my\sod\sodlib\src\guiwindow.cpp + "GUIWindow.h" + +1399216062 source:d:\work\my\sod\sodlib\src\hgeguieditablelabel.cpp + "hgeGUIEditableLabel.h" + +1398244296 source:d:\work\my\sod\sodlib\src\hgeguimenuitem.cpp + "hgeGUIMenuItem.h" + +1400871112 source:d:\work\my\sod\sodlib\src\mapanimation.cpp + "MapAnimation.h" + +1396800271 source:d:\work\my\sod\sodlib\src\muparser.cpp + "muParser.h" + "muParserTemplateMagic.h" + + + + +1396800271 source:d:\work\my\sod\sodlib\src\muparserbase.cpp + "muParserBase.h" + "muParserTemplateMagic.h" + + + + + + + + + +1396800271 source:d:\work\my\sod\sodlib\src\muparserbytecode.cpp + "muParserBytecode.h" + + + + + + "muParserDef.h" + "muParserError.h" + "muParserToken.h" + "muParserStack.h" + "muParserTemplateMagic.h" + +1396800271 source:d:\work\my\sod\sodlib\src\muparsercallback.cpp + "muParserCallback.h" + +1396800271 source:d:\work\my\sod\sodlib\src\muparserdll.cpp + + "muParserDLL.h" + "muParser.h" + "muParserInt.h" + "muParserError.h" + +1396800264 d:\work\my\sod\sodlib\include\muparserdll.h + +1396800264 d:\work\my\sod\sodlib\include\muparserint.h + "muParserBase.h" + + +1396800271 source:d:\work\my\sod\sodlib\src\muparsererror.cpp + "muParserError.h" + +1396800271 source:d:\work\my\sod\sodlib\src\muparserint.cpp + "muParserInt.h" + + + + +1396800271 source:d:\work\my\sod\sodlib\src\muparsertest.cpp + "muParserTest.h" + + + + + +1396800264 d:\work\my\sod\sodlib\include\muparsertest.h + + + + "muParser.h" + "muParserInt.h" + +1396800271 source:d:\work\my\sod\sodlib\src\muparsertokenreader.cpp + + + + + + + "muParserTokenReader.h" + "muParserBase.h" + +1396800271 source:d:\work\my\sod\sodlib\src\nonplayercharacter.cpp + "NonPlayerCharacter.h" + +1396800271 source:d:\work\my\sod\sodlib\src\platform.cpp + "Platform.h" + +1396800271 source:d:\work\my\sod\sodlib\src\playercharacter.cpp + "PlayerCharacter.h" + +1396800271 source:d:\work\my\sod\sodlib\tinystr.cpp + "tinystr.h" + +1396800271 source:d:\work\my\sod\sodlib\tinyxml.cpp + + + + "tinyxml.h" + +1396800271 source:d:\work\my\sod\sodlib\tinyxmlerror.cpp + "tinyxml.h" + +1396800271 source:d:\work\my\sod\sodlib\tinyxmlparser.cpp + + + "tinyxml.h" + + diff --git a/SoDlib/SoDlib.layout b/SoDlib/SoDlib.layout index dce6a5c..be0afe4 100644 --- a/SoDlib/SoDlib.layout +++ b/SoDlib/SoDlib.layout @@ -1,183 +1,226 @@ - + - + + + + - + - + - + - + - - - - + - + - + - + - - - - - - + - + - + - + - + - - - - - - + - + - + - + - + + + + + + + + - + + + + + + - + - + - + - + - + - + - + + + + + + - + + + + + + - + - + - + - + - + - + + + + + + - + - + - + + + + - + - + - + - + - + - + - + - + - + - + - + - + + + + + + - + - + - + - + - + - + - + - + - + + + + + + - + - + + + + + + + + + + + + + + diff --git a/SoDlib/include/Character.h b/SoDlib/include/Character.h index ebf604c..d92daf3 100644 --- a/SoDlib/include/Character.h +++ b/SoDlib/include/Character.h @@ -38,7 +38,7 @@ class Character float getHalfWidth(); int getOnGround(); - float getHotSpotX(int index), getHotSpotY(int index); + float getHotSpotX(int index), getHotSpotY(int index); int getHotSpotIndex(char* name); float getAnimTime(); diff --git a/SoDlib/include/CharacterHotSpot.h b/SoDlib/include/CharacterHotSpot.h index 9cb712b..dc8932b 100644 --- a/SoDlib/include/CharacterHotSpot.h +++ b/SoDlib/include/CharacterHotSpot.h @@ -12,10 +12,12 @@ class CharacterHotSpot CharacterHotSpot(TiXmlElement* xml); virtual ~CharacterHotSpot(); - b2Shape* getShape(); + b2Shape* getShape(); + char* getName(); void setName(char* name); protected: b2Shape* shape; - int type; + int type; + char* name; private: }; diff --git a/SoDlib/include/ConditionPrototype.h b/SoDlib/include/ConditionPrototype.h index 0d39d43..3d593e6 100644 --- a/SoDlib/include/ConditionPrototype.h +++ b/SoDlib/include/ConditionPrototype.h @@ -21,14 +21,17 @@ class ConditionPrototype virtual ~ConditionPrototype(); void loadFromXml(TiXmlElement* xml); + void saveToXml(TiXmlElement* elem); void setParam(int index, float value); void setParamsFromCharacter(Character* character); void setName(const char* name); char* getName(); - int getType(); + int getType(); void setType(int type); float getValue(), getDuration(), getInterval(); + const char* getValueFormula(); const char* getDurationFormula(); const char* getIntervalFormula(); + void setValueFormula(char* formula), setDurationFormula(char* formula), setIntervalFormula(char* formula); Condition* spawnCondition(Character* inflictor, Character* bearer); protected: diff --git a/SoDlib/include/Effect.h b/SoDlib/include/Effect.h index e0b6883..432cbb0 100644 --- a/SoDlib/include/Effect.h +++ b/SoDlib/include/Effect.h @@ -16,6 +16,7 @@ class Effect float getTime(); void setPosition(b2Vec2 position); b2Vec2 getPosition(); + void setHotSpotIndex(int index); void setAnimation(hgeAnimation* animation, int blendMode); @@ -27,6 +28,7 @@ class Effect float time; int r, g, b, a; float scale; + int hotSpotIndex; EffectPrototype* prototype; diff --git a/SoDlib/include/EffectPrototype.h b/SoDlib/include/EffectPrototype.h index 9de33d9..21c58b5 100644 --- a/SoDlib/include/EffectPrototype.h +++ b/SoDlib/include/EffectPrototype.h @@ -67,8 +67,8 @@ class EffectPrototype Effect* spawnEffect(Character* character); Effect* spawnEffect(Effect* effect); - int getPositionType(), getAreaType(), getHotSpotIndex(); - void setPositionType(int type), setAreaType(int type); + int getPositionType(), getAreaType(); char* getHotSpotName(); + void setPositionType(int type), setAreaType(int type), setHotSpotName(char* name); int getActionsCount(); EffectAction* getAction(int index); void addAction(), removeAction(int index); @@ -102,7 +102,8 @@ class EffectPrototype float* params; - int positionType, areaType, hotSpotIndex; + int positionType, areaType; + char* hotSpotName; EffectAction** actions; int actionsCount; char** animations; int animationsCount; int blendMode; diff --git a/SoDlib/include/Game.h b/SoDlib/include/Game.h index 4e0c2e7..2b832a5 100644 --- a/SoDlib/include/Game.h +++ b/SoDlib/include/Game.h @@ -114,25 +114,23 @@ class Game int getMapAnimationsCount(); MapAnimation* getMapAnimation(int index); - int getEffectPrototypesCount(); - EffectPrototype* getEffectPrototype(int index); + int getEffectPrototypesCount(); EffectPrototype* getEffectPrototype(int index); void addEffectPrototype(), removeEffectPrototype(int index); - int getConditionPrototypesCount(); - ConditionPrototype* getConditionPrototype(int index); + int getConditionPrototypesCount(); ConditionPrototype* getConditionPrototype(int index); void addConditionPrototype(), removeConditionPrototype(int index); HGE* getHge(); b2World* getWorld(); hgeGUI* getGUI(); - int getScreenWidth(), getScreenHeight(); - float getWorldScreenWidth(), getWorldScreenHeight(); - float getMapWidth(), getMapHeight(); + int getScreenWidth(), getScreenHeight(); + float getViewportWidth(), getViewportHeight(), getHalfViewportWidth(), getHalfViewportHeight(); + float getMapWidth(), getMapHeight(), getHalfMapWidth(), getHalfMapHeight(); - float worldX(float screenX); - float worldY(float screenY); - float screenX(float worldX); - float screenY(float worldY); + float worldX(float screenX); float worldX(float screenX, float ratio); + float worldY(float screenY); float worldY(float screenY, float ratio); + float screenX(float worldX); float screenX(float worldX, float ratio); + float screenY(float worldY); float screenY(float worldY, float ratio); b2Vec2 screenPos(b2Vec2 worldPos); float getScaleFactor(), getFullScale(); @@ -162,6 +160,9 @@ class Game GroundLine** groundLines; int groundLinesCount; MapAnimation** mapAnimations; int mapAnimationsCount; + int backLayersCount, frontLayersCount; float* backLayerRatios; float* frontLayerRatios; + int** backLayersMapAnimations; int** frontLayersMapAnimations; int* backLayersMapAnimationsCounts; int* frontLayersMapAnimationsCounts; + Platform** platforms; int platformsCount; Character** characters; int charactersCount; EffectPrototype** effectPrototypes; int effectPrototypesCount; @@ -175,8 +176,8 @@ class Game int32 velocityIterations; int32 positionIterations; - int screenWidth, screenHeight; - float mapWidth, mapHeight; + int screenWidth, screenHeight; float viewportWidth, viewportHeight, halfViewportWidth, halfViewportHeight; + float mapWidth, mapHeight, halfMapWidth, halfMapHeight; b2Vec2 cameraPos; float mouseX, mouseY; diff --git a/SoDlib/include/MapAnimation.h b/SoDlib/include/MapAnimation.h index 93fe0f3..0ffdcd6 100644 --- a/SoDlib/include/MapAnimation.h +++ b/SoDlib/include/MapAnimation.h @@ -9,7 +9,7 @@ class MapAnimation MapAnimation(Game* game, hgeAnimation* anim, float x, float y, float angle); virtual ~MapAnimation(); - void draw(bool schematicMode); + void draw(float ratio, bool schematicMode); void move(float dx, float dy); protected: float x, y, angle; diff --git a/SoDlib/libSoDlib.a b/SoDlib/libSoDlib.a index 67deabd..c3e8cdb 100644 Binary files a/SoDlib/libSoDlib.a and b/SoDlib/libSoDlib.a differ diff --git a/SoDlib/src/Character.cpp b/SoDlib/src/Character.cpp index c2a1578..4530f01 100644 --- a/SoDlib/src/Character.cpp +++ b/SoDlib/src/Character.cpp @@ -447,16 +447,16 @@ void Character::update(float dt) { } } - if (position.x > game->getMapWidth()) { - position.x = game->getMapWidth(); + if (position.x > game->getHalfMapWidth()) { + position.x = game->getHalfMapWidth(); speed.x = 0; } - if (position.x < 0) { - position.x = 0; + if (position.x < -game->getHalfMapWidth()) { + position.x = -game->getHalfMapWidth(); speed.x = 0; } - if (position.y > game->getMapHeight()) { - position.y = game->getMapHeight(); + if (position.y > game->getHalfMapHeight()) { + position.y = game->getHalfMapHeight(); speed.y = 0; } // if (position.y < 0) { @@ -584,6 +584,14 @@ float Character::getHotSpotX(int index) { } float Character::getHotSpotY(int index) { return position.y + animatedValue( frameHotSpotY[currentMove][currentFrame][index], frameHotSpotY[currentMove][nextFrame][index] ); +} +int Character::getHotSpotIndex(char* name) { + for (int i = 0; i < hotSpotsCount; i++) { + if ( compareStrings( name, hotSpots[i]->getName() ) ) { + return i; + } + } + return -1; } float Character::getAnimTime() { diff --git a/SoDlib/src/CharacterHotSpot.cpp b/SoDlib/src/CharacterHotSpot.cpp index 40e99d2..ca63e34 100644 --- a/SoDlib/src/CharacterHotSpot.cpp +++ b/SoDlib/src/CharacterHotSpot.cpp @@ -3,7 +3,9 @@ CharacterHotSpot::CharacterHotSpot(b2Shape* shape, int type) { this->shape = shape; - this->type = type; + this->type = type; + + name = ""; } CharacterHotSpot::CharacterHotSpot(TiXmlElement* xml) @@ -13,15 +15,31 @@ CharacterHotSpot::CharacterHotSpot(TiXmlElement* xml) shape = new b2PolygonShape(); ((b2PolygonShape*)shape)->SetAsBox(0.5f * w, 0.5f * h); - type = 1; + type = 1; + if (xml->Attribute("name")) { + name = copyString( xml->Attribute("name") ); + } + else { + name = ""; + } } CharacterHotSpot::~CharacterHotSpot() { - //dtor + delete name; + delete shape; } b2Shape* CharacterHotSpot::getShape() { return this->shape; } + +char* CharacterHotSpot::getName() { + return name; +} +void CharacterHotSpot::setName(char* _name) { + delete name; + + name = copyString(_name); +} diff --git a/SoDlib/src/ConditionPrototype.cpp b/SoDlib/src/ConditionPrototype.cpp index 9212ad4..cdac39d 100644 --- a/SoDlib/src/ConditionPrototype.cpp +++ b/SoDlib/src/ConditionPrototype.cpp @@ -14,8 +14,7 @@ ConditionPrototype::~ConditionPrototype() //dtor } -void ConditionPrototype::loadFromXml(TiXmlElement* xml) -{ +void ConditionPrototype::loadFromXml(TiXmlElement* xml) { printf("loading condition "); if ( xml->Attribute("value_formula") ) { valueParser.SetExpr( xml->Attribute("value_formula") ); @@ -64,6 +63,22 @@ void ConditionPrototype::loadFromXml(TiXmlElement* xml) printf(" done\n"); } +void ConditionPrototype::saveToXml(TiXmlElement* xml) { + char* f = copyString( getValueFormula() ); + xml->SetAttribute("value_formula", f); + delete f; + + f = copyString( getDurationFormula() ); + xml->SetAttribute("duration_formula", f); + delete f; + + f = copyString( getIntervalFormula() ); + xml->SetAttribute("interval_formula", f); + delete f; + + xml->SetAttribute("type", type); + xml->SetAttribute("name", name); +} void ConditionPrototype::setParam(int index, float value) { @@ -74,23 +89,42 @@ void ConditionPrototype::setParamsFromCharacter(Character* character) setParam( CONDITION_PROTOTYPE_PARAM_DAMAGE, character->getDamage() ); } -int ConditionPrototype::getType() -{ +int ConditionPrototype::getType() { return type; } +void ConditionPrototype::setType(int _type) { + type = _type; +} -float ConditionPrototype::getValue() -{ +float ConditionPrototype::getValue() { return valueParser.Eval(); } -float ConditionPrototype::getDuration() -{ +float ConditionPrototype::getDuration() { return durationParser.Eval(); } -float ConditionPrototype::getInterval() -{ +float ConditionPrototype::getInterval() { return intervalParser.Eval(); } +const char* ConditionPrototype::getValueFormula() { + return valueParser.GetExpr().data(); +} +const char* ConditionPrototype::getDurationFormula() { + return durationParser.GetExpr().data(); +} +const char* ConditionPrototype::getIntervalFormula() { + return intervalParser.GetExpr().data(); +} + +void ConditionPrototype::setValueFormula(char* formula) { + valueParser.SetExpr( formula ); +} +void ConditionPrototype::setDurationFormula(char* formula) { + durationParser.SetExpr( formula ); +} +void ConditionPrototype::setIntervalFormula(char* formula) { + intervalParser.SetExpr( formula ); +} + char* ConditionPrototype::getName() { return name; } diff --git a/SoDlib/src/Effect.cpp b/SoDlib/src/Effect.cpp index 240737b..27c6fe2 100644 --- a/SoDlib/src/Effect.cpp +++ b/SoDlib/src/Effect.cpp @@ -1,10 +1,23 @@ #include "Effect.h" -Effect::Effect(Game* game, EffectPrototype* prototype) -{ +Effect::Effect(Game* game, EffectPrototype* prototype) { this->game = game; this->prototype = prototype; + if (prototype->getAnimationsCount() > 0) { + setAnimation( + game->loadAnimation( + (char*)prototype->getAnimation( + game->getHge()->Random_Int(1, prototype->getAnimationsCount()) - 1 + ) + ), + prototype->getBlendMode() + ); + } + else { + animation = NULL; + } + actionTimes = new float[prototype->getActionsCount()]; actionInteractions = new int*[prototype->getActionsCount()]; for ( int i = 0; i < prototype->getActionsCount(); i++ ) { @@ -22,23 +35,19 @@ Effect::Effect(Game* game, EffectPrototype* prototype) owner = NULL; } -Effect::~Effect() -{ +Effect::~Effect() { delete animation; delete actionTimes; } -void Effect::setOwner(Character* owner) -{ +void Effect::setOwner(Character* owner) { this->owner = owner; } -Character* Effect::getOwner() -{ +Character* Effect::getOwner() { return owner; } -void Effect::initialize() -{ +void Effect::initialize() { time = prototype->evalStartExpression(EFFECT_FUNCTION_TIME); componentSpeed.x = prototype->evalStartExpression(EFFECT_FUNCTION_XSPEED); componentSpeed.y = prototype->evalStartExpression(EFFECT_FUNCTION_YSPEED); @@ -56,8 +65,11 @@ void Effect::draw(bool schematicMode) { if (schematicMode) { game->drawRect( game->screenX(position.x), game->screenY(position.y), 3, 3, 0, 0xFFFFAA00, 0xAAFFAA00 ); - } else { - animation->RenderEx( game->screenX(position.x), game->screenY(position.y), angle, scale, scale ); + } + else { + if (animation) { + animation->RenderEx( game->screenX(position.x), game->screenY(position.y), angle, scale, scale ); + } } } @@ -74,27 +86,29 @@ void Effect::update(float dt) prototype->setParam(EFFECT_PARAM_SCALE, scale); prototype->setParam(EFFECT_PARAM_DT, dt); - if ( prototype->getExpressionExists(EFFECT_FUNCTION_R) ) { - r = prototype->evalExpression(EFFECT_FUNCTION_R); - } - if ( prototype->getExpressionExists(EFFECT_FUNCTION_G) ) { - g = prototype->evalExpression(EFFECT_FUNCTION_G); - } - if ( prototype->getExpressionExists(EFFECT_FUNCTION_B) ) { - b = prototype->evalExpression(EFFECT_FUNCTION_B); - } - if ( prototype->getExpressionExists(EFFECT_FUNCTION_A) ) { - a = prototype->evalExpression(EFFECT_FUNCTION_A); - } - animation->SetColor( (a << 24) + (r << 16) + (g << 8) + b ); + if (animation) { + if ( prototype->getExpressionExists(EFFECT_FUNCTION_R) ) { + r = prototype->evalExpression(EFFECT_FUNCTION_R); + } + if ( prototype->getExpressionExists(EFFECT_FUNCTION_G) ) { + g = prototype->evalExpression(EFFECT_FUNCTION_G); + } + if ( prototype->getExpressionExists(EFFECT_FUNCTION_B) ) { + b = prototype->evalExpression(EFFECT_FUNCTION_B); + } + if ( prototype->getExpressionExists(EFFECT_FUNCTION_A) ) { + a = prototype->evalExpression(EFFECT_FUNCTION_A); + } + animation->SetColor( (a << 24) + (r << 16) + (g << 8) + b ); - if ( prototype->getExpressionExists(EFFECT_FUNCTION_SCALE) ) { - scale = prototype->evalExpression(EFFECT_FUNCTION_SCALE); - } + if ( prototype->getExpressionExists(EFFECT_FUNCTION_SCALE) ) { + scale = prototype->evalExpression(EFFECT_FUNCTION_SCALE); + } - if ( prototype->getExpressionExists(EFFECT_FUNCTION_ANGLE) ) { - angle = prototype->evalExpression(EFFECT_FUNCTION_ANGLE); -// printf("angle evaluated to %f \n", angle); + if ( prototype->getExpressionExists(EFFECT_FUNCTION_ANGLE) ) { + angle = prototype->evalExpression(EFFECT_FUNCTION_ANGLE); + // printf("angle evaluated to %f \n", angle); + } } switch ( prototype->getPositionType() ) { @@ -126,8 +140,8 @@ void Effect::update(float dt) break; case EFFECT_POSITION_TYPE_HOTSPOT: if (owner) { - position.x = owner->getHotSpotX(prototype->getHotSpotIndex()); - position.y = owner->getHotSpotY(prototype->getHotSpotIndex()); + position.x = owner->getHotSpotX(hotSpotIndex); + position.y = owner->getHotSpotY(hotSpotIndex); } break; } @@ -198,6 +212,9 @@ void Effect::setPosition(b2Vec2 position) { } b2Vec2 Effect::getPosition() { return position; +} +void Effect::setHotSpotIndex(int index) { + hotSpotIndex = index; } void Effect::setAnimation(hgeAnimation* animation, int blendMode) { diff --git a/SoDlib/src/EffectPrototype.cpp b/SoDlib/src/EffectPrototype.cpp index 4ca2468..11f65f3 100644 --- a/SoDlib/src/EffectPrototype.cpp +++ b/SoDlib/src/EffectPrototype.cpp @@ -4,7 +4,7 @@ EffectPrototype::EffectPrototype(Game* game) { this->game = game; - animationsCount = actionsCount = positionType = areaType = hotSpotIndex = 0; + animationsCount = actionsCount = positionType = areaType = 0; name = ""; @@ -12,11 +12,60 @@ EffectPrototype::EffectPrototype(Game* game) { startExpressionParsers = new mu::Parser[EFFECT_FUNCTIONS_COUNT]; expressionExists = new bool[EFFECT_FUNCTIONS_COUNT]; - params = new float[EFFECT_PARAMS_COUNT]; + for ( int i = 0; i < EFFECT_FUNCTIONS_COUNT; i++ ) { + expressionParsers[i].DefineFun("rand", frand); + expressionExists[i] = false; + startExpressionParsers[i].DefineFun("rand", frand); + } + + startExpressionParsers[EFFECT_FUNCTION_TIME].SetExpr("1"); + startExpressionParsers[EFFECT_FUNCTION_XSPEED].SetExpr("0"); + startExpressionParsers[EFFECT_FUNCTION_YSPEED].SetExpr("0"); + startExpressionParsers[EFFECT_FUNCTION_ANGLE].SetExpr("0"); + + startExpressionParsers[EFFECT_FUNCTION_R].SetExpr("255"); + startExpressionParsers[EFFECT_FUNCTION_G].SetExpr("255"); + startExpressionParsers[EFFECT_FUNCTION_B].SetExpr("255"); + startExpressionParsers[EFFECT_FUNCTION_A].SetExpr("255"); + + startExpressionParsers[EFFECT_FUNCTION_SCALE].SetExpr("1"); + + params = new float[EFFECT_PARAMS_COUNT]; + + hotSpotName = ""; + + positionType = EFFECT_POSITION_TYPE_STATIC; + areaType = EFFECT_AREA_TYPE_POINT; + blendMode = BLEND_DEFAULT; + + animationsCount = 0; + animations = new char*[animationsCount]; + + actionsCount = 0; + actions = new EffectAction*[actionsCount]; + } -EffectPrototype::~EffectPrototype() { - //dtor +EffectPrototype::~EffectPrototype() { + delete name; + + delete expressionParsers; + delete startExpressionParsers; + delete expressionExists; + + delete params; + + delete hotSpotName; + + for (int i = 0; i < animationsCount; i++) { + delete animations[i]; + } + delete animations; + + for (int i = 0; i < actionsCount; i++) { + delete actions[i]; + } + delete actions; } void EffectPrototype::loadFromXml(TiXmlElement* xml) { @@ -36,6 +85,7 @@ void EffectPrototype::loadFromXml(TiXmlElement* xml) { printf("%s formula is <%s>\n", EFFECT_FUNCTION_NAMES[i], xml->Attribute(formulaAttribName)); } else { expressionParsers[i].SetExpr("0"); + expressionParsers[i].DefineFun("rand", frand); expressionExists[i] = false; } @@ -47,7 +97,8 @@ void EffectPrototype::loadFromXml(TiXmlElement* xml) { startExpressionParsers[i].DefineFun("rand", frand); printf("start %s formula is <%s>\n", EFFECT_FUNCTION_NAMES[i], xml->Attribute(startFormulaAttribName)); } else { - startExpressionParsers[i].SetExpr("0"); + startExpressionParsers[i].SetExpr("0"); + startExpressionParsers[i].DefineFun("rand", frand); } } @@ -65,10 +116,10 @@ void EffectPrototype::loadFromXml(TiXmlElement* xml) { } else { areaType = EFFECT_AREA_TYPE_POINT; } - if (xml->Attribute("hot_spot_index")) { - hotSpotIndex = atoi(xml->Attribute("hot_spot_index")); + if (xml->Attribute("hot_spot_name")) { + hotSpotName = copyString(xml->Attribute("hot_spot_name")); } else { - hotSpotIndex = -1; + hotSpotName = ""; } if (xml->Attribute("blend_mode")) { @@ -137,7 +188,7 @@ void EffectPrototype::saveToXml(TiXmlElement* xml) { xml->SetAttribute("name", name); xml->SetAttribute("position_type", positionType); xml->SetAttribute("area_type", areaType); - xml->SetAttribute("hot_spot_index", hotSpotIndex); + xml->SetAttribute("hot_spot_name", hotSpotName); xml->SetAttribute("blend_mode", blendMode); xml->SetAttribute("animations_count", animationsCount); for (int i = 0; i < animationsCount; i++) { @@ -157,7 +208,7 @@ Effect* EffectPrototype::spawnEffect(Character* character) { Effect* newObject = new Effect(game, this); newObject->setOwner(character); newObject->setPosition( character->getPosition() ); - newObject->setAnimation( game->loadAnimation(animations[game->getHge()->Random_Int(1, animationsCount) - 1]), blendMode ); + newObject->setHotSpotIndex( character->getHotSpotIndex(hotSpotName) ); return newObject; } Effect* EffectPrototype::spawnEffect(Effect* effect) { @@ -165,7 +216,6 @@ Effect* EffectPrototype::spawnEffect(Effect* effect) { Effect* newObject = new Effect(game, this); newObject->setOwner( effect->getOwner() ); newObject->setPosition( effect->getPosition() ); - newObject->setAnimation( game->loadAnimation( animations[game->getHge()->Random_Int(1, animationsCount) - 1] ), blendMode ); //printf("new effect position is %f %f\n", effect->getPosition().x, effect->getPosition().y); clock_t et = clock(); game->updateCounter(COUNTER_EFFECTS_SPAWN, (float)(et - st)); @@ -178,8 +228,8 @@ int EffectPrototype::getPositionType() { int EffectPrototype::getAreaType() { return areaType; } -int EffectPrototype::getHotSpotIndex() { - return hotSpotIndex; +char* EffectPrototype::getHotSpotName() { + return hotSpotName; } void EffectPrototype::setPositionType(int _type) { @@ -188,6 +238,10 @@ void EffectPrototype::setPositionType(int _type) { void EffectPrototype::setAreaType(int _type) { areaType = _type; } +void EffectPrototype::setHotSpotName(char* name) { + delete hotSpotName; + hotSpotName = copyString(name); +} int EffectPrototype::getActionsCount() { return actionsCount; diff --git a/SoDlib/src/Game.cpp b/SoDlib/src/Game.cpp index f107e2c..3219f8e 100644 --- a/SoDlib/src/Game.cpp +++ b/SoDlib/src/Game.cpp @@ -4,14 +4,6 @@ Game::Game(HGE * hge) { this->world = world; this->hge = hge; - screenWidth = 1600; screenHeight = 900; - // Set up video mode - hge->System_SetState(HGE_WINDOWED, true); - hge->System_SetState(HGE_SCREENWIDTH, screenWidth); - hge->System_SetState(HGE_SCREENHEIGHT, screenHeight); - hge->System_SetState(HGE_SCREENBPP, 32); - hge->System_SetState(HGE_FPS, 60); - //groundLines = new GroundLine*[1000]; groundLinesCount = 0; //mapAnimations = new MapAnimation*[1000]; @@ -39,6 +31,7 @@ Game::Game(HGE * hge) { gravity = b2Vec2(0, 20); mapWidth = 10; mapHeight = 10; + halfMapWidth = mapWidth * 0.5f; halfMapHeight = mapHeight * 0.5f; counters = new float[COUNTERS_COUNT]; displayedCounters = new float[COUNTERS_COUNT]; @@ -48,7 +41,19 @@ Game::Game(HGE * hge) { textureNames = new char*[1000]; textures = new HTEXTURE[1000]; - texturesCount = 0; + texturesCount = 0; + + screenWidth = 1600; screenHeight = 900; + viewportWidth = screenWidth / (pixelsPerMeter * scaleFactor); + viewportHeight = screenHeight / (pixelsPerMeter * scaleFactor); + halfViewportWidth = viewportWidth * 0.5f; + halfViewportHeight = viewportHeight * 0.5f; + // Set up video mode + hge->System_SetState(HGE_WINDOWED, true); + hge->System_SetState(HGE_SCREENWIDTH, screenWidth); + hge->System_SetState(HGE_SCREENHEIGHT, screenHeight); + hge->System_SetState(HGE_SCREENBPP, 32); + hge->System_SetState(HGE_FPS, 60); //debugDraw = new DebugDraw(this); //world->SetDebugDraw((b2Draw*)debugDraw); @@ -171,7 +176,19 @@ void Game::updateWorld(float dt) { clock_t eue = clock(); counters[COUNTER_EFFECTS_UPDATE] += (float)(eue - eus); if (charactersCount > 0) { - cameraPos = characters[0]->getPosition() - b2Vec2(0.5 * screenWidth / pixelsPerMeter, 0.5 * screenHeight / pixelsPerMeter); + cameraPos = characters[0]->getPosition(); + if (cameraPos.x - halfViewportWidth < -halfMapWidth) { + cameraPos.x = -halfMapWidth + halfViewportWidth; + } + if (cameraPos.x + halfViewportWidth > halfMapWidth) { + cameraPos.x = halfMapWidth - halfViewportWidth; + } + if (cameraPos.y - halfViewportHeight < -halfMapHeight) { + cameraPos.y = -halfMapHeight + halfViewportHeight; + } + if (cameraPos.y + halfViewportHeight > halfMapHeight) { + cameraPos.y = halfMapHeight - halfViewportHeight; + } } } bool Game::updateControls() { @@ -218,6 +235,18 @@ void Game::drawGame() { } clock_t et = clock(); updateCounter(COUNTER_DRAW_GL, et - st); + + st = clock(); + + for (int i = 0; i < backLayersCount; i++) { + for (int j = 0; j < backLayersMapAnimationsCounts[i]; j++) { + mapAnimations[ backLayersMapAnimations[i][j] ]->draw(backLayerRatios[i], schematicDrawMode); + } + } + + et = clock(); + float map_t = et - st; + st = clock(); for (int i = 0; i < charactersCount; i++) { characters[i]->draw(schematicDrawMode); @@ -225,11 +254,15 @@ void Game::drawGame() { et = clock(); updateCounter(COUNTER_DRAW_CHARACTERS, et - st); st = clock(); - for (int i = 0; i < mapAnimationsCount; i++) { - mapAnimations[i]->draw(schematicDrawMode); + + for (int i = 0; i < frontLayersCount; i++) { + for (int j = 0; j < frontLayersMapAnimationsCounts[i]; j++) { + mapAnimations[ frontLayersMapAnimations[i][j] ]->draw(frontLayerRatios[i], schematicDrawMode); + } } + et = clock(); - updateCounter(COUNTER_DRAW_MAP, et - st); + updateCounter(COUNTER_DRAW_MAP, map_t + et - st); st = clock(); for (int i = 0; i < effectsCount; i++) { effects[i]->draw(schematicDrawMode); @@ -742,6 +775,26 @@ EffectPrototype* Game::getEffectPrototype(int index) { return NULL; } } +void Game::addEffectPrototype() { + EffectPrototype** _effectPrototypes = new EffectPrototype*[effectPrototypesCount + 1]; + for (int i = 0; i < effectPrototypesCount; i++) { + _effectPrototypes[i] = effectPrototypes[i]; + } + _effectPrototypes[effectPrototypesCount] = new EffectPrototype(this); + + delete effectPrototypes; + effectPrototypes = _effectPrototypes; + effectPrototypesCount++; +} +void Game::removeEffectPrototype(int index) { + if (index > -1 && index < effectPrototypesCount) { + delete effectPrototypes[index]; + for (int i = index; i < effectPrototypesCount - 1; i++) { + effectPrototypes[i] = effectPrototypes[i + 1]; + } + effectPrototypesCount--; + } +} int Game::getConditionPrototypesCount() { return conditionPrototypesCount; @@ -752,24 +805,58 @@ ConditionPrototype* Game::getConditionPrototype(int index) { } else { return NULL; } +} +void Game::addConditionPrototype() { + ConditionPrototype** _conditionPrototypes = new ConditionPrototype*[conditionPrototypesCount + 1]; + for (int i = 0; i < conditionPrototypesCount; i++) { + _conditionPrototypes[i] = conditionPrototypes[i]; + } + _conditionPrototypes[conditionPrototypesCount] = new ConditionPrototype(); + + delete conditionPrototypes; + conditionPrototypes = _conditionPrototypes; + conditionPrototypesCount++; +} +void Game::removeConditionPrototype(int index) { + if (index > -1 && index < conditionPrototypesCount) { + delete conditionPrototypes[index]; + for (int i = index; i < conditionPrototypesCount - 1; i++) { + conditionPrototypes[i] = conditionPrototypes[i + 1]; + } + conditionPrototypesCount--; + } +} + +float Game::worldX(float screenX, float ratio) { + return (screenX - getScreenWidth() * 0.5f) / (pixelsPerMeter * scaleFactor) + cameraPos.x * ratio; +} +float Game::worldY(float screenY, float ratio) { + return (screenY - getScreenHeight() * 0.5f) / (pixelsPerMeter * scaleFactor) + cameraPos.y * ratio; } float Game::worldX(float screenX) { - return (screenX / (pixelsPerMeter * scaleFactor)) + cameraPos.x; + return (screenX - getScreenWidth() * 0.5f) / (pixelsPerMeter * scaleFactor) + cameraPos.x; } float Game::worldY(float screenY) { - return (screenY / (pixelsPerMeter * scaleFactor)) + cameraPos.y; + return (screenY - getScreenHeight() * 0.5f) / (pixelsPerMeter * scaleFactor) + cameraPos.y; } + +float Game::screenX(float worldX) { + return (worldX - cameraPos.x) * (pixelsPerMeter * scaleFactor) + getScreenWidth() * 0.5f; +} +float Game::screenY(float worldY) { + return (worldY - cameraPos.y) * (pixelsPerMeter * scaleFactor) + getScreenHeight() * 0.5f; +} -float Game::screenX(float worldX) { - return (worldX - cameraPos.x) * (pixelsPerMeter * scaleFactor); -} -float Game::screenY(float worldY) { - return (worldY - cameraPos.y) * (pixelsPerMeter * scaleFactor); +float Game::screenX(float worldX, float ratio) { + return (worldX - cameraPos.x * ratio) * (pixelsPerMeter * scaleFactor) + getScreenWidth() * 0.5f; } -b2Vec2 Game::screenPos(b2Vec2 worldPos) { - return b2Vec2(this->screenX(worldPos.x), this->screenY(worldPos.y)); +float Game::screenY(float worldY, float ratio) { + return (worldY - cameraPos.y * ratio) * (pixelsPerMeter * scaleFactor) + getScreenHeight() * 0.5f; } +//b2Vec2 Game::screenPos(b2Vec2 worldPos) { +// return b2Vec2(this->screenX(worldPos.x), this->screenY(worldPos.y)); +//} float Game::getScaleFactor() { return scaleFactor; @@ -782,7 +869,11 @@ float Game::getFullScale() { } void Game::setScale(float scale) { - scaleFactor = scale; + scaleFactor = scale; + viewportWidth = screenWidth / (pixelsPerMeter * scaleFactor); + viewportHeight = screenHeight / (pixelsPerMeter * scaleFactor); + halfViewportWidth = viewportWidth * 0.5f; + halfViewportHeight = viewportHeight * 0.5f; } void Game::moveCamera(b2Vec2 diff) { cameraPos += diff; @@ -819,19 +910,32 @@ int Game::getScreenWidth() { int Game::getScreenHeight() { return screenHeight; } +float Game::getViewportWidth() { + return viewportWidth; +} +float Game::getViewportHeight() { + return viewportHeight; +} +float Game::getHalfViewportWidth() { + return halfViewportWidth; +} +float Game::getHalfViewportHeight() { + return halfViewportHeight; +} + float Game::getMapWidth() { return mapWidth; } float Game::getMapHeight() { return mapHeight; +} +float Game::getHalfMapWidth() { + return halfMapWidth; } - -float Game::getWorldScreenWidth() { - return screenWidth / (scaleFactor * pixelsPerMeter); +float Game::getHalfMapHeight() { + return halfMapHeight; } -float Game::getWorldScreenHeight() { - return screenHeight / (scaleFactor * pixelsPerMeter); -} + void Game::loadMap(char* fn) { //mapAnimations = new hgeAnimation*[256]; @@ -856,6 +960,8 @@ void Game::loadMap(char* fn) { if (root->Attribute("height")) { mapHeight = atof(root->Attribute("height")); } + halfMapWidth = mapWidth * 0.5f; halfMapHeight = mapHeight * 0.5f; + mapAnimationsCount = atoi(root->Attribute("animations")); mapAnimations = new MapAnimation*[mapAnimationsCount]; groundLinesCount = atoi(root->Attribute("ground_lines")); @@ -863,13 +969,86 @@ void Game::loadMap(char* fn) { platformsCount = atoi(root->Attribute("platforms")); platforms = new Platform*[platformsCount]; - TiXmlElement* element = root->FirstChildElement("animation"); + + int layersCount = atoi( root->Attribute("layers") ); + int orders[layersCount]; + float ratios[layersCount]; + + int layer = 0; + TiXmlElement* element = root->FirstChildElement("layer"); + while (element) { + orders[layer] = atoi( element->Attribute("order") ); + ratios[layer] = atof( element->Attribute("ratio") ); + layer++; + + element = element->NextSiblingElement("layer"); + } + layersCount = layer; + + int minOrder = -1; + int maxOrder = -100; + for (int i = 0; i < layersCount; i++) { + if ( orders[i] < minOrder ) + minOrder = orders[i]; + if ( orders[i] > maxOrder && orders[i] < 0 ) + maxOrder = orders[i]; + } + backLayersCount = 0; + int backLayerIndices[layersCount]; + backLayerRatios = new float[layersCount]; + for (int order = minOrder; order <= maxOrder; order++) { + for (int i = 0; i < layersCount; i++) { + if (order == orders[i]) { + backLayerRatios[backLayersCount] = ratios[i]; + backLayerIndices[backLayersCount] = i; + backLayersCount++; + } + } + } + + minOrder = 100; + maxOrder = 0; + for (int i = 0; i < layersCount; i++) { + if ( orders[i] < minOrder && orders[i] >= 0 ) + minOrder = orders[i]; + if ( orders[i] > maxOrder ) + maxOrder = orders[i]; + } + frontLayersCount = 0; + int frontLayerIndices[layersCount]; + frontLayerRatios = new float[layersCount]; + for (int order = minOrder; order <= maxOrder; order++) { + for (int i = 0; i < layersCount; i++) { + if (order == orders[i]) { + frontLayerRatios[frontLayersCount] = ratios[i]; + frontLayerIndices[frontLayersCount] = i; + frontLayersCount++; + } + } + } + + backLayersMapAnimationsCounts = new int[backLayersCount]; + frontLayersMapAnimationsCounts = new int[frontLayersCount]; + backLayersMapAnimations = new int*[backLayersCount]; + frontLayersMapAnimations = new int*[frontLayersCount]; + for (int i = 0; i < backLayersCount; i++) { + backLayersMapAnimations[i] = new int[mapAnimationsCount]; + backLayersMapAnimationsCounts[i] = 0; + } + for (int i = 0; i < frontLayersCount; i++) { + frontLayersMapAnimations[i] = new int[mapAnimationsCount]; + frontLayersMapAnimationsCounts[i] = 0; + } + + + element = root->FirstChildElement("animation"); int i = 0; while (element) { printf("loading animation...\n"); float x = atof(element->Attribute("x")); float y = atof(element->Attribute("y")); float angle = atof(element->Attribute("angle")); + int layer = atoi(element->Attribute("layer")); char* animationName = (char*)element->Attribute("file"); hgeAnimation* animation = loadAnimation(animationName); @@ -877,6 +1056,19 @@ void Game::loadMap(char* fn) { mapAnimations[i] = new MapAnimation(this, animation, x, y, angle); + for (int j = 0; j < backLayersCount; j++) { + if (backLayerIndices[j] == layer) { + backLayersMapAnimations[j][ backLayersMapAnimationsCounts[j] ] = i; + backLayersMapAnimationsCounts[j]++; + } + } + for (int j = 0; j < frontLayersCount; j++) { + if (frontLayerIndices[j] == layer) { + frontLayersMapAnimations[j][ frontLayersMapAnimationsCounts[j] ] = i; + frontLayersMapAnimationsCounts[j]++; + } + } + i++; element = element->NextSiblingElement("animation"); } @@ -1081,7 +1273,8 @@ char* getFileName(const char* path) { } i++; } - for (int i = 0; i < finish - start; i++) { + + for (i = 0; i < finish - start; i++) { fileName[i] = path[start + i]; } fileName[i] = '\0'; diff --git a/SoDlib/src/GroundLine.cpp b/SoDlib/src/GroundLine.cpp index 519fa8e..1d5c69d 100644 --- a/SoDlib/src/GroundLine.cpp +++ b/SoDlib/src/GroundLine.cpp @@ -137,7 +137,7 @@ b2Vec2 GroundLine::getEndPoint() void GroundLine::debugDraw(DWORD color) { - game->drawLine(game->screenPos(startPoint), game->screenPos(endPoint), color); + game->drawLine(game->screenX(startPoint.x), game->screenY(startPoint.y), game->screenX(endPoint.x), game->screenY(endPoint.y), color); } void GroundLine::debugDraw() { diff --git a/SoDlib/src/MapAnimation.cpp b/SoDlib/src/MapAnimation.cpp index e16bd31..d6116fe 100644 --- a/SoDlib/src/MapAnimation.cpp +++ b/SoDlib/src/MapAnimation.cpp @@ -14,11 +14,11 @@ MapAnimation::~MapAnimation() //dtor } -void MapAnimation::draw(bool schematicMode) +void MapAnimation::draw(float ratio, bool schematicMode) { animation->RenderEx( - game->screenX(x), - game->screenY(y), + game->screenX(x, ratio), + game->screenY(y, ratio), angle, game->getScaleFactor(), game->getScaleFactor() diff --git a/characterEditor/bin/Debug/pencil sword.xml b/characterEditor/bin/Debug/pencil sword.xml new file mode 100644 index 0000000..c2c78ce --- /dev/null +++ b/characterEditor/bin/Debug/pencil sword.xml @@ -0,0 +1,46 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/characterEditor/characterEditor.cbp b/characterEditor/characterEditor.cbp index 5341a3a..a6664e8 100644 --- a/characterEditor/characterEditor.cbp +++ b/characterEditor/characterEditor.cbp @@ -7,7 +7,7 @@