From DONOTREPLY at icculus.org Thu Sep 1 09:23:04 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Sep 2005 09:23:04 -0400 Subject: r131 - trunk/src Message-ID: <20050901132304.7616.qmail@icculus.org> Author: jonas Date: 2005-09-01 09:23:04 -0400 (Thu, 01 Sep 2005) New Revision: 131 Modified: trunk/src/editor.cpp trunk/src/editor.h trunk/src/gfxeng.cpp trunk/src/objectpools.cpp trunk/src/objectpools.h trunk/src/players_common.cpp trunk/src/scenario.cpp trunk/src/scenario.h Log: GAME_PAUSED state fixes (update the whole scene if necessary). ObjectsPool creates objects in game coordinates, not display coordinates. Various editor improvements (the map editor is quite useable now): - Various bug fixes - Much improved TextInputBox (e.g. allow nice Input entry titles/fields) - Allow non centered layouts - Much improved EditBox - New Map creations - Allow Map saving - Allow Map loading - Allow Map testing - Much improved ObjectBox (full featured object configuration before placing) Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/editor.cpp 2005-09-01 13:23:04 UTC (rev 131) @@ -10,16 +10,19 @@ Editor::Editor() { run_action(EDIT_RESET_ACTIONS); string place_name=""; - save_name="newmap.txt"; + save_name="newmap.cfg"; box=NULL; } Editor::~Editor() { closeBox(); - saveBuf(save_name); } void Editor::run_action(Uint32 action, Uint16 x, Uint16 y) { + SDL_Rect shift=gfxeng->getShift(); + Sint16 xs=x-shift.x; + Sint16 ys=y-shift.y; + gfxeng->update(UPDATE_ALL); if (action&EDIT_RESET_ACTIONS) { for (Uint8 i=0; i<6; i++) { @@ -35,9 +38,8 @@ if (box) box->act(box->getCurrentEntry(x,y)); } else if (action&EDIT_PLACE_OBJECT) { scenario->reloadMap(); - string next_name=scenario->pool->getNextObjectName(place_name); - if (scenario->pool->addObjectbyName(place_name,place_image,x,y,next_name)) { - appendtoBuf(place_name+" "+place_image+" "+itos(x)+" "+itos(y)+" "+next_name); + if (scenario->pool->addObjectbyName(place_name,place_image,xs,ys,place_arg1,place_arg2,place_arg3)) { + appendtoBuf(place_name+" "+place_image+" "+itos(xs)+" "+itos(ys)+" "+place_arg1+" "+place_arg2+" "+place_arg3); } // action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX; } else { } @@ -76,8 +78,8 @@ } Box* Editor::setBox(Box* newbox) { - gfxeng->update(UPDATE_ALL); - return box=newbox; + closeBox(); + return box=newbox; } void Editor::closeBox() { @@ -92,7 +94,9 @@ //don't forget the "::" font(::font), font_title(font), - font_high(font2) { + font_high(font2), + centered(true) { + editor->run_action(EDIT_RESET_ACTIONS); area.x=x; area.y=y; } @@ -172,13 +176,66 @@ /* write entries */ for (Uint8 i=0; igetHeight()*i+WFONT+font_title->getHeight(); - font->writeCenter(surface,entries[i],tmph); + if (centered) font->writeCenter(surface,entries[i],tmph); + else font->write(surface,entries[i],WFONT,tmph); line.y=tmph+font->getHeight()+(int)((DFONT-line.h)/2); SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,180)); } } EditBox::EditBox(Sint16 x, Sint16 y): Box(x,y) { + title="EDIT MAP"; + entries.push_back("New"); + entries.push_back("Save As..."); + entries.push_back("Save"); + entries.push_back("Open"); + entries.push_back("Run"); + entries.push_back("Quit"); + entries.push_back(""); + entries.push_back("Place Object"); + entries.push_back("Remove Object"); + entries.push_back("Move Object"); + entries.push_back("Configure Object"); + update(); +} + +void EditBox::act(Sint8 curentry) { + gfxeng->update(UPDATE_ALL); + if (curentry==-1 || curentry >= (Sint8)entries.size()) { + editor->closeBox(); + } else if (entries[curentry]=="New") { + editor->setBox(new NewMapBox(area.x,area.y)); + } else if (entries[curentry]=="Save As...") { + editor->setBox(new SaveAsBox(area.x,area.y)); + } else if (entries[curentry]=="Save") { + if (editor->save_name=="newmap.cfg") { + editor->setBox(new SaveAsBox(area.x,area.y)); + } else { + editor->saveBuf(editor->save_name); + editor->closeBox(); + } + } else if (entries[curentry]=="Open") { + editor->setBox(new OpenMapBox(area.x,area.y)); + } else if (entries[curentry]=="Run") { + setGameMode(GAME_PLAY); + scenario->reloadMap(); + editor->closeBox(); + } else if (entries[curentry]=="Place Object") { + editor->setBox(new PlaceBox(area.x,area.y)); + } else if (entries[curentry]=="Remove Object") { + editor->closeBox(); + } else if (entries[curentry]=="Move Object") { + editor->closeBox(); + } else if (entries[curentry]=="Configure Object") { + editor->closeBox(); + } else if (entries[curentry]=="Quit") { + quitGame(0); + } else { + editor->closeBox(); + } +} + +PlaceBox::PlaceBox(Sint16 x, Sint16 y): Box(x,y) { title="PLACE"; entries.push_back("Wall"); entries.push_back("Exit"); @@ -206,55 +263,53 @@ update(); } -void EditBox::act(Sint8 curentry) { +void PlaceBox::act(Sint8 curentry) { gfxeng->update(UPDATE_ALL); if (curentry==-1 || curentry >= (Sint8)entries.size()) { - editor->closeBox(); } else { - editor->place_name=entries[curentry]; - if (editor->place_name=="Wall") { - editor->place_image="viking1.bmp"; - } else if (editor->place_name=="Water") { - editor->place_image="water.bmp"; - } else if (editor->place_name=="Exit") { - editor->place_image="exit.bmp"; - } else if (editor->place_name=="Teleporter") { - editor->place_image="viking1.bmp"; - } else if (editor->place_name=="Wind") { - editor->place_image="teleport_01.bmp"; - } else if (editor->place_name=="Geyser") { - editor->place_image="viking1.bmp"; - } else if (editor->place_name=="Trigger") { - editor->place_image="key.bmp"; - } else if (editor->place_name=="Door") { - editor->place_image="viking1.bmp"; - } else if (editor->place_name=="Spike") { - editor->place_image="viking1.bmp"; - } else if (editor->place_name=="Heart") { - editor->place_image="heart.bmp"; - } else if (editor->place_name=="Key") { - editor->place_image="key.bmp"; - } else if (editor->place_name=="Bomb") { - editor->place_image="bomb_fire.bmp"; - } else if (editor->place_name=="Erik") { - editor->place_image="viking.bmp"; - } else if (editor->place_name=="Olaf") { - editor->place_image="viking.bmp"; - } else if (editor->place_name=="Baleog") { - editor->place_image="viking.bmp"; - } else if (editor->place_name=="Fang") { - editor->place_image="viking.bmp"; - } else if (editor->place_name=="Scorch") { - editor->place_image="viking.bmp"; - } else if (editor->place_name=="Plant") { - editor->place_image="viking1.bmp"; - } else if (editor->place_name=="Zombie") { - editor->place_image="viking.bmp"; + string next_name=scenario->pool->getNextObjectName(entries[curentry]); + if (entries[curentry]=="Wall") { + editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Water") { + editor->setBox(new ObjectBox(entries[curentry],"water.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Exit") { + editor->setBox(new ObjectBox(entries[curentry],"exit.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Teleporter") { + editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Teleport Destination (x coordinate): ","0","Teleport Destination (y coordinate): ","0","Name: ",next_name)); + } else if (entries[curentry]=="Wind") { + editor->setBox(new ObjectBox(entries[curentry],"teleport_01.bmp",area.x,area.y,"Wind acceleration: ","0","Name: ",next_name)); + } else if (entries[curentry]=="Geyser") { + editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Geyser force: ","0","Name: ",next_name)); + } else if (entries[curentry]=="Trigger") { + editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Trigger target name: ","","Name: ",next_name,"Key name: ","")); + } else if (entries[curentry]=="Door") { + editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Key name: ","","Name: ",next_name)); + } else if (entries[curentry]=="Spike") { + editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Direction (R=1,L=2,U=4,D=8): ","4","Name: ",next_name)); + } else if (entries[curentry]=="Heart") { + editor->setBox(new ObjectBox(entries[curentry],"heart.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Key") { + editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Bomb") { + editor->setBox(new ObjectBox(entries[curentry],"bomb_fire.bmp",area.x,area.y,"Exploding time (in ms): ","0","Name: ",next_name)); + } else if (entries[curentry]=="Erik") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Olaf") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Baleog") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Fang") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Scorch") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); + } else if (entries[curentry]=="Plant") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name)); + } else if (entries[curentry]=="Zombie") { + editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else { - editor->place_image=""; + editor->run_action(EDIT_RESET_ACTIONS); + editor->closeBox(); } - editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT; - editor->closeBox(); } } @@ -263,32 +318,127 @@ SDL_EnableUNICODE(1); SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY,SDL_DEFAULT_REPEAT_INTERVAL); addGameMode(GAME_TEXT_INPUT); + editor->action_mouse_released[SDL_BUTTON_RIGHT]=NOTHING; } TextInputBox::~TextInputBox() { SDL_EnableUNICODE(0); SDL_EnableKeyRepeat(0,SDL_DEFAULT_REPEAT_INTERVAL); removeGameMode(GAME_TEXT_INPUT); - editor->run_action(EDIT_RESET_ACTIONS); + editor->action_mouse_released[SDL_BUTTON_RIGHT]=EDIT_BOX; } - void TextInputBox::act(Sint8 button) { - if (button>=0 && (Uint8)button=0 && (Uint8)button=(int)einput.size()) { } else if (akey==(Uint16)config.keybind[KEY_ACT]) { - editor->closeBox(); + evaluateEntry(); // Backspace } else if (akey==8) { - if ( entries[currententry].begin() != entries[currententry].end() ) { - entries[currententry].erase(entries[currententry].end()-1); + if ( einput[currententry].begin() != einput[currententry].end() ) { + einput[currententry].erase(einput[currententry].end()-1); gfxeng->update(UPDATE_ALL); update(); } } else if ((Uint16)akey<32 || (Uint16)akey>126) { } else { - entries[currententry]+=(char)akey; + einput[currententry]+=(char)akey; gfxeng->update(UPDATE_ALL); update(); } } +void TextInputBox::evaluateEntry() { + editor->closeBox(); +} +void TextInputBox::update() { + Uint8 maxs=max(entries.size(),max(einput.size(),etitles.size())); + Uint16 maxw=0; + string spaces=""; + if (entries.size()getTextWidth(etitles[i])); + } + for (Uint8 i=0; igetTextWidth(etitles[i]+spaces)save_name); + currententry=0; + update(); +} + +void SaveAsBox::evaluateEntry() { + editor->save_name=einput[0]; + editor->saveBuf(editor->save_name); + editor->closeBox(); +} + +OpenMapBox::OpenMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) { + title="Open Map"; + einput.push_back(scenario->name); + currententry=0; + update(); +} + +void OpenMapBox::evaluateEntry() { + scenario->loadMap(einput[0]); + editor->closeBox(); +} + +NewMapBox::NewMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) { + title="New Map"; + centered=false; + etitles.push_back("Map file: "); einput.push_back("newmap.cfg"); + etitles.push_back("Background image: "); einput.push_back(scenario->bgimage); + currententry=0; + update(); +} + +void NewMapBox::evaluateEntry() { + scenario->name=einput[0]; + scenario->newMap(einput[1]); + scenario->reloadMap(); + editor->closeBox(); +} + +ObjectBox::ObjectBox(string name, string image, Sint16 x, Sint16 y, string targ1, string arg1, string targ2, string arg2, string targ3, string arg3): TextInputBox(x,y), + objname(name) { + title=name+" Properties"; + centered=false; + currententry=0; + etitles.push_back("Image name: "); einput.push_back(image); + if (targ1!="" || arg1!="") { + etitles.push_back(targ1); + einput.push_back(arg1); + } + if (targ2!="" || arg2!="") { + etitles.push_back(targ2); + einput.push_back(arg2); + } + if (targ3!="" || arg3!="") { + etitles.push_back(targ3); + einput.push_back(arg3); + } + update(); +} + +void ObjectBox::evaluateEntry() { + editor->place_name=objname; + editor->place_image=einput[0]; + if (einput.size()>=2) editor->place_arg1=einput[1]; + if (einput.size()>=3) editor->place_arg2=einput[2]; + if (einput.size()>=4) editor->place_arg3=einput[3]; + editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT; + editor->closeBox(); +} Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/editor.h 2005-09-01 13:23:04 UTC (rev 131) @@ -39,7 +39,9 @@ /// Area occupied by the selection box SDL_Rect area; /// Draw the box surface - void update(); + virtual void update(); + /// True if the entries should be draw centered + bool centered; }; class EditBox : public Box { @@ -48,22 +50,60 @@ virtual void act(Sint8); }; +class PlaceBox : public Box { + public: + PlaceBox(Sint16,Sint16); + virtual void act(Sint8); +}; + class TextInputBox : public Box { public: TextInputBox(Sint16,Sint16); virtual ~TextInputBox(); virtual void act(Sint8); virtual void input(Uint16); + virtual void evaluateEntry(); protected: Sint8 currententry; + std::vector etitles; + std::vector einput; + virtual void update(); }; +class ObjectBox : public TextInputBox { + public: + ObjectBox(string,string,Sint16,Sint16,string targ1="",string arg1="",string targ2="",string arg2="",string targ3="",string arg3=""); + protected: + virtual void evaluateEntry(); + string objname; +}; +class SaveAsBox : public TextInputBox { + public: + SaveAsBox(Sint16,Sint16); + protected: + virtual void evaluateEntry(); +}; + +class OpenMapBox : public TextInputBox { + public: + OpenMapBox(Sint16,Sint16); + protected: + virtual void evaluateEntry(); +}; + +class NewMapBox : public TextInputBox { + public: + NewMapBox(Sint16,Sint16); + protected: + virtual void evaluateEntry(); +}; + + /** \brief Handels editor specific tasks */ class Editor { - friend class EditBox; public: Editor(); ~Editor(); @@ -85,17 +125,18 @@ else return false; } Box* box; - protected: /// Name the saved map file string save_name; /// Object to place when clicking the left mouse button string place_name; /// Image name of the placed object string place_image; - /// Action type for the mouse buttons when clicking - Uint32 action_mouse_pressed[6]; - /// Action type for the mouse buttons when releasing the button - Uint32 action_mouse_released[6]; + /// First additonal parameter of the placed object + string place_arg1; + /// Seconds additional parameter of the placed object + string place_arg2; + /// Third additional parameter of the placed object + string place_arg3; /// Append a command to the buffered map file void appendtoBuf(string); /* TODO: add header modifiers */ @@ -103,6 +144,10 @@ string removefromBuf(string); /// Save the map file buffer to the specified file if possible int saveBuf(string); + /// Action type for the mouse buttons when clicking + Uint32 action_mouse_pressed[6]; + /// Action type for the mouse buttons when releasing the button + Uint32 action_mouse_released[6]; }; #endif Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/gfxeng.cpp 2005-09-01 13:23:04 UTC (rev 131) @@ -59,8 +59,11 @@ } //Paused game } else if (game_mode&GAME_PAUSED) { - if (updatetype==UPDATE_ALL || updatetype==UPDATE_BAR) { + if (updatetype==UPDATE_ALL) { + drawScene(); drawPlayerBar(); + } else if (updatetype==UPDATE_BAR) { + drawPlayerBar(); } //Not paused running game } else if (game_mode&GAME_PLAY) { Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/objectpools.cpp 2005-09-01 13:23:04 UTC (rev 131) @@ -38,11 +38,11 @@ while (i!=objectspool.end()) i=removeObject(i); } -Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, const string& arg1, const string& arg2, const string& arg3) { - x-=gfxeng->getShift().x; - y-=gfxeng->getShift().y; +Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, string& arg1, string& arg2, const string& arg3) { //Set names... - string name=obj; + if (arg1.empty()) arg1="0"; + if (arg2.empty()) arg2="0"; + string name=getNextObjectName(obj); if (arg1!="0") { //one additional parameter if (name=="Trigger" || name=="Door" || name=="Bomb" || name=="TriggeredBomb" || name=="Plant" || name=="Geyser" || name=="Wind" || name=="Spike") { Modified: trunk/src/objectpools.h =================================================================== --- trunk/src/objectpools.h 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/objectpools.h 2005-09-01 13:23:04 UTC (rev 131) @@ -30,7 +30,7 @@ /// \param arg3 Third argument as string /// \return Pointer to the new entry in the objectspool or NULL if /// the object was not recognized - Object* addObjectbyName(const string& obj, const string& image, Sint16 x=0, Sint16 y=0, const string& arg1="0", const string& arg2="0", const string& arg3="0"); + Object* addObjectbyName(const string& obj, const string& image, Sint16 x=0, Sint16 y=0, string& arg1="", string& arg2="", const string& arg3=""); //@{ /// Add an Object to the objectspool /// \return Pointer to the new entry in the objectspool or NULL if it failed Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/players_common.cpp 2005-09-01 13:23:04 UTC (rev 131) @@ -8,6 +8,8 @@ #include "sndcache.h" #include "objectpools.h" #include "scenario.h" +//to allow gfxeng->update() +#include "gfxeng.h" #include "players_common.h" @@ -97,12 +99,14 @@ } void Player::removeItem(Uint8 num) { + gfxeng->update(UPDATE_BAR); if (num>=MAX_ITEMS || items[num]==NULL) return; delete items[num]; items[num]=NULL; } Item* Player::moveItem(Uint8 num) { + gfxeng->update(UPDATE_BAR); if (num>=MAX_ITEMS || items[num]==NULL) return NULL; Item* tmpit=items[num]; items[num]=NULL; @@ -110,6 +114,7 @@ } void Player::switchItem(bool right) { + gfxeng->update(UPDATE_BAR); if (right) { ++currentitem; if (currentitem>=MAX_ITEMS) currentitem=0; @@ -120,6 +125,7 @@ } Object* Player::dropItem(Uint8 num) { + gfxeng->update(UPDATE_ALL); Item* tmpit=moveItem(num); Object* tmpobj=NULL; bool ok=false; Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/scenario.cpp 2005-09-01 13:23:04 UTC (rev 131) @@ -13,7 +13,8 @@ area(NULL), player(NULL), failed(false), - name("") { + name(""), + bgimage("") { cout << "Scenario: ImageCache...\n"; imgcache=new ImageCache(); cout << "Scenario: SoundCache...\n"; @@ -51,6 +52,10 @@ player=NULL; } +void Scenario::newMap(string bgimage) { + mapbuf.clear(); + mapbuf.push_back("Background "+bgimage); +} int Scenario::loadMapBuf(string mapname) { name=mapname; ifstream mapfile; @@ -117,7 +122,10 @@ if (cname=="Background" && (!background)) { background=new Background(image); - if (background) area=background->getPos(); + if (background) { + area=background->getPos(); + bgimage=image; + } //Background has to be first! } else if (background) { pool->addObjectbyName(cname,image,x,y,arg1,arg2,arg3); Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-01 00:01:51 UTC (rev 130) +++ trunk/src/scenario.h 2005-09-01 13:23:04 UTC (rev 131) @@ -61,6 +61,8 @@ ObjectsPool* pool; /// Physic Handler PhysicHandler* physic; + /// Create a new empty map with the specified background + void newMap(string bgname); /// Used to load the map file into a buffer int loadMapBuf(string mapname); /// Reload the map file using the buffered map file @@ -75,6 +77,8 @@ bool failed; /// Name of the map file string name; + /// Name of the map background image + string bgimage; std::vector mapbuf; private: inline void reinitMap(); From DONOTREPLY at icculus.org Thu Sep 1 14:29:41 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Sep 2005 14:29:41 -0400 Subject: r132 - trunk/src Message-ID: <20050901182941.2991.qmail@icculus.org> Author: jonas Date: 2005-09-01 14:29:41 -0400 (Thu, 01 Sep 2005) New Revision: 132 Modified: trunk/src/editor.cpp trunk/src/editor.h Log: correct object naming Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-01 13:23:04 UTC (rev 131) +++ trunk/src/editor.cpp 2005-09-01 18:29:41 UTC (rev 132) @@ -12,6 +12,7 @@ string place_name=""; save_name="newmap.cfg"; box=NULL; + place_obj_name=NULL; } Editor::~Editor() { @@ -41,6 +42,8 @@ if (scenario->pool->addObjectbyName(place_name,place_image,xs,ys,place_arg1,place_arg2,place_arg3)) { appendtoBuf(place_name+" "+place_image+" "+itos(xs)+" "+itos(ys)+" "+place_arg1+" "+place_arg2+" "+place_arg3); } + if (place_obj_name) (*place_obj_name)=scenario->pool->getNextObjectName(place_name); + if (place_obj_name) cout << "Name: " << *place_obj_name << endl; // action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX; } else { } } @@ -268,6 +271,7 @@ if (curentry==-1 || curentry >= (Sint8)entries.size()) { } else { string next_name=scenario->pool->getNextObjectName(entries[curentry]); + editor->place_obj_name=&editor->place_arg1; if (entries[curentry]=="Wall") { editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Water") { @@ -275,22 +279,29 @@ } else if (entries[curentry]=="Exit") { editor->setBox(new ObjectBox(entries[curentry],"exit.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Teleporter") { + editor->place_obj_name=&editor->place_arg3; editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Teleport Destination (x coordinate): ","0","Teleport Destination (y coordinate): ","0","Name: ",next_name)); } else if (entries[curentry]=="Wind") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"teleport_01.bmp",area.x,area.y,"Wind acceleration: ","0","Name: ",next_name)); } else if (entries[curentry]=="Geyser") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Geyser force: ","0","Name: ",next_name)); } else if (entries[curentry]=="Trigger") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Trigger target name: ","","Name: ",next_name,"Key name: ","")); } else if (entries[curentry]=="Door") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Key name: ","","Name: ",next_name)); } else if (entries[curentry]=="Spike") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Direction (R=1,L=2,U=4,D=8): ","4","Name: ",next_name)); } else if (entries[curentry]=="Heart") { editor->setBox(new ObjectBox(entries[curentry],"heart.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Key") { editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Bomb") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"bomb_fire.bmp",area.x,area.y,"Exploding time (in ms): ","0","Name: ",next_name)); } else if (entries[curentry]=="Erik") { editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); @@ -303,6 +314,7 @@ } else if (entries[curentry]=="Scorch") { editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Plant") { + editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name)); } else if (entries[curentry]=="Zombie") { editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-01 13:23:04 UTC (rev 131) +++ trunk/src/editor.h 2005-09-01 18:29:41 UTC (rev 132) @@ -131,6 +131,8 @@ string place_name; /// Image name of the placed object string place_image; + /// Object name to place when clicking the left mouse button + string* place_obj_name; /// First additonal parameter of the placed object string place_arg1; /// Seconds additional parameter of the placed object From DONOTREPLY at icculus.org Thu Sep 1 14:31:19 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Sep 2005 14:31:19 -0400 Subject: r133 - trunk/src Message-ID: <20050901183119.3300.qmail@icculus.org> Author: jonas Date: 2005-09-01 14:31:19 -0400 (Thu, 01 Sep 2005) New Revision: 133 Modified: trunk/src/editor.cpp Log: 10l (forgot to remove debug stuff) Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-01 18:29:41 UTC (rev 132) +++ trunk/src/editor.cpp 2005-09-01 18:31:19 UTC (rev 133) @@ -43,7 +43,6 @@ appendtoBuf(place_name+" "+place_image+" "+itos(xs)+" "+itos(ys)+" "+place_arg1+" "+place_arg2+" "+place_arg3); } if (place_obj_name) (*place_obj_name)=scenario->pool->getNextObjectName(place_name); - if (place_obj_name) cout << "Name: " << *place_obj_name << endl; // action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX; } else { } } From DONOTREPLY at icculus.org Thu Sep 1 14:33:45 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Sep 2005 14:33:45 -0400 Subject: r134 - trunk/src Message-ID: <20050901183345.3514.qmail@icculus.org> Author: jonas Date: 2005-09-01 14:33:45 -0400 (Thu, 01 Sep 2005) New Revision: 134 Modified: trunk/src/editor.cpp Log: small fix in case an invalid object was specified... Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-01 18:31:19 UTC (rev 133) +++ trunk/src/editor.cpp 2005-09-01 18:33:45 UTC (rev 134) @@ -270,10 +270,11 @@ if (curentry==-1 || curentry >= (Sint8)entries.size()) { } else { string next_name=scenario->pool->getNextObjectName(entries[curentry]); - editor->place_obj_name=&editor->place_arg1; if (entries[curentry]=="Wall") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Water") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"water.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Exit") { editor->setBox(new ObjectBox(entries[curentry],"exit.bmp",area.x,area.y,"Name: ",next_name)); @@ -296,26 +297,34 @@ editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Direction (R=1,L=2,U=4,D=8): ","4","Name: ",next_name)); } else if (entries[curentry]=="Heart") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"heart.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Key") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Bomb") { editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"bomb_fire.bmp",area.x,area.y,"Exploding time (in ms): ","0","Name: ",next_name)); } else if (entries[curentry]=="Erik") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Olaf") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Baleog") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Fang") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Scorch") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Plant") { editor->place_obj_name=&editor->place_arg2; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name)); } else if (entries[curentry]=="Zombie") { + editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else { editor->run_action(EDIT_RESET_ACTIONS); From DONOTREPLY at icculus.org Thu Sep 1 14:57:06 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Sep 2005 14:57:06 -0400 Subject: r135 - trunk/src Message-ID: <20050901185706.5278.qmail@icculus.org> Author: jonas Date: 2005-09-01 14:57:06 -0400 (Thu, 01 Sep 2005) New Revision: 135 Modified: trunk/src/objectpools.cpp trunk/src/objectpools.h trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/scenario.cpp trunk/src/scenario.h Log: added a comparsion function to put a proper ordering on the pools: the numbers of created objects so far. This can be used as an id as well. Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-01 18:33:45 UTC (rev 134) +++ trunk/src/objectpools.cpp 2005-09-01 18:57:06 UTC (rev 135) @@ -30,6 +30,11 @@ #include "objects/zombie.h" +bool Compare::operator()(const Object* obj1, const Object* obj2) { + if (obj1->onumonum) return true; + else return false; +} + ObjectsPool::ObjectsPool(): currentplayer(playerspool.begin()), au_switch(sndcache->loadWAV("newchar.wav")) { } Modified: trunk/src/objectpools.h =================================================================== --- trunk/src/objectpools.h 2005-09-01 18:33:45 UTC (rev 134) +++ trunk/src/objectpools.h 2005-09-01 18:57:06 UTC (rev 135) @@ -1,6 +1,10 @@ #ifndef DEF_OBJECTPOOLS_H #define DEF_OBJECTPOOLS_H 1 +struct Compare { + bool operator()(const Object*, const Object*); +}; + /** \brief Container for objects. Contains a pool for each important derived object class, @@ -69,19 +73,19 @@ ///\brief Object pool /// /// Contains all objects managed by the ObjectsPool - std::set objectspool; + std::set objectspool; ///\brief Character pool /// /// Contains all characters managed by the ObjectsPool - std::set characterspool; + std::set characterspool; ///\brief Player pool /// /// Contains all players managed by the ObjectsPool - std::set playerspool; + std::set playerspool; ///\brief Monster pool /// /// Contains all monsters managed by the ObjectsPool - std::set monsterspool; + std::set monsterspool; //@} private: //player number of the currently selected player Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-01 18:33:45 UTC (rev 134) +++ trunk/src/objects_common.cpp 2005-09-01 18:57:06 UTC (rev 135) @@ -8,7 +8,6 @@ Object::Object(string imagename, Sint16 xcord, Sint16 ycord, string oname): - tbirth(SDL_GetTicks()), state(NOTHING), event(NULL), im_orig(new Animation(scenario->imgcache->loadImage(imagename))), @@ -24,6 +23,7 @@ curpos.h=pos.h; curpos.x=0; curpos.y=0; + onum=++scenario->max_obj_num; } Object::~Object() { @@ -31,6 +31,11 @@ if (!(otype&OTYPE_CHARACTER)) delete animation; } +bool Object::operator<(const Object& obj) const { + if (onum rect.x && pos.x < (rect.x+rect.w) && (pos.y+pos.h) > rect.y && pos.y < (rect.y+rect.h)) return true; Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-01 18:33:45 UTC (rev 134) +++ trunk/src/objects_common.h 2005-09-01 18:57:06 UTC (rev 135) @@ -163,8 +163,9 @@ /// \remark This should be called downwards by all derived classes virtual void idle(Uint16) { } //@} + bool operator<(const Object& obj) const; + Uint32 onum; protected: - Uint16 tbirth; Uint32 state; Event* event; Animation* im_orig; Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-01 18:33:45 UTC (rev 134) +++ trunk/src/scenario.cpp 2005-09-01 18:57:06 UTC (rev 135) @@ -23,6 +23,7 @@ physic=new PhysicHandler(); cout << "Map: ObjectsPool...\n"; pool=new ObjectsPool(); + max_obj_num=0; } Scenario::~Scenario() { @@ -50,6 +51,7 @@ background=NULL; area=NULL; player=NULL; + max_obj_num=0; } void Scenario::newMap(string bgimage) { Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-01 18:33:45 UTC (rev 134) +++ trunk/src/scenario.h 2005-09-01 18:57:06 UTC (rev 135) @@ -80,6 +80,8 @@ /// Name of the map background image string bgimage; std::vector mapbuf; + /// The number of created objects + Uint32 max_obj_num; private: inline void reinitMap(); }; From DONOTREPLY at icculus.org Thu Sep 1 14:58:24 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 1 Sep 2005 14:58:24 -0400 Subject: r136 - in trunk: . src Message-ID: <20050901185824.5484.qmail@icculus.org> Author: jonas Date: 2005-09-01 14:58:24 -0400 (Thu, 01 Sep 2005) New Revision: 136 Modified: trunk/TODO trunk/src/common.h Log: forgot the TODO entry ;-) Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-01 18:57:06 UTC (rev 135) +++ trunk/TODO 2005-09-01 18:58:24 UTC (rev 136) @@ -127,8 +127,6 @@ - crushable (ie. weapon fart, jump, run destroys them?) - bombable (ie. bomb destroys them) - multistates? => bridges, door, stone block - o Give each object a serial number and order the pools with it - => solves display bug... Progress Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-01 18:57:06 UTC (rev 135) +++ trunk/src/common.h 2005-09-01 18:58:24 UTC (rev 136) @@ -162,6 +162,7 @@ //global variables //@{ +/// masks extern const Uint32 rmask; extern const Uint32 gmask; extern const Uint32 bmask; From DONOTREPLY at icculus.org Fri Sep 2 18:11:39 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 2 Sep 2005 18:11:39 -0400 Subject: r137 - in trunk: . src Message-ID: <20050902221139.22976.qmail@icculus.org> Author: jonas Date: 2005-09-02 18:11:39 -0400 (Fri, 02 Sep 2005) New Revision: 137 Modified: trunk/TODO trunk/src/editor.cpp Log: updated bugs, 10l Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-01 18:58:24 UTC (rev 136) +++ trunk/TODO 2005-09-02 22:11:39 UTC (rev 137) @@ -2,6 +2,8 @@ ==== o rewrite zombie (bug in movement!, attacks too often, use events, etc...) o memleaks, segfaults? + o left/right move + switchPlayer (keeps moving) + o key vs. trigger in map2 Code Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-01 18:58:24 UTC (rev 136) +++ trunk/src/editor.cpp 2005-09-02 22:11:39 UTC (rev 137) @@ -322,7 +322,7 @@ editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); } else if (entries[curentry]=="Plant") { editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name)); + editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name)); } else if (entries[curentry]=="Zombie") { editor->place_obj_name=&editor->place_arg1; editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); From DONOTREPLY at icculus.org Sat Sep 3 07:58:44 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Sep 2005 07:58:44 -0400 Subject: r138 - tags Message-ID: <20050903115844.18234.qmail@icculus.org> Author: jonas Date: 2005-09-03 07:58:44 -0400 (Sat, 03 Sep 2005) New Revision: 138 Added: tags/rel-0-1-7/ Log: Released version 0.1.7 (the latest version with the old animation/imgcache design) Copied: tags/rel-0-1-7 (from rev 137, trunk) From DONOTREPLY at icculus.org Sat Sep 3 08:40:32 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Sep 2005 08:40:32 -0400 Subject: r139 - in trunk: . src src/objects tools Message-ID: <20050903124032.21039.qmail@icculus.org> Author: jonas Date: 2005-09-03 08:40:31 -0400 (Sat, 03 Sep 2005) New Revision: 139 Modified: trunk/TODO trunk/src/animation.cpp trunk/src/animation.h trunk/src/characters_common.cpp trunk/src/characters_common.h trunk/src/common.cpp trunk/src/common.h trunk/src/events.cpp trunk/src/gfxeng.cpp trunk/src/imgcache.cpp trunk/src/imgcache.h trunk/src/lost_penguins.cpp trunk/src/monsters_common.cpp trunk/src/monsters_common.h trunk/src/objects/baleog.cpp trunk/src/objects/erik.cpp trunk/src/objects/fang.cpp trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/scorch.cpp trunk/src/objects/zombie.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/physics.cpp trunk/src/players_common.cpp trunk/src/players_common.h trunk/tools/lvl2magick.c Log: Huge REWRITE of the Animation and ImageCache class: o Introduced the struct Image: An image is composed of an SDL_Surface* and a corresponding description of it's frames (std::vector). o Added constructors to the Frame struct to ease creation. o Introduce animation type: It describe?\209?\149 what type of animation we have (once/loop/swing/backwards/etc) o Introduced BasePointType and AllignType to specify how animations should be positioned wrt to their current base position (see animation.h). o ImageCache (basically a rewrite): - ImageCache now uses Images as a base, not SDL_Surface* and is also responsible to load the image description besides the surface. - Support for description file loading (compatible with the output of lvl2magick) => we should be able to easily load animations from a lvl2magick generated image - Support for description generation based on: base rectangles, number of frames, width and shift, direct specification (see imgcache.h) - Support for _Image_ scaling (including description) o Animation (complete rewrite): check animation.h!! o Updated the rest of the code to support the new ImageCache and Animation classes: - Removed all occurencies of curpos/getCurPos() (we don't need them anymore, to get the draw position of an animation we use getDrawPos()) - As a consequence we can get rid of 3 shiftMapArea - Added/Changed getFrame()/getDrawPos() as a function of each object to allow the gfxeng to get the draw position and frame - Removed all occurencies of anim->getWidth()/getHeight() (we use getBaseDim() now) - updated updateAnimState(), resetAnimState(), setAnim(), we don't need the change parameter of updateAnimState() anymore (maybe check the two changes in physics.cpp) - Introduced a Object::loadAnimation(...) function (loads an animation and sets the corresponding base position to the object position) - Added all Animation loadings everywhere accordingly (to match the Animation class) - As there is no more getFrame(nr) function, Animation has now a getBaseFrame() function to allow the loading of icons (HACK) o Updated the TODO accordingly o Updated lvl2magick to write a proper parsable description header for description files which are now have the extension .dsc o A few cosmetic changes Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/TODO 2005-09-03 12:40:31 UTC (rev 139) @@ -4,6 +4,7 @@ o memleaks, segfaults? o left/right move + switchPlayer (keeps moving) o key vs. trigger in map2 + o fall event (DONE?) Code @@ -35,75 +36,18 @@ possible. If it's not possible, do sthg else (stop the elevator and hit the object/whatever)... - o Animations/Events: - o Allow as complex Images as possible: - Introduce some image info structure that gives an array of subimages - Animations can then easily be specified by giving the start and end number in the - array. A subimage is defined by sthg like SDL_rect relative to the base image - o As the images of an animation (as in above) may vary in size we should introduce - sthg like a "base point" type: center/left/right (x) center/top/bottom (y) - => total: 9 types. Find a default base point... - which is a point in the animation that stays fixed (related to pos) - o Using the "base point" type => introduce corresponding drawing methode, which - consists of a rule on how to map the base point to the position (allignment): - center/left/right (x) center/top/bottom (y) - maybe introduce delta values for correction shifts - => most times the x-alignment probably corresponds to the base point, but the - y-allignment will almost always be bottom (top: sthg that hangs on a rope) - o Is the alignment a property of the object (state) or of the animation? => suggest animation - o Idea: introduce two type of animation for a simple triggered anim: - still anim: eg. 1 image, trig anim: animation starting with the still one - => get rid of once, running - More generally: do the logic about that outside of the animation structure - o Maybe introduce an animation base class and do the base_point/allignment logic - in derived classes somehow? Or use another pattern for this... + o Events/Animations: o Allow empty animation, decouple (put more logic in) these relations: object (pos, draw?), game(time, state, handler), gfxeng(draw), animation(empty, frame, update, time, draw)?, frame, global/current (public, private) properties - - o New anim class/struct: - /* Global properties */ - SDL_Surface* base_image (or in Frame struct) - Uint16 start_pos - Uint16 end_pos / or Uint16 frames - enum base_point_type - enum allignment_type - Uint16 allignment_delta - Uint16 length - /* Global Helper values */ - // maybe: bool empty? - bool still (if frames==1) - (see above) Uint16 frames / or Uint16 end_pos - - /* (Current) public properties */ - void update(Uint16 dt) - void draw() <- friend in gfxeng (shift, screen, etc)? - //information about the current graphic (frame) - //information about where to draw it (draw_pos) - - /* Current private properties */ - Uint16 cur_im_pos / or Uint16 cur_frame / or Uint16 cur_time - SDL_Rect* owner_pos (position of the owner) / or const SDL_Rect& owner_pos - /* Current helper values */ - Frame cur_frame (using private + image info) => w,h (or + Base Image) - (see above) Uint16 cur_pos / or Uint16 cur_frame / or Uint16 cur_time - SDL_Rect* (or SDL_Rect& ) draw_pos (using - (allignment/base_point)_(type/delta) + frame + owner_pos) - o Make all events quite short, ie. almost all events become animation events - o Maybe: Improve the (very simple) image format: - - All frame in one sprite sheet for each character (image matrices - using two description vectors or even more general: offset matrices) - => see above - - store rects in an array/vector/whatever or use offset matrices - => see above - - do some column/row logics to easy the access + o Do some column/row logics to easy the access? => NO - eg. set offsets for left, right, mleft, mright... - - IDEA: just store one side and add some flipping logic to the image + o IDEA: just store one side and add some flipping logic to the image loading process... - o IDEA: change Animation* pointers to Animation (or references), leave only - animation as a pointer and get the address each time... + o IDEA: change Animation* pointers to Animation (or references or auto_ptr), + leave only animation as a pointer and get the address each time... o introduce animation events that play an animation and end when it's finnished (always ESTATE_BUSY or abort animation?) o allow an event length depending on animation length, or: relate events more @@ -138,6 +82,7 @@ o DONE?: players, object, item, ai, weapons, character o PART DONE: effect management (periodic events, permanent effects, etc) o DONE: hitlogic + o IMPROVE!: move logic Features/Ideas @@ -145,12 +90,11 @@ o Make water movements possible (eric) o Add better graphics - o finnish the map editor - o OpenGL + o improve the map editor o Simple AI o Finnish the vikings: - - weapons: run, jump2, fart, sword, arm, fire, claws + - weapons: better run, jump2, fart, arm, fire - baleog swing (hard one) o Add new objects: @@ -161,7 +105,6 @@ o Monsters?: - stone? - - plant - knight - dragon - skeleton -> zombie Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/animation.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -1,65 +1,271 @@ #include "common.h" #include "animation.h" -Animation::Animation(SDL_Surface* anim_image, Uint16 max_num, Uint16 total_time, bool an_once): - size(max_num), - time(total_time), - num(0), - tcurrent(0), - once(an_once) { - if (time==0 || once) running=false; - else running=true; - frame.image=anim_image; - w=(Uint16)((frame.image->w)/size); - h=frame.image->h; - frame.pos.x=0; - frame.pos.y=0; - frame.pos.w=w; - frame.pos.h=h; +Animation::Animation(const Image& abase_image, + Uint32 aduration, + Uint16 aframes, + Uint16 aanimation_type, + Uint16 astart_pos, + BasePointType abp_type, + AllignType aallign_type, + Sint16 ashift_x, + Sint16 ashift_y): + base_image(abase_image), + duration(aduration), + frames(aframes), + animation_type(aanimation_type), + start_pos(astart_pos), + bp_type(abp_type), + allign_type(aallign_type), + shift_x(ashift_x), + shift_y(ashift_y), + end_pos(start_pos+frames), + base_pos(NULL) { + checkAnim(); } +Animation::~Animation() { } +void Animation::runAnim() { + if (!isValid()) { + cout << "Starting an invalid animation!" << endl; + return; + } + is_running=true; + cur_time=0; + if (animation_type&ATYPE_ALL_NORMAL) { + forward=true; + cur_frame_num=0; + cur_im_pos=start_pos; + } else { + forward=false; + cur_frame_num=frames-1; + cur_im_pos=end_pos; + } +} +bool Animation::stopAnim() { + if (!isValid()) { + cout << "Stopping an invalid animation!" << endl; + return is_running=false; + } else if (animation_type&ATYPE_ALL_ONCE) { + is_running=false; + cur_time=0; + if (animation_type&ATYPE_ALL_LSTART) { + cur_frame_num=0; + cur_im_pos=start_pos; + } else { + cur_frame_num=frames-1; + cur_im_pos=end_pos; + } + } + return isRunning(); +} -Animation::Animation(Uint16 width, SDL_Surface* anim_image, Uint16 max_num, Uint16 total_time, bool an_once): - size(max_num), - time(total_time), - num(0), - tcurrent(0), - once(an_once) { - if (time==0 || once) running=false; - else running=true; - frame.image=anim_image; - w=width; - h=frame.image->h; - frame.pos.x=0; - frame.pos.y=0; - frame.pos.w=w; - frame.pos.h=h; +bool Animation::updateAnim(Uint16 dt) { + if (!isValid()) { + cout << "Updating an invalid animation!" << endl; + return false; + } + if (!isRunning()) return false; + cur_time+=dt; + Uint32 durationh=(Uint32)duration/2; + + if (animation_type&ATYPE_ONCE || animation_type&ATYPE_ONCE_END) { + if (cur_time>=duration) { + return stopAnim(); + } else { + cur_frame_num=(Uint16)(cur_time*frames/duration); + } + } else if (animation_type&ATYPE_LOOP) { + if (cur_time>=duration) { + while(cur_time>=duration) cur_time-=duration; + } + cur_frame_num=(Uint16)(cur_time*frames/duration); + } else if (animation_type&ATYPE_ONCE_REV || animation_type&ATYPE_ONCE_END_REV) { + if (cur_time>=duration) { + return stopAnim(); + } else { + cur_frame_num=(Uint16)((duration-cur_time-1)*frames/duration); + } + } else if (animation_type&ATYPE_LOOP_REV) { + if (cur_time>=duration) { + while(cur_time>=duration) cur_time-=duration; + } + cur_frame_num=(Uint16)((duration-cur_time-1)*frames/duration); + } else if (animation_type&ATYPE_SWING && forward) { + if (cur_time>=durationh) { + forward=false; + cur_frame_num=(Uint16)((duration-cur_time-1)*frames/durationh); + } else { + cur_frame_num=(Uint16)(cur_time*frames/durationh); + } + } else if (animation_type&ATYPE_SWING) { + if (cur_time>=duration) { + while(cur_time>=duration) cur_time-=duration; + forward=true; + cur_frame_num=(Uint16)(cur_time*frames/durationh); + } else { + cur_frame_num=(Uint16)((duration-cur_time-1)*frames/durationh); + } + } else if (animation_type&ATYPE_SWING_REV && forward) { + if (cur_time>=duration) { + while(cur_time>=duration) cur_time-=duration; + forward=false; + cur_frame_num=(Uint16)((duration-cur_time-1)*frames/durationh); + } else { + cur_frame_num=(Uint16)(cur_time*frames/durationh); + } + } else if (animation_type&ATYPE_SWING_REV) { + if (cur_time>=durationh) { + forward=true; + cur_frame_num=(Uint16)(cur_time*frames/durationh); + } else { + cur_frame_num=(Uint16)((duration-cur_time-1)*frames/durationh); + } + } else { + cout << "This shouldn't happen: Unknown animation_type!" << endl; + return stopAnim(); + } + return isRunning(); } +Frame Animation::getFrame() const { + if (!isValid()) cout << "Invalid Frame of an invalid animation!" << endl; + return Frame(base_image.surface,base_image.description[cur_frame_num]); +} +Frame Animation::getBaseFrame() const { + if (!isValid()) cout << "Invalid Base Frame of an invalid animation!" << endl; + Uint16 num; + if (animation_type&ATYPE_ALL_NORMAL) num=start_pos; + else num=end_pos; + return Frame(base_image.surface,base_image.description[num]); +} +SDL_Rect Animation::getDrawPos() const { + SDL_Rect draw_pos=base_image.description[cur_frame_num]; + if (!base_pos || !isValid()) { + if (!isValid()) cout << "Invalid DrawPos of an invalid animation!" << endl; + else cout << "Invalid DrawPos!" << endl; + draw_pos.x=draw_pos.y=draw_pos.w=draw_pos.h=0; + return draw_pos; + } + draw_pos.x=base_pos->x; + draw_pos.y=base_pos->y; -Animation::~Animation() { } + /* calculate the base point */ + Sint16 base_point_x=0; + Sint16 base_point_y=0; -bool Animation::updateAnim(Uint16 dt) { - if (!running) return false; - tcurrent+=dt; - if (tcurrent < time) { - num=(Uint16)((tcurrent*size)/time); - if (num>=size) num=0; - } else if (once || time==0) { - num=size; - tcurrent=time; - running=false; + /* BP_MD is used most times */ + if (bp_type==BP_MD) { + base_point_x=(Uint16)draw_pos.w/2; + base_point_y=draw_pos.h; + } else if (bp_type==BP_LU) { + base_point_x=0; + base_point_y=0; + } else if (bp_type==BP_LM) { + base_point_x=0; + base_point_y=(Uint16)draw_pos.h/2; + } else if (bp_type==BP_LD) { + base_point_x=0; + base_point_y=draw_pos.h; + } else if (bp_type==BP_MU) { + base_point_x=(Uint16)draw_pos.w/2; + base_point_y=0; + } else if (bp_type==BP_MM) { + base_point_x=(Uint16)draw_pos.w/2; + base_point_y=(Uint16)draw_pos.h/2; + } else if (bp_type==BP_RU) { + base_point_x=draw_pos.w; + base_point_y=0; + } else if (bp_type==BP_RM) { + base_point_x=draw_pos.w; + base_point_y=(Uint16)draw_pos.h/2; + } else if (bp_type==BP_RD) { + base_point_x=draw_pos.w; + base_point_y=draw_pos.h; } else { - num=0; - tcurrent=0; + cout << "This shouldn't happen: Unknown base point type!" << endl; + base_point_x=(Uint16)draw_pos.w/2; + base_point_y=draw_pos.h; } - frame.pos.x=num*w; - if (running) return true; - else return false; -//The solution below would be better but it won't work with the 2nd constructor -// frame.pos.x=(Uint16)((num*frame.image->w)/size); + + /* calculate the draw_pos using the allignment type */ + if (allign_type==AT_MD) { + draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.y+=base_pos->h-base_point_y; + } else if (allign_type==AT_LU) { + draw_pos.x-=base_point_x; + draw_pos.y-=base_point_y; + } else if (allign_type==AT_LM) { + draw_pos.x-=base_point_x; + draw_pos.y+=(Uint16)base_pos->h/2-base_point_y; + } else if (allign_type==AT_LD) { + draw_pos.x-=base_point_x; + draw_pos.y+=base_pos->h-base_point_y; + } else if (allign_type==AT_MU) { + draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.y-=base_point_y; + } else if (allign_type==AT_MM) { + draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.y+=(Uint16)base_pos->h/2-base_point_y; + } else if (allign_type==AT_RU) { + draw_pos.x+=base_pos->w-base_point_x; + draw_pos.y-=base_point_y; + } else if (allign_type==AT_RM) { + draw_pos.x+=base_pos->w-base_point_x; + draw_pos.y+=(Uint16)base_pos->h/2-base_point_y; + } else if (allign_type==AT_RD) { + draw_pos.x+=base_pos->w-base_point_x; + draw_pos.y+=base_pos->h-base_point_y; + } else { + cout << "This shouldn't happen: Unknown allign type!" << endl; + draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.y+=base_pos->h-base_point_y; + } + + /* substract shift ("add" it to the bp position) */ + draw_pos.x-=shift_x; + draw_pos.y-=shift_y; + + return draw_pos; } -const Frame& Animation::setFrame(Uint16 num) { - frame.pos.x=num*w; - return frame; +SDL_Rect Animation::getFrameDim() const { + if (!isFixed()) cout << "Invalid Frame dimension of an invalid animation!" << endl; + SDL_Rect rect; + rect.x=rect.y=0; + rect.w=base_image.description[start_pos].w; + rect.h=base_image.description[start_pos].h; + return rect; } +bool Animation::checkAnim() { + if (base_image.surface==NULL || base_image.description.empty()) { + is_valid=false; + } else if (base_image.description.size()==1 || duration==0 || frames==1) { + is_image=true; + cur_time=0; + forward=true; + cur_frame_num=0; + cur_im_pos=start_pos; + is_running=false; + is_fixed=true; + is_valid=true; + } else if (frames==0 || start_pos>end_pos || (start_pos+frames)>base_image.description.size()) { + is_valid=false; + } else { + is_valid=true; + is_image=false; + is_fixed=false; + if (animation_type&ATYPE_ALL_ONCE) is_running=false; + else is_running=true; + cur_time=0; + if (animation_type&ATYPE_ALL_NORMAL) { + forward=true; + cur_frame_num=0; + cur_im_pos=start_pos; + } else { + forward=false; + cur_frame_num=frames-1; + cur_im_pos=end_pos; + } + } + return is_valid; +} Modified: trunk/src/animation.h =================================================================== --- trunk/src/animation.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/animation.h 2005-09-03 12:40:31 UTC (rev 139) @@ -1,76 +1,138 @@ #ifndef DEF_ANIMATION_H #define DEF_ANIMATION_H 1 -/** \brief A container for frames. +/** \brief Animation is responsible to return the correct frame of an animation - Animation format: a horizontal strip (image) with (num) frames - \todo Change this to an offset matrix or something similar or give each row a different animation */ class Animation { public: /// \brief Initialize the animation - /// \param image Image used for the animation - /// \param max_num Number of frames (will devide the image horizontally accordingly) - /// \param total_time Duration of the animation, if set to 0 assume it's one still image - /// \param once If true it run the animation only once when called by \fn start() - Animation(SDL_Surface* image, Uint16 max_num=1, Uint16 total_time=0, bool once=false); - /// \brief Initialize the animation - /// \param width Image width used from the left side - /// \param image Image used for the animation - /// \param max_num Number of frames (will devide the image horizontally accordingly) - /// \param total_time Duration of the animation, if set to 0 assume it's one still image - /// \param once If true: Run the animation only once when called by \fn start() - Animation(Uint16 width, SDL_Surface* image, Uint16 max_num=1, Uint16 total_time=0, bool once=false); + /// \param abase_image Base image used for the animation + /// \param aduration Duration of the animation + /// \param aframes Number of frames + /// \param aanimation_type Animation type + /// \param astart_pos Start position from the frame array of the base_image + /// \param abp_type Base point type + /// \param aallign_type Allignment type + /// \param ashift_x x shift value + /// \param ashift_y y shift value + /// + /// To load one still image simply use: Animation(loadImage(1,"image_name.png")) + Animation(const Image& abase_image, + Uint32 aduration=0, + Uint16 aframes=1, + Uint16 aanimation_type=ATYPE_LOOP, + Uint16 astart_pos=0, + BasePointType abp_type=BP_MD, + AllignType aallign_type=AT_MD, + Sint16 ashift_x=0, + Sint16 ashift_y=0); ~Animation(); + /// Set the base position of the animation + void setBasePos(SDL_Rect* abase_pos) { + base_pos=abase_pos; + checkAnim(); + } + /// Unsets the base position of the animation + void unsetBasePos() { + base_pos=NULL; + } + /// Start the animation from the beginning (used when the animation was still) + void runAnim(); /// Updates a running animation and stops it if necessary /// return True if the animation is still running - /// \todo This should be more advanced bool updateAnim(Uint16 dt); - /// Updates the frame status of a frame series (usually when not running) - /// return Current frame - const Frame& setFrame(Uint16 nr); - /// Starts an (usually non running) animation - void start() { - num=0; - tcurrent=0; - running=true; + /// Calculates and returns the current frame + Frame getFrame() const; + /// Calculates and returns the current draw position using: + /// base_pos,bp_type,allign_type,shift,cur_im_pos + SDL_Rect getDrawPos() const; + /// HACK: Return the dimensions of the first frame + SDL_Rect getFrameDim() const; + /// HACK: Return the base frame + Frame getBaseFrame() const; + /// return True if the animation is valid + bool isValid() const { + return is_valid; } - const Frame& getFrame() const { - return frame; - } - Frame getFrame(Uint16 nr) const { - Frame newframe=frame; - newframe.pos.x=nr*w; - return newframe; - } - Uint16 getWidth() const { - return w; - } - Uint16 getHeight() const { - return h; - } /// return True if the animation is running bool isRunning() const { - return running; + return is_running; } + /// return True if the animation is a still image + bool isImage() const { + return is_image; + } + /// return True if the animation dimensions stay the same + bool isFixed() const { + return is_fixed; + } private: - /// Frame pointer - Frame frame; + /// Helper function to stop an animation + bool stopAnim(); + /// check validity of the animation + bool checkAnim(); + private: + /// Base image for the animation (big) + Image base_image; + /// Duration of the animation in ms + Uint32 duration; /// Number of frames - Uint16 size; - /// Total time (in ms) - Uint16 time; - /// Frame size - Uint16 w; - Uint16 h; + Uint16 frames; + /// Animation type: ATYPE_ONCE (play once), ATYPE_ONCE_END (play once and stop at end), + /// ATYPE_LOOP (always play, jump back to the beginning), ATYPE_SWING (always play, + /// reverse direction when finnished). The appended _REV means that the animation is + /// started at the end and played backwards. + Uint16 animation_type; + /// Start position from the frame array of the base_image + Uint16 start_pos; + ///\brief The base point of the animation + /// + /// The base point always stays fixed during the animation. + /// It's types are: BP_xy, where x may be either L,M or R and y may be either + /// U, M or D. L: left end, M: middle, R: right end, U: upper end, D: lower end + /// + /// Example: BP_MU means the BP is the upper middle point of each frame. + /// Default: BP_MD + BasePointType bp_type; + ///\brief Allignment of the base point onto the base_pos + /// + /// The allignment specifies how the base point should be positioned wrt to the + /// base_pos: It's type are basically the same as in BasePointType. + /// + /// Example: (Assuming BP_MD) AT_LD means the middle point of each frame (BP_MD) + /// is mapped onto the lower left edge of the base_pos + /// Default: AT_MD + AllignType allign_type; + //@{ + /// shift is added as an additional value to the designated BP position. + Sint16 shift_x; + Sint16 shift_y; + //@} + + /* calculated or given values/functions */ + /// End position from the frame array of the base_image + Uint16 end_pos; + /// True if the animation consist of one still image (frames=1,still=true) + bool is_image; + /// True if the sanity checks suceeded + bool is_valid; + /// True if the image dimensions stay fixed during the whole animation (unused) + bool is_fixed; + + /* temporary values */ + /// Pointer to the current base position of the animation + SDL_Rect* base_pos; + /// True if the animation is running + bool is_running; + /// True if the animation is running forward at the moment + bool forward; /// Current frame number - Uint16 num; - /// Current time position (in ms) - Uint16 tcurrent; - /// frame series or running? - bool running; - /// play the animation only once? - bool once; + Uint16 cur_frame_num; + /// Current position of the base_image_desc array + Uint16 cur_im_pos; + /// Current time + Uint32 cur_time; }; #endif Modified: trunk/src/characters_common.cpp =================================================================== --- trunk/src/characters_common.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/characters_common.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -64,12 +64,8 @@ enter.erase(obj); } -void Character::updateAnimState(bool change) { - if (change) animation=im_orig; - curpos.w=animation->getWidth(); - curpos.h=animation->getHeight(); - curpos.x=(Uint16)((pos.w-curpos.w)/2); - curpos.y=(pos.h-curpos.h); +void Character::updateAnimState() { + animation=im_orig; } void Character::idle(Uint16) { Modified: trunk/src/characters_common.h =================================================================== --- trunk/src/characters_common.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/characters_common.h 2005-09-03 12:40:31 UTC (rev 139) @@ -105,12 +105,11 @@ virtual void removedObject(Object*); ///\brief Updates the current animation /// - /// Checks the state and changes the animation and curpos correpspondingly - /// \param change False if only the curpos should be changed and not the animation. - virtual void updateAnimState(bool change=true); + /// Checks the state and changes the animation correpspondingly + virtual void updateAnimState(); virtual void resetAnimState() { Object::resetAnimState(); - updateAnimState(true); + updateAnimState(); } //Define these for each character, the base function must be run for all derived classes virtual void idle(Uint16); Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/common.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -1,5 +1,4 @@ #include "common.h" -#include "menu.h" ImageCache* imgcache; SoundCache* sndcache; @@ -64,3 +63,12 @@ SDL_ShowCursor(SDL_DISABLE); } } + +Frame::Frame(SDL_Surface* surface,SDL_Rect rect): + image(surface), + pos(rect) { } + +Frame::Frame(): + image(NULL) { + pos.x=pos.y=pos.w=pos.h=0; +} Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/common.h 2005-09-03 12:40:31 UTC (rev 139) @@ -20,7 +20,6 @@ #include #endif -using std::string; using namespace std; class Object; @@ -50,26 +49,44 @@ typedef std::set::iterator monster_iterator; //General definitions -#define NOTHING 0x00000000 -#define ALL 0xFFFFFFFF -#define DIR_RIGHT 0x00000001 -#define DIR_LEFT 0x00000002 -#define DIR_UP 0x00000004 -#define DIR_DOWN 0x00000008 -#define DIR_ALL 0x0000000F -#define DIR_UPR 0x00000005 -#define DIR_UPL 0x00000006 -#define DIR_DWR 0x00000009 -#define DIR_DWL 0x0000000A -#define DIR_LR 0x00000003 +#define NOTHING 0x00000000 +#define ALL 0xFFFFFFFF +#define DIR_RIGHT 0x00000001 +#define DIR_LEFT 0x00000002 +#define DIR_UP 0x00000004 +#define DIR_DOWN 0x00000008 +#define DIR_ALL 0x0000000F +#define DIR_UPR 0x00000005 +#define DIR_UPL 0x00000006 +#define DIR_DWR 0x00000009 +#define DIR_DWL 0x0000000A +#define DIR_LR 0x00000003 -#define GAME_PAUSED 0x00000001 -#define GAME_PLAY 0x00000002 -#define GAME_MENU 0x00000004 -#define GAME_EDIT 0x00000008 -#define GAME_EDIT_NOANIM 0x00000010 -#define GAME_TEXT_INPUT 0x00000020 +//Game states +#define GAME_PAUSED 0x00000001 +#define GAME_PLAY 0x00000002 +#define GAME_MENU 0x00000004 +#define GAME_EDIT 0x00000008 +#define GAME_EDIT_NOANIM 0x00000010 +#define GAME_TEXT_INPUT 0x00000020 +//Animation types +#define ATYPE_ONCE 0x00000001 +#define ATYPE_ONCE_END 0x00000002 +#define ATYPE_LOOP 0x00000004 +#define ATYPE_SWING 0x00000008 +#define ATYPE_ONCE_REV 0x00000010 +#define ATYPE_ONCE_END_REV 0x00000020 +#define ATYPE_LOOP_REV 0x00000040 +#define ATYPE_SWING_REV 0x00000080 +#define ATYPE_ALL_ONCE 0x00000033 +#define ATYPE_ALL_LSTART 0x00000021 +#define ATYPE_ALL_LEND 0x00000012 +#define ATYPE_ALL_LOOP 0x00000044 +#define ATYPE_ALL_SWING 0x00000088 +#define ATYPE_ALL_NORMAL 0x0000000F +#define ATYPE_ALL_REV 0x000000F0 + enum ConfigKey { KEY_START, KEY_LEFT, @@ -91,6 +108,30 @@ KEY_NOANIM }; +enum BasePointType { + BP_LU, + BP_LM, + BP_LD, + BP_MU, + BP_MM, + BP_MD, + BP_RU, + BP_RM, + BP_RD +}; + +enum AllignType { + AT_LU, + AT_LM, + AT_LD, + AT_MU, + AT_MM, + AT_MD, + AT_RU, + AT_RM, + AT_RD +}; + /**\brief Collision type */ @@ -118,11 +159,21 @@ */ struct Frame { - SDL_Surface* image; - //Frame position (Source Rectangle) - SDL_Rect pos; + Frame(SDL_Surface*,SDL_Rect); + Frame(); + SDL_Surface* image; + //Frame position (Source Rectangle) + SDL_Rect pos; }; +/**\brief Image structure + +*/ +struct Image { + SDL_Surface* surface; + std::vector description; +}; + //global functions //@{ /// Quits the game with a error code Modified: trunk/src/events.cpp =================================================================== --- trunk/src/events.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/events.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -57,8 +57,10 @@ anim(runanim), del(delanim), sound(asound) { - if (anim) state|=ESTATE_ANIM; - if (anim!=NULL) duration=30000; + if (anim) { + state|=ESTATE_ANIM; + duration=30000; + } } Uint16 AnimEvent::update(Uint16 dt) { Uint16 evstate=Event::update(dt); Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/gfxeng.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -23,7 +23,7 @@ shift.x=0; shift.y=0; resize(config.width, config.height); - lifeimage=new Animation(imgcache->loadImage("life.bmp")); + lifeimage=new Animation(imgcache->loadImage(1,"life.bmp")); } GraphicsEngine::~GraphicsEngine() { @@ -155,22 +155,19 @@ tmprect=*scenario->area; srcpos=scenario->background->getFrame().pos; - shiftMapArea(tmprect,*scenario->background->getCurPos()); SDL_BlitSurface(scenario->background->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); object_iterator obit=scenario->pool->objectspool.begin(); while (obit!=scenario->pool->objectspool.end()) { - tmprect=*((*obit)->getPos()); + tmprect=((*obit)->getDrawPos()); srcpos=(*obit)->getFrame().pos; - shiftMapArea(tmprect,*((*obit)->getCurPos())); SDL_BlitSurface((*obit)->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); ++obit; } if (game_mode&GAME_PLAY && scenario->player!=NULL) { - tmprect=*(scenario->player->getPos()); + tmprect=(scenario->player->getDrawPos()); srcpos=scenario->player->getFrame().pos; - shiftMapArea(tmprect,*(scenario->player->getCurPos())); SDL_BlitSurface(scenario->player->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); } } Modified: trunk/src/imgcache.cpp =================================================================== --- trunk/src/imgcache.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/imgcache.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -3,37 +3,62 @@ #include "imgcache.h" -ImageCache::ImageCache() { - not_found="no_file.bmp"; +ImageCache::ImageCache(): + not_found("no_file.bmp") { } ImageCache::~ImageCache() { - map, SDL_Surface*>::iterator imgit=imgcache.begin(); + map, Image>::iterator imgit=imgcache.begin(); while (imgit != imgcache.end()) { - SDL_FreeSurface((*imgit).second); - imgcache.erase(imgit++); + SDL_FreeSurface((*imgit).second.surface); + imgcache.erase(imgit); + imgit=imgcache.begin(); } } -//TODO: maybe replace double scale_factor by string scale_format or sthg like that -SDL_Surface* ImageCache::loadImage(string imagename, double scale_factor) { +SDL_Rect& ImageCache::scaleRectangle(SDL_Rect& base_rect, double scale_factor) { + base_rect.x=(Sint16)(base_rect.x*scale_factor); + base_rect.y=(Sint16)(base_rect.y*scale_factor); + base_rect.w=(Uint16)(base_rect.w*scale_factor); + base_rect.h=(Uint16)(base_rect.h*scale_factor); + return base_rect; +} + +std::vector& ImageCache::scaleDescription(std::vector& description, double scale_factor) { + for (Uint16 i=0; i image_desc, string imagename, double scale_factor) { + //negative values are taken as positive reciproc + if (scale_factor<0) scale_factor=-1/scale_factor; //default is not_found if (imagename=="") { imagename=not_found; scale_factor=1; } - map, SDL_Surface*>::iterator imgit=imgcache.find(make_pair(imagename,scale_factor)); + map, Image>::iterator imgit=imgcache.find(make_pair(imagename,scale_factor)); // Image is not yet cached if (imgit==imgcache.end()) { string loadfile=config.datadir+imagename; - SDL_Surface* tmpimg=NULL; - SDL_Surface* returnimg=NULL; + SDL_Surface* tmp_surface=NULL; + Image return_image; // Loading #ifdef SDL_IMAGE - if ((tmpimg=IMG_Load(loadfile.c_str())) == NULL) { + if ((tmp_surface=IMG_Load(loadfile.c_str())) == NULL) { #else - if ((tmpimg=SDL_LoadBMP(loadfile.c_str())) == NULL) { + if ((tmp_surface=SDL_LoadBMP(loadfile.c_str())) == NULL) { #endif cout << "Couldn't load the image: " << imagename << endl; //Even the fallback image was not found @@ -41,47 +66,184 @@ quitGame(3); //Try to load the fallback image... } else { - return loadImage(not_found); + std::vector empty_vector; + return loadImage(empty_vector,not_found); } // Preprocessing } else { + return_image.surface=tmp_surface; + // if no description is given consider this as one big image + if (image_desc.empty()) { + SDL_Rect whole_image_rect; + whole_image_rect.x=0; + whole_image_rect.y=0; + whole_image_rect.w=return_image.surface->w; + whole_image_rect.h=return_image.surface->h; + image_desc.push_back(whole_image_rect); + } + return_image.description=image_desc; // About ColorKeys: I'm not sure anymore what is necessary and what not, as some stuff is now // also done in SDL_rotozoom.cpp, at least it seems to work this way... // Image's colorkey have to be set before (if unset) as the SCALING changes the color values #ifdef ALPHA - if (!(tmpimg->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA))) { + if (!(tmp_surface->flags & (SDL_SRCCOLORKEY|SDL_SRCALPHA))) { #else - if (!(tmpimg->flags & (SDL_SRCCOLORKEY))) { + if (!(tmp_surface->flags & (SDL_SRCCOLORKEY))) { #endif - SDL_SetColorKey(tmpimg, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(tmpimg->format,255,0,255)); + SDL_SetColorKey(return_image.surface, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(return_image.surface->format,255,0,255)); } - // SCALING - if (scale_factor!=1) tmpimg=scaleImage(tmpimg,scale_factor); + // SCALING (we need to assign tmp_surface a value again to have a valid SDL_FreeSurface...) + if (scale_factor!=1) tmp_surface=(scaleImage(return_image,scale_factor)).surface; // Image's colorkey - if (tmpimg->flags & SDL_SRCCOLORKEY) { - SDL_SetColorKey(tmpimg, SDL_SRCCOLORKEY|SDL_RLEACCEL, tmpimg->format->colorkey); - returnimg=SDL_DisplayFormat(tmpimg); + if (return_image.surface->flags & SDL_SRCCOLORKEY) { + SDL_SetColorKey(return_image.surface, SDL_SRCCOLORKEY|SDL_RLEACCEL, return_image.surface->format->colorkey); + return_image.surface=SDL_DisplayFormat(return_image.surface); #ifdef ALPHA // Alpha - } else if (tmpimg->flags & SDL_SRCALPHA) { - SDL_SetAlpha(tmpimg, SDL_SRCALPHA|SDL_RLEACCEL, tmpimg->format->alpha); - returnimg=SDL_DisplayFormatAlpha(tmpimg); + } else if (return_image.surface->flags & SDL_SRCALPHA) { + SDL_SetAlpha(return_image.surface, SDL_SRCALPHA|SDL_RLEACCEL, return_image.surface->format->alpha); + return_image.surface=SDL_DisplayFormatAlpha(return_image.surface); #endif // Our own colorkey (0xff00ff) } else { - SDL_SetColorKey(tmpimg, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(tmpimg->format,255,0,255)); - returnimg=SDL_DisplayFormat(tmpimg); + SDL_SetColorKey(return_image.surface, SDL_SRCCOLORKEY|SDL_RLEACCEL, SDL_MapRGB(return_image.surface->format,255,0,255)); + return_image.surface=SDL_DisplayFormat(return_image.surface); } - SDL_FreeSurface(tmpimg); + SDL_FreeSurface(tmp_surface); } - imgcache.insert(make_pair(make_pair(imagename,scale_factor),returnimg)); - return returnimg; + // Nice return statement, isn't it ;-))) + return (*(imgcache.insert(make_pair(make_pair(imagename,scale_factor),return_image))).first).second; // Return the existing Image in cache... } else return (*imgit).second; } -inline SDL_Surface* ImageCache::scaleImage(SDL_Surface* original_image, double scale_factor) { - SDL_Surface* scaled_image=zoomSurface(original_image, scale_factor, scale_factor, 1); - SDL_FreeSurface(original_image); - return scaled_image; +Image& ImageCache::loadImage(string imagename, double scale_factor, string image_desc_file) { + //negative values are taken as positive reciproc + if (scale_factor<0) scale_factor=-1/scale_factor; + if (image_desc_file.empty()) image_desc_file=imagename+".dsc"; + + /* Parse image_desc_file */ + ifstream file; + string tmpline; + string loadfile=config.datadir+image_desc_file; + std::vector description; + SDL_Rect tmp_rect; + + file.open(loadfile.c_str()); + if (!file) { + cout << "Failed to open the image description file: " << loadfile << " not found!" << endl; + } else { + cout << "Loading image description: " << loadfile << endl; + + string arg1,arg2,arg3,arg4,arg5,arg6; + Uint16 description_type=DESC_NONE; + + while (getline(file,tmpline)) { + arg1=arg2=arg3=arg4=arg5=arg6=""; + std::istringstream tmpstream(tmpline); + tmpstream >> arg1 >> arg2 >> arg3 >> arg4 >> arg5 >> arg6; + + if (arg1 == "DESCRIPTION") { + if (arg2 == "LVLANIM") { + description_type=DESC_LVLANIM; + } else if (arg2 == "FIX_RECT") { + if (arg3.empty() || arg4.empty() || arg5.empty() || arg6.empty()) { + description_type=DESC_NONE; + } else { + tmp_rect.x=atoi(arg3.c_str()); + tmp_rect.y=atoi(arg4.c_str()); + tmp_rect.w=atoi(arg5.c_str()); + tmp_rect.h=atoi(arg6.c_str()); + /* Load Image Case 2*/ + return loadImage(tmp_rect,imagename,scale_factor); + } + } else if (arg2 == "FIX_HOR_WS") { + if (arg3.empty() || arg4.empty()) { + description_type=DESC_NONE; + } else { + /* Load Image Case 3*/ + return loadImage(atoi(arg3.c_str()),atoi(arg4.c_str()),imagename,scale_factor); + } + } else if (arg2 == "FIX_HOR_NUM") { + if (arg3.empty()) { + description_type=DESC_NONE; + } else { + /* Load Image Case 4*/ + return loadImage(atoi(arg3.c_str()),imagename,scale_factor); + } + } else { + description_type=DESC_NONE; + } + } + + if (description_type==DESC_LVLANIM) { + if (arg1.empty() || arg2.empty() || arg3.empty() || arg4.empty()) { + } else { + tmp_rect.x=atoi(arg1.c_str()); + tmp_rect.y=atoi(arg2.c_str()); + tmp_rect.w=atoi(arg3.c_str()); + tmp_rect.h=atoi(arg4.c_str()); + description.push_back(tmp_rect); + } + } + } + + file.close(); + file.clear(); + } + + /* Load Image Case 1 */ + return loadImage(description,imagename,scale_factor); } + +Image& ImageCache::loadImage(SDL_Rect base_rect, string imagename, double scale_factor) { + //negative values are taken as positive reciproc + if (scale_factor<0) scale_factor=-1/scale_factor; + std::vector description; + if (imagename=="" || base_rect.w==0 || base_rect.h==0) return loadImage(description,imagename,scale_factor); + Image& img=loadImage(description,imagename,scale_factor); + if (scale_factor != 1) scaleRectangle(base_rect,scale_factor); + SDL_Rect cur_rect=base_rect; + + Uint16 x=base_rect.x; + Uint16 y=base_rect.y; + while (y<=(img.surface->h-base_rect.h)) { + cur_rect.y=y; + x=base_rect.x; + while (x<=(img.surface->w-base_rect.w)) { + cur_rect.x=x; + description.push_back(cur_rect); + x+=base_rect.w; + } + y+=base_rect.h; + } + + img.description=description; + return img; +} + +Image& ImageCache::loadImage(Uint16 num_frames, string imagename, double scale_factor) { + //negative values are taken as positive reciproc + if (scale_factor<0) scale_factor=-1/scale_factor; + std::vector description; + Image& img=loadImage(description,imagename,scale_factor); + SDL_Rect base_rectangle; + base_rectangle.x=0; + base_rectangle.y=0; + base_rectangle.w=(Uint16)(img.surface->w*1.0/num_frames/scale_factor); + base_rectangle.h=(Uint16)(img.surface->h*1.0/scale_factor); + return loadImage(base_rectangle,imagename,scale_factor); +} + +Image& ImageCache::loadImage(Uint16 width, Uint16 shift, string imagename, double scale_factor) { + //negative values are taken as positive reciproc + if (scale_factor<0) scale_factor=-1/scale_factor; + std::vector description; + Image& img=loadImage(description,imagename,scale_factor); + SDL_Rect base_rectangle; + base_rectangle.x=shift; + base_rectangle.y=0; + base_rectangle.w=(Uint16)(width*1.0/scale_factor); + base_rectangle.h=(Uint16)(img.surface->h*1.0/scale_factor); + return loadImage(base_rectangle,imagename,scale_factor); +} Modified: trunk/src/imgcache.h =================================================================== --- trunk/src/imgcache.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/imgcache.h 2005-09-03 12:40:31 UTC (rev 139) @@ -1,6 +1,9 @@ #ifndef DEF_IMGCACHE_H #define DEF_IMGCACHE_H 1 +#define DESC_NONE 0x00000000 +#define DESC_LVLANIM 0x00000001 + /** \brief Caches images. Caches images supported by SDL_image according to their name @@ -13,12 +16,20 @@ /// Loads an image if it isn't already contained in the pool /// according to it's image name. If the image is not found /// it tries to load a fallback image (not_found). - SDL_Surface* loadImage(string imagename="", double scale_factor=1); + //@{ + Image& loadImage(std::vector image_desc, string imagename, double scale_factor=1); + Image& loadImage(string imagename, double scale_factor=1, string image_desc_file=""); + Image& loadImage(Uint16 num_frames, string imagename, double scale_factor=1); + Image& loadImage(Uint16 width, Uint16 shift, string imagename, double scale_factor=1); + Image& loadImage(SDL_Rect base_rect, string imagename, double scale_factor=1); + //@} private: - std::map,SDL_Surface*> imgcache; + std::map,Image> imgcache; string not_found; private: - inline SDL_Surface* scaleImage(SDL_Surface* original_image, double scale_factor); + SDL_Rect& scaleRectangle(SDL_Rect& base_rect, double scale_factor); + std::vector& scaleDescription(std::vector& description, double scale_factor); + Image& scaleImage(Image& original_image, double scale_factor); }; #endif Modified: trunk/src/lost_penguins.cpp =================================================================== --- trunk/src/lost_penguins.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/lost_penguins.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -44,8 +44,8 @@ cout << "SoundEngine...\n"; sfxeng=new SoundsEngine(); cout << "Fonts...\n"; - font=new Font(imgcache->loadImage("font_arial_white_16_01.png")); - font2=new Font(imgcache->loadImage("font_arial_red_16_01.png")); + font=new Font(imgcache->loadImage(1,"font_arial_white_16_01.png").surface); + font2=new Font(imgcache->loadImage(1,"font_arial_red_16_01.png").surface); cout << "InputHandler...\n"; input=new InputHandler(); cout << "Initializing Scenario...\n"; Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/monsters_common.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -73,17 +73,12 @@ } } -void Monster::updateAnimState(bool change) { - if (!change) { - } else if (state&STATE_LEFT) { +void Monster::updateAnimState() { + if (state&STATE_LEFT) { animation=im_left; } else { animation=im_right; } - curpos.w=animation->getWidth(); - curpos.h=animation->getHeight(); - curpos.x=(Uint16)((pos.w-curpos.w)/2); - curpos.y=(pos.h-curpos.h); } void Monster::idle(Uint16 dt) { Modified: trunk/src/monsters_common.h =================================================================== --- trunk/src/monsters_common.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/monsters_common.h 2005-09-03 12:40:31 UTC (rev 139) @@ -12,7 +12,7 @@ Monster(string img, Sint16 xpos=0, Sint16 ypos=0, string name="Monster"); virtual ~Monster(); virtual void removedObject(Object*); - virtual void updateAnimState(bool change=true); + virtual void updateAnimState(); virtual void idle(Uint16); virtual void fall(Uint16); virtual Uint16 hit(Uint16 direction, Weapon& weap); Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/baleog.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -10,19 +10,19 @@ Baleog::Baleog(string imagename, Sint16 xcord, Sint16 ycord, string pname): Player(imagename,xcord,ycord,pname) { - im_left=new Animation(scenario->imgcache->loadImage("baleog1_left.bmp")); - im_right=new Animation(scenario->imgcache->loadImage("baleog1_right.bmp")); - im_run_left=new Animation(scenario->imgcache->loadImage("baleog1-run_left.png"),8,1000); - im_run_right=new Animation(scenario->imgcache->loadImage("baleog1-run_right.png"),8,1000); + im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),1000,8); + im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8); im_fall_left=im_left; im_fall_right=im_right; im_krit_left=im_left; im_krit_right=im_right; - im_land_left=new Animation(scenario->imgcache->loadImage("olaf1_land_left.bmp"),1,T_IRR,true); - im_land_right=new Animation(scenario->imgcache->loadImage("olaf1_land_right.bmp"),1,T_IRR,true); + im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); weapon=Weapon(-1,W_STRIKE); - im_sword_left=new Animation(scenario->imgcache->loadImage("BaleogCyborg_Slash_left.png"),8,1000,true); - im_sword_right=new Animation(scenario->imgcache->loadImage("BaleogCyborg_Slash_right.png"),8,1000,true); + im_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),1000,8,ATYPE_ONCE_END); + im_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),1000,8,ATYPE_ONCE_END); au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/erik.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -15,16 +15,16 @@ jump(V_JUMP), jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); - im_left=new Animation(scenario->imgcache->loadImage("erik1_left.bmp")); - im_right=new Animation(scenario->imgcache->loadImage("erik1_right.bmp")); + im_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); + im_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); im_run_right=im_right; im_run_left=im_left; im_fall_left=im_left; im_fall_right=im_right; im_krit_left=im_left; im_krit_right=im_right; - im_land_left=new Animation(scenario->imgcache->loadImage("olaf1_land_left.bmp"),1,T_IRR,true); - im_land_right=new Animation(scenario->imgcache->loadImage("olaf1_land_right.bmp"),1,T_IRR,true); + im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); au_jump=scenario->sndcache->loadWAV("rboots.wav"); au_hit=scenario->sndcache->loadWAV("erikhit.wav"); au_run=NULL; Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/fang.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -12,18 +12,18 @@ Player(imagename,xcord,ycord,pname), jump(V_JUMP) { weapon=Weapon(-1,W_STRIKE); - im_left=new Animation(scenario->imgcache->loadImage("Fang_Breath_left.png"),4,1000); - im_right=new Animation(scenario->imgcache->loadImage("Fang_Breath_right.png"),4,1000); - im_run_left=new Animation(scenario->imgcache->loadImage("Fang_walk_left.png"),8,1000); - im_run_right=new Animation(scenario->imgcache->loadImage("Fang_walk_right.png"),8,1000); + im_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),1000,4); + im_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),1000,4); + im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),1000,8); + im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),1000,8); im_fall_left=im_left; im_fall_right=im_right; im_krit_left=im_left; im_krit_right=im_right; - im_land_left=new Animation(scenario->imgcache->loadImage("olaf1_land_left.bmp"),1,T_IRR,true); - im_land_right=new Animation(scenario->imgcache->loadImage("olaf1_land_right.bmp"),1,T_IRR,true); - im_claw_left=new Animation(scenario->imgcache->loadImage("Fang_Clawslash_left.png"),8,1000,true); - im_claw_right=new Animation(scenario->imgcache->loadImage("Fang_Clawslash_right.png"),8,1000,true); + im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),1000,8,ATYPE_ONCE_END); + im_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),1000,8,ATYPE_ONCE_END); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav"); au_jump=scenario->sndcache->loadWAV("fangjump.wav"); Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/olaf.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -12,28 +12,28 @@ Olaf::Olaf(string imagename, Sint16 xcord, Sint16 ycord, string pname): Player(imagename,xcord,ycord,pname), fart(V_FART) { - im_left=new Animation(scenario->imgcache->loadImage("olaf1_left.bmp")); - im_right=new Animation(scenario->imgcache->loadImage("olaf1_right.bmp")); - im_run_left=new Animation(scenario->imgcache->loadImage("olaf1-run_left.png"),8,1000); - im_run_right=new Animation(scenario->imgcache->loadImage("olaf1-run_right.png"),8,1000); + im_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); + im_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); + im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),1000,8); + im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),1000,8); im_fall_left=im_left; im_fall_right=im_right; im_krit_left=im_left; im_krit_right=im_right; - im_land_left=new Animation(scenario->imgcache->loadImage("olaf1_land_left.bmp"),1,T_IRR,true); - im_land_right=new Animation(scenario->imgcache->loadImage("olaf1_land_right.bmp"),1,T_IRR,true); + im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_small_left=new Animation(scenario->imgcache->loadImage("Olaf_Small_Walk_left.png"),7,0); - im_small_right=new Animation(scenario->imgcache->loadImage("Olaf_Small_Walk_right.png"),7,0); - im_run_small_left=new Animation(scenario->imgcache->loadImage("Olaf_Small_Walk_left.png"),7,500); - im_run_small_right=new Animation(scenario->imgcache->loadImage("Olaf_Small_Walk_right.png"),7,500); - im_shield_right=new Animation(scenario->imgcache->loadImage("olaf1_fall_shield_right.bmp")); - im_shield_left=new Animation(scenario->imgcache->loadImage("olaf1_fall_shield_left.bmp")); + im_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),0,1); + im_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),0,1); + im_run_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),500,7); + im_run_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),500,7); + im_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); + im_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); im_run_shield_right=im_shield_right; im_run_shield_left=im_shield_left; im_fall_shield_left=im_shield_left; im_fall_shield_right=im_shield_right; - im_die=new Animation(60,scenario->imgcache->loadImage("kuru.bmp"),12,2000,true); + im_die=loadAnimation(scenario->imgcache->loadImage(60,"kuru.bmp"),2000,12,0,ATYPE_ONCE_END); au_small=scenario->sndcache->loadWAV("blob.wav"); au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); @@ -54,9 +54,8 @@ delete im_shield_left; } -void Olaf::updateAnimState(bool change) { - if (!change) { - } else if (state&STATE_SMALL) { +void Olaf::updateAnimState() { + if (state&STATE_SMALL) { if (state&STATE_LEFT) { if (state&STATE_MLEFT) animation=im_run_small_left; else animation=im_small_left; @@ -85,10 +84,6 @@ otype&=~OTYPE_DENSE_D; Player::updateAnimState(); } - curpos.w=animation->getWidth(); - curpos.h=animation->getHeight(); - curpos.x=(Uint16)((pos.w-curpos.w)/2); - curpos.y=(pos.h-curpos.h); } void Olaf::in_left(Uint16 dt) { @@ -114,10 +109,10 @@ //Assume both images have the same dimension else tmpanim=im_orig; //IDEA: left/right edge instead of bottom? - tmppos.x+=(Sint16)((tmppos.w-tmpanim->getWidth())/2); - tmppos.y+=tmppos.h-tmpanim->getHeight(); - tmppos.w=tmpanim->getWidth(); - tmppos.h=tmpanim->getHeight(); + tmppos.x+=(Sint16)((tmppos.w-tmpanim->getFrameDim().w)/2); + tmppos.y+=tmppos.h-tmpanim->getFrameDim().h; + tmppos.w=tmpanim->getFrameDim().w; + tmppos.h=tmpanim->getFrameDim().h; if (!(checkMove(tmppos,true).enter&DIR_ALL)) { pos=tmppos; if (small) { Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/olaf.h 2005-09-03 12:40:31 UTC (rev 139) @@ -19,7 +19,7 @@ Olaf(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Olaf"); virtual ~Olaf(); /// Additionally checks if Olaf is small and how he wears his shield - virtual void updateAnimState(bool change=true); + virtual void updateAnimState(); virtual void in_left(Uint16); virtual void in_right(Uint16); /// \brief Olaf tries to shrink (if he was big) Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/scorch.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -12,16 +12,16 @@ Player(imagename,xcord,ycord,pname), left_wings(SCORCH_MAX_WINGS), wing(V_FLY) { - im_left=new Animation(scenario->imgcache->loadImage("baleog1_left.bmp")); - im_right=new Animation(scenario->imgcache->loadImage("baleog1_right.bmp")); - im_run_left=new Animation(scenario->imgcache->loadImage("baleog1-run_left.png"),8,1000); - im_run_right=new Animation(scenario->imgcache->loadImage("baleog1-run_right.png"),8,1000); + im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),1000,8); + im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8); im_fall_left=im_left; im_fall_right=im_right; im_krit_left=im_left; im_krit_right=im_right; - im_land_left=new Animation(scenario->imgcache->loadImage("olaf1_land_left.bmp"),1,T_IRR,true); - im_land_right=new Animation(scenario->imgcache->loadImage("olaf1_land_right.bmp"),1,T_IRR,true); + im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); au_tired=scenario->sndcache->loadWAV("flwings.wav"); au_hit=scenario->sndcache->loadWAV("draghit.wav"); Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects/zombie.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -15,8 +15,8 @@ au_attack(scenario->sndcache->loadWAV("clang.wav")), T_Attack_Bite(1500) { maxspeedx=80; - im_left=new Animation(scenario->imgcache->loadImage("olaf1_left.bmp"),2,1000); - im_right=new Animation(scenario->imgcache->loadImage("olaf1_right.bmp"),2,1000); + im_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),1000,2); + im_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),1000,2); weapon=Weapon(-1,W_STRIKE); } Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects_common.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -10,19 +10,14 @@ Object::Object(string imagename, Sint16 xcord, Sint16 ycord, string oname): state(NOTHING), event(NULL), - im_orig(new Animation(scenario->imgcache->loadImage(imagename))), + im_orig(loadAnimation(scenario->imgcache->loadImage(1,imagename))), otype(NOTHING), name(oname), delete_flag(false) { animation=im_orig; + pos=animation->getFrameDim(); pos.x=xcord; pos.y=ycord; - pos.w=animation->getWidth(); - pos.h=animation->getHeight(); - curpos.w=pos.w; - curpos.h=pos.h; - curpos.x=0; - curpos.y=0; onum=++scenario->max_obj_num; } @@ -64,7 +59,24 @@ return ok; } -const Frame& Object::getFrame() const { +Animation* Object::loadAnimation(const Image& abase_image, + Uint32 aduration, + Uint16 aframes, + Uint16 aanimation_type, + Uint16 astart_pos, + BasePointType abp_type, + AllignType aallign_type, + Sint16 ashift_x, + Sint16 ashift_y) { + Animation* anim=new Animation(abase_image,aduration,aframes,aanimation_type,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); + anim->setBasePos(&pos); + return anim; +} + +SDL_Rect Object::getDrawPos() const { + return animation->getDrawPos(); +} +const Frame Object::getFrame() const { return animation->getFrame(); } bool Object::updateAnim(Uint16 dt) { @@ -72,11 +84,13 @@ } void Object::setAnim(Animation* anim) { animation=anim; - animation->start(); + animation->setBasePos(&pos); + animation->runAnim(); } void Object::resetAnimState() { animation=im_orig; - animation->setFrame(0); + animation->setBasePos(&pos); + animation->runAnim(); } bool Object::isRunning() const { return animation->isRunning(); Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/objects_common.h 2005-09-03 12:40:31 UTC (rev 139) @@ -61,12 +61,8 @@ SDL_Rect* getPos() { return &pos; } - //we want: bottom-middle of pos - //animation (image) changes (depending on State changes) - SDL_Rect* getCurPos() { - return &curpos; - } - const Frame& getFrame() const; + SDL_Rect getDrawPos() const; + const Frame getFrame() const; //@{ Uint16 getType() const { return otype; @@ -109,6 +105,16 @@ delete this; } //@} + /// Load an animation bound onto this object + Animation* loadAnimation(const Image& abase_image, + Uint32 aduration=0, + Uint16 aframes=1, + Uint16 aanimation_type=ATYPE_LOOP, + Uint16 astart_pos=0, + BasePointType abp_type=BP_MD, + AllignType aallign_type=AT_MD, + Sint16 ashift_x=0, + Sint16 ashift_y=0); //Events (triggered animations/effects) //@{ /// Clears the event field (sets it to NULL). This should only be used by @@ -171,9 +177,6 @@ Animation* im_orig; Animation* animation; ///\todo Document this! - //temporary information about where to _draw_ the animation frame: - //curpos.wh <= pos.wh, curpos.xy = positive dxy - SDL_Rect curpos; /// Upper left logical position of the object (used for decisions) SDL_Rect pos; //Object type Modified: trunk/src/physics.cpp =================================================================== --- trunk/src/physics.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/physics.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -104,7 +104,7 @@ character_iterator cit=scenario->pool->characterspool.begin(); while (cit!=scenario->pool->characterspool.end()) { (*cit)->fall(dt); - (*cit)->updateAnimState(!((*cit)->getState(ESTATE_ANIM))); + if (!((*cit)->getState(ESTATE_ANIM))) (*cit)->updateAnimState(); ++cit; } //update the animations of all objects @@ -113,6 +113,7 @@ if ((*obit)->getState(ESTATE_ANIM)) { bool runs=(*obit)->updateAnim(dt); if (!runs) (*obit)->stopEvent(); + } else if ((*obit)->isRunning()) (*obit)->updateAnim(dt); ++obit; } @@ -136,7 +137,7 @@ character_iterator cit=scenario->pool->characterspool.begin(); while (cit!=scenario->pool->characterspool.end()) { (*cit)->fall(dt); - (*cit)->updateAnimState(!((*cit)->getState(ESTATE_ANIM))); + if (!((*cit)->getState(ESTATE_ANIM))) (*cit)->updateAnimState(); ++cit; } //update the animations of all objects Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/players_common.cpp 2005-09-03 12:40:31 UTC (rev 139) @@ -57,7 +57,7 @@ } Frame Player::getIcon() const { - return (im_right->getFrame(0)); + return (im_right->getBaseFrame()); } void Player::addEnter(std::set& aset) { @@ -146,9 +146,8 @@ Character::setEvent(ev); } -void Player::updateAnimState(bool change) { - if (!change) { - } else if (state&STATE_LEFT) { +void Player::updateAnimState() { + if (state&STATE_LEFT) { if (state&STATE_FALL) { if (speed>V_KRIT) { animation=im_krit_left; @@ -173,10 +172,6 @@ animation=im_right; } } - curpos.w=animation->getWidth(); - curpos.h=animation->getHeight(); - curpos.x=(Uint16)((pos.w-curpos.w)/2); - curpos.y=(pos.h-curpos.h); } void Player::idle(Uint16 dt) { Modified: trunk/src/players_common.h =================================================================== --- trunk/src/players_common.h 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/src/players_common.h 2005-09-03 12:40:31 UTC (rev 139) @@ -56,7 +56,7 @@ //@} //VIRTUAL METHODS //@{ - virtual void updateAnimState(bool change=true); + virtual void updateAnimState(); virtual void idle(Uint16); virtual void fall(Uint16); virtual Uint16 hit(Uint16 direction, Weapon& weap); Modified: trunk/tools/lvl2magick.c =================================================================== --- trunk/tools/lvl2magick.c 2005-09-03 11:58:44 UTC (rev 138) +++ trunk/tools/lvl2magick.c 2005-09-03 12:40:31 UTC (rev 139) @@ -278,7 +278,7 @@ if (strcmp(config.data_file,"")==0) { snprintf(config.data_file,16,"%s.dat",config.basename); } - snprintf(config.geom_file,16,"%s.txt",config.basename); + snprintf(config.geom_file,16,"%s.dsc",config.basename); /* set colorkey in palette */ lvl_palette[0][red] = (unsigned char)(config.colorkey.red*255/MaxRGB); @@ -651,11 +651,11 @@ } /* Create the geometry file */ - snprintf(buf,16,"%s.txt",config.basename); + snprintf(buf,16,"%s.dsc",config.basename); geom_file = fopen(buf,"w"); geom_file = freopen(buf,"a",geom_file); - fprintf(geom_file,"LVLGEOM\n"); + fprintf(geom_file,"DESCRIPTION LVLANIM\n"); fprintf(geom_file,"Size %u %u\n\n",lvlanim_size,num_entries); for (i=0; i Author: jonas Date: 2005-09-03 09:17:01 -0400 (Sat, 03 Sep 2005) New Revision: 140 Added: trunk/docs/data.txt trunk/docs/level.txt Log: tech files by al3x about interplay formats (slv,lvl,levels) Added: trunk/docs/data.txt =================================================================== --- trunk/docs/data.txt 2005-09-03 12:40:31 UTC (rev 139) +++ trunk/docs/data.txt 2005-09-03 13:17:01 UTC (rev 140) @@ -0,0 +1,64 @@ +Lost Vikings DATA files +----------------------- +Written by Alex Beregszaszi + +Extensions: .LVL and .SLV + +LVL +--- + +Contains graphic sprites + +32bit tag (always = DATA) +32bit size +32bit data size (byte swapped) + +SLV +--- + +Contains sound sprites + +32bit tag (always = DATA) +32bit size +32bit data size (byte swapped) +32bit unknown (maybe entries?) +32bit sampling rate +32bit sample size +32bit unknown (coding type?) +32bit entries? +7*32bit unkown (always zero?) +16bit unknown +13*8bit - string: filename +32bit unknown +16bit unknown + +ENTRIES: + +(normal) + +32bit data size +32bit sampling rate +32bit sample size +32bit unknown (coding type ?) +32bit unknown +7*32bit unkown (always zero?) +16bit unknown +13*8bit - string: filename +32bit unknown +16bit unknown +xbit data +aligned end, padded with zero + +(byteswapped) + +32bit data size +32bit sampling rate +32bit sample size +32bit unknown +32bit unknown +7*32bit unkown (always zero?) +13*8bit - string: filename +8bit unknown +2*32bit unknown +xbit data +aligned end, padded with zero Added: trunk/docs/level.txt =================================================================== --- trunk/docs/level.txt 2005-09-03 12:40:31 UTC (rev 139) +++ trunk/docs/level.txt 2005-09-03 13:17:01 UTC (rev 140) @@ -0,0 +1,22 @@ +DOS - WIN differences + +bytes 6,7,8,9 -- size ? +and starting 0x1c + +LEVEL diffs + +bytes 5,6,7,8,9,a,b,c,d,10 ... + +byte[5] == byte[a] == maybe num of sprites?!/entries?! + +hmm.. between D1 and D2, only 6,7,8,9 differs, and then until 0x37c nothing +D1->D3: starting 0x21..., then 0x14 + + +FORMAT +------ + +byte0-3 ID == 'DATA' +byte4-5 num of sprites? +byte6-8 sizes? +byte9-10 num of sprites? From DONOTREPLY at icculus.org Sat Sep 3 10:21:55 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Sep 2005 10:21:55 -0400 Subject: r141 - in trunk/src: . objects Message-ID: <20050903142155.29219.qmail@icculus.org> Author: jonas Date: 2005-09-03 10:21:55 -0400 (Sat, 03 Sep 2005) New Revision: 141 Modified: trunk/src/editor.h trunk/src/events.h trunk/src/objects/plant.h trunk/src/objects/teleport.h Log: a few additional documentations to avoid doxygen warnings and to get a better class hierarchy image Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-03 13:17:01 UTC (rev 140) +++ trunk/src/editor.h 2005-09-03 14:21:55 UTC (rev 141) @@ -6,7 +6,7 @@ #define EDIT_ACT_BOX 0x00000008 #define EDIT_PLACE_OBJECT 0x00000010 -/** \brief abstract selection box base class +/** \brief abstract Box base class */ class Box { @@ -44,18 +44,27 @@ bool centered; }; +/** \brief Main Box of the editor with all main options + +*/ class EditBox : public Box { public: EditBox(Sint16,Sint16); virtual void act(Sint8); }; +/** \brief Box used to choose the object that is to be placed + +*/ class PlaceBox : public Box { public: PlaceBox(Sint16,Sint16); virtual void act(Sint8); }; +/** \brief Abstract base class for text input boxes + +*/ class TextInputBox : public Box { public: TextInputBox(Sint16,Sint16); @@ -70,6 +79,9 @@ virtual void update(); }; +/** \brief Configure object attributes + +*/ class ObjectBox : public TextInputBox { public: ObjectBox(string,string,Sint16,Sint16,string targ1="",string arg1="",string targ2="",string arg2="",string targ3="",string arg3=""); @@ -78,6 +90,9 @@ string objname; }; +/** \brief Saves the map to the specified file + +*/ class SaveAsBox : public TextInputBox { public: SaveAsBox(Sint16,Sint16); @@ -85,6 +100,9 @@ virtual void evaluateEntry(); }; +/** \brief Opens the specified map + +*/ class OpenMapBox : public TextInputBox { public: OpenMapBox(Sint16,Sint16); @@ -92,6 +110,9 @@ virtual void evaluateEntry(); }; +/** \brief Creates a new map with the specified attributes + +*/ class NewMapBox : public TextInputBox { public: NewMapBox(Sint16,Sint16); Modified: trunk/src/events.h =================================================================== --- trunk/src/events.h 2005-09-03 13:17:01 UTC (rev 140) +++ trunk/src/events.h 2005-09-03 14:21:55 UTC (rev 141) @@ -53,6 +53,10 @@ */ class AnimEvent : public Event { public: + /// \param obj Owner object of the AnimEvent + /// \param length Duration of the animation, once it's started + /// \param edelay Delay until the animation is started + /// \param switchstate States that will be switched when the animation starts/ends /// \param asound Sound (Mix_Chunk) to be played when the event starts /// \param runanim Animation to be run when the event starts /// \todo Get rid of the delanim parameter @@ -97,11 +101,19 @@ */ class EAttack : public CAnimEvent { public: + /// \param chr Character owner of the AnimEvent + /// \param length Duration of the animation, once it's started /// \param atweapon Weapon to be used for the attack /// \param dir Directions to attack /// \param weapon_range Range of the weapon starting from the /// character into all specified directions /// \param target_mask Mask for the object type of the targets to be hit + /// \param edelay Delay until the animation is started + /// \param switchstate States that will be switched when the animation starts/ends + /// \param esound Sound (Mix_Chunk) to be played when the event starts + /// \param runanim Animation to be run when the event starts + /// \todo Get rid of the delanim parameter + /// \param delanim True if the animation should be deleted EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weapon_range=0, Uint16 target_mask=NOTHING, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL, Animation* runanim=NULL, bool delanim=false); @@ -121,8 +133,6 @@ class ERun : public CAnimEvent { public: /// Adds the initial speed - /// \param inispeed Initial horizontal speed to be added - /// \param ahspeed Horizontal speed to be added when the event starts ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL, Animation* runanim=NULL, bool delanim=false); virtual ~ERun(); Modified: trunk/src/objects/plant.h =================================================================== --- trunk/src/objects/plant.h 2005-09-03 13:17:01 UTC (rev 140) +++ trunk/src/objects/plant.h 2005-09-03 14:21:55 UTC (rev 141) @@ -9,7 +9,7 @@ virtual ~Plant(); virtual void touch(Object*); virtual void idle(Uint16); - virtual Uint16 hit(Uint16 dir, Weapon& weap); + virtual Uint16 hit(Uint16 direction, Weapon& weap); private: Uint16 recover; Sint16 tcur; Modified: trunk/src/objects/teleport.h =================================================================== --- trunk/src/objects/teleport.h 2005-09-03 13:17:01 UTC (rev 140) +++ trunk/src/objects/teleport.h 2005-09-03 14:21:55 UTC (rev 141) @@ -6,8 +6,12 @@ */ class Teleporter : public Object { public: + /// \param imagename Name of the image file used to display this object + /// \param xpos x coordinate of the object position + /// \param ypos y coordinate of the object position /// \param xExit x coordinate of the exit position /// \param yExit y coordinate of the exit position + /// \param name Name of this object Teleporter(string imagename, Sint16 xpos=0, Sint16 ypos=0, Sint16 xExit=0, Sint16 yExit=0, string name="Teleporter"); virtual ~Teleporter(); virtual bool act(Object* obj); From DONOTREPLY at icculus.org Sat Sep 3 13:18:56 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Sep 2005 13:18:56 -0400 Subject: r142 - trunk/tools Message-ID: <20050903171856.11322.qmail@icculus.org> Author: jonas Date: 2005-09-03 13:18:56 -0400 (Sat, 03 Sep 2005) New Revision: 142 Modified: trunk/tools/lvl2magick.c Log: fixed a huge bug that come up with a recent magick api update (specified tile size manually), lvl2magick should produce correct results again... Modified: trunk/tools/lvl2magick.c =================================================================== --- trunk/tools/lvl2magick.c 2005-09-03 14:21:55 UTC (rev 141) +++ trunk/tools/lvl2magick.c 2005-09-03 17:18:56 UTC (rev 142) @@ -305,13 +305,13 @@ * * Data file Format: * - * ----------------- - * LVLDATA + * --------------------------- + * ANIMATION LVLANIM imagename * * start_offset size name * ... * - * ----------------- + * --------------------------- * * start_offset is the image index off all images in the file * size is the number of frames of the animation @@ -319,7 +319,7 @@ * */ unsigned int parseDataFile(char* data_file_name, LVLAnim** lvlanims) { - const char data_id[]="LVLDATA"; + const char data_id[]="ANIMATION LVLANIM"; unsigned int start_num, size, data_size=0; char name[50], line[80]; int match=0; @@ -333,7 +333,7 @@ return 0; } - if (!fgets(line,80,data_file) || strncmp(line,data_id,7)) { + if (!fgets(line,80,data_file) || strncmp(line,data_id,17)) { printf("Data file %s is invalid!!\n",data_file_name); fclose(data_file); return 0; @@ -423,6 +423,7 @@ /* temporary variables */ char buf[20]; + char tmpcstr[10]=""; struct stat sb; unsigned int i,j,width,height,x_off=0,y_off=0,maxh=0; int d_exception=0; @@ -616,6 +617,8 @@ /* Montage the image and append it to the big image list */ if (config.write!=0) { if (anim_list!=(Image *) ((void *)0)) { + snprintf(tmpcstr,9,"%lux1",GetImageListLength(anim_list)); + montage_anim_info.tile=tmpcstr; anim_image=MontageImages(anim_list,&montage_anim_info,&exception); anim_image->matte_color=config.colorkey; @@ -636,6 +639,8 @@ /* Create a big image (montage) using the big image list */ if (config.write!=0) { + snprintf(tmpcstr,9,"1x%lu",GetImageListLength(image_list)); + montage_info.tile=tmpcstr; big_image=MontageImages(image_list,&montage_info,&exception); big_image->matte_color=config.colorkey; DestroyImageList(image_list); From DONOTREPLY at icculus.org Sat Sep 3 20:13:19 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 3 Sep 2005 20:13:19 -0400 Subject: r143 - in trunk/src: . objects Message-ID: <20050904001319.10507.qmail@icculus.org> Author: jonas Date: 2005-09-03 20:13:18 -0400 (Sat, 03 Sep 2005) New Revision: 143 Modified: trunk/src/Makefile trunk/src/animation.cpp trunk/src/animation.h trunk/src/characters_common.cpp trunk/src/characters_common.h trunk/src/common.h trunk/src/imgcache.cpp trunk/src/imgcache.h trunk/src/lost_penguins.cpp trunk/src/objects/Makefile trunk/src/objects/baleog.cpp trunk/src/objects/erik.cpp trunk/src/objects/olaf.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp Log: Numerious animation loading improvements: o lvl2magick now creates an animation data file o output name and id tag name changes in lvl2magick (minor) o scale_factor in ImageCache should scale the area, not the area squared o add directions to im_die (im_die_left, im_die_right) o fixed a huge bug that only allowed start_pos=0 in the animation class o removed cur_im_pos (=cur_frame_num+start_pos) in the animation class o added animfile, datadir and lvlscale as specifiable options (lvlscale specifies the scale factor for lvl images) o added loadAnimation(...) to load animations from the animation data file o used loadAnimation(...) and the new animations for Erik Modified: trunk/src/Makefile =================================================================== --- trunk/src/Makefile 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/Makefile 2005-09-04 00:13:18 UTC (rev 143) @@ -35,6 +35,7 @@ distclean: clean rm -f *~ rm -f Makefile.dep + rm -f Makefile.dep.bak +$(MAKE) -C objects distclean depend: Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/animation.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -34,11 +34,9 @@ if (animation_type&ATYPE_ALL_NORMAL) { forward=true; cur_frame_num=0; - cur_im_pos=start_pos; } else { forward=false; cur_frame_num=frames-1; - cur_im_pos=end_pos; } } bool Animation::stopAnim() { @@ -50,10 +48,8 @@ cur_time=0; if (animation_type&ATYPE_ALL_LSTART) { cur_frame_num=0; - cur_im_pos=start_pos; } else { cur_frame_num=frames-1; - cur_im_pos=end_pos; } } return isRunning(); @@ -128,7 +124,7 @@ } Frame Animation::getFrame() const { if (!isValid()) cout << "Invalid Frame of an invalid animation!" << endl; - return Frame(base_image.surface,base_image.description[cur_frame_num]); + return Frame(base_image.surface,base_image.description[cur_frame_num+start_pos]); } Frame Animation::getBaseFrame() const { if (!isValid()) cout << "Invalid Base Frame of an invalid animation!" << endl; @@ -244,7 +240,6 @@ cur_time=0; forward=true; cur_frame_num=0; - cur_im_pos=start_pos; is_running=false; is_fixed=true; is_valid=true; @@ -260,11 +255,9 @@ if (animation_type&ATYPE_ALL_NORMAL) { forward=true; cur_frame_num=0; - cur_im_pos=start_pos; } else { forward=false; cur_frame_num=frames-1; - cur_im_pos=end_pos; } } return is_valid; Modified: trunk/src/animation.h =================================================================== --- trunk/src/animation.h 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/animation.h 2005-09-04 00:13:18 UTC (rev 143) @@ -17,7 +17,7 @@ /// \param ashift_x x shift value /// \param ashift_y y shift value /// - /// To load one still image simply use: Animation(loadImage(1,"image_name.png")) + /// To load one still image simply use: Animation(imgcache->loadImage(1,"image_name.png")) Animation(const Image& abase_image, Uint32 aduration=0, Uint16 aframes=1, @@ -45,7 +45,7 @@ /// Calculates and returns the current frame Frame getFrame() const; /// Calculates and returns the current draw position using: - /// base_pos,bp_type,allign_type,shift,cur_im_pos + /// base_pos,bp_type,allign_type,shift SDL_Rect getDrawPos() const; /// HACK: Return the dimensions of the first frame SDL_Rect getFrameDim() const; @@ -129,8 +129,6 @@ bool forward; /// Current frame number Uint16 cur_frame_num; - /// Current position of the base_image_desc array - Uint16 cur_im_pos; /// Current time Uint32 cur_time; }; Modified: trunk/src/characters_common.cpp =================================================================== --- trunk/src/characters_common.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/characters_common.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -17,7 +17,8 @@ speed(0), gravity(900), Dgrav(0), - im_die(NULL), + im_die_left(NULL), + im_die_right(NULL), dense_types(NOTHING), enemy_types(NOTHING), weapon(Weapon(0)) { Modified: trunk/src/characters_common.h =================================================================== --- trunk/src/characters_common.h 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/characters_common.h 2005-09-04 00:13:18 UTC (rev 143) @@ -174,7 +174,8 @@ //temporary attributes Sint16 Dgrav; //Die animation - Animation* im_die; + Animation* im_die_left; + Animation* im_die_right; //Entered objects std::set enter; //Touched objects Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/common.h 2005-09-04 00:13:18 UTC (rev 143) @@ -87,6 +87,11 @@ #define ATYPE_ALL_NORMAL 0x0000000F #define ATYPE_ALL_REV 0x000000F0 +//Description formats +#define DESC_NONE 0x00000000 +#define DESC_LVLANIM 0x00000001 +#define DESC_ANIM_LVLANIM 0x00000002 + enum ConfigKey { KEY_START, KEY_LEFT, @@ -152,7 +157,9 @@ int audio_channels; string datadir; string map; + string anim_file; SDLKey keybind[30]; + double lvlscale; }; /**\brief Frame format Modified: trunk/src/imgcache.cpp =================================================================== --- trunk/src/imgcache.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/imgcache.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -16,10 +16,10 @@ } SDL_Rect& ImageCache::scaleRectangle(SDL_Rect& base_rect, double scale_factor) { - base_rect.x=(Sint16)(base_rect.x*scale_factor); - base_rect.y=(Sint16)(base_rect.y*scale_factor); - base_rect.w=(Uint16)(base_rect.w*scale_factor); - base_rect.h=(Uint16)(base_rect.h*scale_factor); + base_rect.x=(Sint16)(base_rect.x*sqrt(scale_factor)); + base_rect.y=(Sint16)(base_rect.y*sqrt(scale_factor)); + base_rect.w=(Uint16)(base_rect.w*sqrt(scale_factor)); + base_rect.h=(Uint16)(base_rect.h*sqrt(scale_factor)); return base_rect; } @@ -31,7 +31,7 @@ } Image& ImageCache::scaleImage(Image& original_image, double scale_factor) { - SDL_Surface* newsurface=zoomSurface(original_image.surface, scale_factor, scale_factor, 1); + SDL_Surface* newsurface=zoomSurface(original_image.surface, sqrt(scale_factor), sqrt(scale_factor), 1); SDL_FreeSurface(original_image.surface); original_image.surface=newsurface; scaleDescription(original_image.description, scale_factor); @@ -143,7 +143,9 @@ std::istringstream tmpstream(tmpline); tmpstream >> arg1 >> arg2 >> arg3 >> arg4 >> arg5 >> arg6; - if (arg1 == "DESCRIPTION") { + if (arg1 == "ANIMATION") { + description_type=DESC_NONE; + } else if (arg1 == "DESCRIPTION") { if (arg2 == "LVLANIM") { description_type=DESC_LVLANIM; } else if (arg2 == "FIX_RECT") { Modified: trunk/src/imgcache.h =================================================================== --- trunk/src/imgcache.h 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/imgcache.h 2005-09-04 00:13:18 UTC (rev 143) @@ -1,9 +1,6 @@ #ifndef DEF_IMGCACHE_H #define DEF_IMGCACHE_H 1 -#define DESC_NONE 0x00000000 -#define DESC_LVLANIM 0x00000001 - /** \brief Caches images. Caches images supported by SDL_image according to their name Modified: trunk/src/lost_penguins.cpp =================================================================== --- trunk/src/lost_penguins.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/lost_penguins.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -98,7 +98,9 @@ config.audio_format = MIX_DEFAULT_FORMAT; config.audio_channels = 2; config.datadir="data/"; + config.anim_file="animation_data.anim"; config.map="map1.cfg"; + config.lvlscale=4; //key bindings config.keybind[KEY_LEFT] = SDLK_LEFT; @@ -133,6 +135,9 @@ if (option[0]=='#') continue; if (option=="datadir") { config.datadir=arg1; + if (config.datadir.substr(config.datadir.size() - 1, 1)!="/") config.datadir+="/"; + } else if (option=="animfile") { + config.anim_file=arg1; } else if (option=="width") { config.width=atoi(arg1.c_str()); } else if (option=="height") { @@ -165,6 +170,13 @@ config.map=argv[i+1]; config.map+=".cfg"; i++; + } else if ( strcmp(argv[i], "-datadir") == 0 ) { + config.datadir=argv[i+1]; + if (config.datadir.substr(config.datadir.size() - 1, 1)!="/") config.datadir+="/"; + i++; + } else if ( strcmp(argv[i], "-animfile") == 0 ) { + config.anim_file=argv[i+1]; + i++; } else if ( strcmp(argv[i], "--help") == 0 || strcmp(argv[i], "-h") == 0) { usage(); } else usage(); @@ -173,6 +185,8 @@ void usage() { cout << "Usage: lost_penguins [OPTIONS]\n\n"; + cout << " -datadir Changes the data directory. Default: data/\n"; + cout << " -animfile Changes the animation file name. Default: animation_data.anim\n"; cout << " -w, -width Changes resolution (width) of game. Default: 640\n"; cout << " -h, -height Changes resolution (height) of game. Default: 480\n"; cout << " -fs, -full Enable fullscreen. Default: disabled\n"; Modified: trunk/src/objects/Makefile =================================================================== --- trunk/src/objects/Makefile 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/objects/Makefile 2005-09-04 00:13:18 UTC (rev 143) @@ -30,6 +30,7 @@ distclean: clean rm -f *~ rm -f Makefile.dep + rm -f Makefile.dep.bak depend: touch Makefile.dep Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/objects/baleog.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -12,7 +12,7 @@ Player(imagename,xcord,ycord,pname) { im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),1000,8); + im_run_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),1000,8); im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8); im_fall_left=im_left; im_fall_right=im_right; Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/objects/erik.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -15,6 +15,7 @@ jump(V_JUMP), jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); +/* im_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); im_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); im_run_right=im_right; @@ -25,6 +26,19 @@ im_krit_right=im_right; im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); +*/ + im_left=loadAnimation("eric_idle_left",config.lvlscale,1000); + im_right=loadAnimation("eric_idle_right",config.lvlscale,1000); + im_run_left=loadAnimation("eric_run_left",config.lvlscale,1000); + im_run_right=loadAnimation("eric_run_right",config.lvlscale,1000); + im_fall_left=loadAnimation("eric_fall_left",config.lvlscale,1000); + im_fall_right=loadAnimation("eric_fall_right",config.lvlscale,1000); + im_krit_left=loadAnimation("eric_fall_fast_left",config.lvlscale,1000); + im_krit_right=loadAnimation("eric_fall_fast_right",config.lvlscale,1000); + im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); + im_die_left=loadAnimation("eric_idle_left",config.lvlscale,1000); + im_die_right=loadAnimation("eric_idle_left",config.lvlscale,1000); au_jump=scenario->sndcache->loadWAV("rboots.wav"); au_hit=scenario->sndcache->loadWAV("erikhit.wav"); au_run=NULL; Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/objects/olaf.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -33,7 +33,8 @@ im_run_shield_left=im_shield_left; im_fall_shield_left=im_shield_left; im_fall_shield_right=im_shield_right; - im_die=loadAnimation(scenario->imgcache->loadImage(60,"kuru.bmp"),2000,12,0,ATYPE_ONCE_END); + im_die_left=loadAnimation(scenario->imgcache->loadImage(60,"kuru.bmp"),2000,12,0,ATYPE_ONCE_END); + im_die_right=im_die_left; au_small=scenario->sndcache->loadWAV("blob.wav"); au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/objects_common.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -59,6 +59,66 @@ return ok; } +Animation* Object::loadAnimation(string anim_name, + double scale_factor, + Uint32 aduration, + Uint16 aanimation_type, + BasePointType abp_type, + AllignType aallign_type, + Sint16 ashift_x, + Sint16 ashift_y) { + + /* Parse animation data file */ + ifstream file; + string tmpline; + string loadfile=config.datadir+config.anim_file; + + file.open(loadfile.c_str()); + if (!file) { + cout << "Failed to open the animation data file: " << loadfile << " => Couldn't load " << anim_name << " animation!\n" << endl; + return NULL; + } else { + string arg1,arg2,arg3,arg4,arg5,arg6; + string tmp_anim_name=""; + string imagename=""; + Uint16 astart_pos=0; + Uint16 aframes=1; + + Uint16 description_type=DESC_NONE; + + while (getline(file,tmpline)) { + arg1=arg2=arg3=arg4=arg5=arg6=""; + std::istringstream tmpstream(tmpline); + tmpstream >> arg1 >> arg2 >> arg3 >> arg4 >> arg5 >> arg6; + + if (arg1 == "DESCRIPTION") { + description_type=DESC_NONE; + } else if (arg1 == "ANIMATION") { + if (arg2 == "LVLANIM") { + description_type=DESC_ANIM_LVLANIM; + } else { + description_type=DESC_NONE; + } + } + + if (description_type==DESC_ANIM_LVLANIM) { + if (arg1.empty() || arg2.empty() || arg3.empty() || arg4.empty()) { + } else { + tmp_anim_name=arg1; + imagename=arg2; + astart_pos=(Uint16)atoi(arg3.c_str()); + aframes=(Uint16)atoi(arg4.c_str()); + + if (anim_name==tmp_anim_name) { + return loadAnimation(imgcache->loadImage(imagename,scale_factor),aduration,aframes,aanimation_type,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); + } + } + } + } + } + return NULL; +} + Animation* Object::loadAnimation(const Image& abase_image, Uint32 aduration, Uint16 aframes, Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/objects_common.h 2005-09-04 00:13:18 UTC (rev 143) @@ -105,6 +105,15 @@ delete this; } //@} + /// Load an animation bound onto this object from an animation data file + Animation* loadAnimation(string anim_name, + double scale_factor=1, + Uint32 aduration=0, + Uint16 aanimation_type=ATYPE_LOOP, + BasePointType abp_type=BP_MD, + AllignType aallign_type=AT_MD, + Sint16 ashift_x=0, + Sint16 ashift_y=0); /// Load an animation bound onto this object Animation* loadAnimation(const Image& abase_image, Uint32 aduration=0, Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-03 17:18:56 UTC (rev 142) +++ trunk/src/players_common.cpp 2005-09-04 00:13:18 UTC (rev 143) @@ -279,18 +279,18 @@ Character* deadplr=scenario->pool->addCharacter(new DeadPlayer("dead_player.bmp",pos.x,pos.y)); switch(weap.getSubType()) { case WS_FIRE: { - if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,im_die)); + if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? im_die_left : im_die_right)); else sfxeng->playWAV(au_fire); break; } case WS_WATER: { - if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_drown,im_die)); + if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_drown,(state&STATE_LEFT) ? im_die_left : im_die_right)); else sfxeng->playWAV(au_drown); break; } //WS_NORMAL, WS_ELECTRIC, WS_FIRE, WS_PRESSURE default: { - if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_die,im_die)); + if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_die,(state&STATE_LEFT) ? im_die_left : im_die_right)); else sfxeng->playWAV(au_die); } } From DONOTREPLY at icculus.org Sun Sep 4 17:21:34 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 4 Sep 2005 17:21:34 -0400 Subject: r144 - in trunk: src src/objects tools Message-ID: <20050904212134.3508.qmail@icculus.org> Author: jonas Date: 2005-09-04 17:21:33 -0400 (Sun, 04 Sep 2005) New Revision: 144 Modified: trunk/src/animation.cpp trunk/src/animation.h trunk/src/characters_common.cpp trunk/src/characters_common.h trunk/src/common.cpp trunk/src/common.h trunk/src/events.cpp trunk/src/imgcache.cpp trunk/src/lost_penguins.cpp trunk/src/monsters_common.cpp trunk/src/monsters_common.h trunk/src/objectpools.cpp trunk/src/objects/baleog.cpp trunk/src/objects/baleog.h trunk/src/objects/erik.cpp trunk/src/objects/fang.cpp trunk/src/objects/fang.h trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/scorch.cpp trunk/src/objects/zombie.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp trunk/src/players_common.h trunk/src/scenario.cpp trunk/tools/lvl2magick.c Log: o Forgot this in an old commit: lvl2magick now creates an animation file, basically based on the LVLDATA file. The animation files can be joined together as one single file. o Animation takes fps instead of duration as a parameter. Theoretically it seems to be the more logical choice but in reality it animations always seem to be of the same duration. To get FPS from duration, use calcFPS(frames,duration). To supply the duration specify it as a negative fps value in ms. Default 0 will set duration to DATA_LVLDUR=1000; o instead of applying animation directly this is now done using setAnim() which returns true if the argument is valid. Otherwise the original animation is set. To also initialize the animation supply true as a second argument (default: false). Animations are valid if they are not NULL. o Renamed animations from im_* to anim_* o players_common.* now handles all its animation, by default all animations are NULL. As players_common also deletes all its animation, each pointer has to point to a different location or we get a double free. :( players_common now also supports basic (bad) fallbacks to more basic animations like anim_left. So one doesn't has to specify them in the corresponding objects. o Fixed the object naming scheme in Objectspool. o Added (practically) all basic animations to Erik (now we only have to support them ;). Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/animation.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -2,18 +2,18 @@ #include "animation.h" Animation::Animation(const Image& abase_image, - Uint32 aduration, Uint16 aframes, Uint16 aanimation_type, + double afps, Uint16 astart_pos, BasePointType abp_type, AllignType aallign_type, Sint16 ashift_x, Sint16 ashift_y): base_image(abase_image), - duration(aduration), frames(aframes), animation_type(aanimation_type), + fps(afps), start_pos(astart_pos), bp_type(abp_type), allign_type(aallign_type), @@ -21,6 +21,12 @@ shift_y(ashift_y), end_pos(start_pos+frames), base_pos(NULL) { + if (fps==0) { + fps=calcFPS(frames,DATA_LVLDUR); + } else if (fps<0) { + fps=calcFPS(frames,(Uint32)(-fps)); + } + duration=(Uint32)(frames*1000.0/fps+0.5); checkAnim(); } Animation::~Animation() { } Modified: trunk/src/animation.h =================================================================== --- trunk/src/animation.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/animation.h 2005-09-04 21:21:33 UTC (rev 144) @@ -8,8 +8,8 @@ public: /// \brief Initialize the animation /// \param abase_image Base image used for the animation - /// \param aduration Duration of the animation /// \param aframes Number of frames + /// \param afps FPS of the animation, if (afps < 0) it is considered to be the duration in ms, if (afps==0) a default duration DATA_LVLDUR is taken /// \param aanimation_type Animation type /// \param astart_pos Start position from the frame array of the base_image /// \param abp_type Base point type @@ -19,9 +19,9 @@ /// /// To load one still image simply use: Animation(imgcache->loadImage(1,"image_name.png")) Animation(const Image& abase_image, - Uint32 aduration=0, Uint16 aframes=1, Uint16 aanimation_type=ATYPE_LOOP, + double afps=0, Uint16 astart_pos=0, BasePointType abp_type=BP_MD, AllignType aallign_type=AT_MD, @@ -75,8 +75,6 @@ private: /// Base image for the animation (big) Image base_image; - /// Duration of the animation in ms - Uint32 duration; /// Number of frames Uint16 frames; /// Animation type: ATYPE_ONCE (play once), ATYPE_ONCE_END (play once and stop at end), @@ -84,6 +82,8 @@ /// reverse direction when finnished). The appended _REV means that the animation is /// started at the end and played backwards. Uint16 animation_type; + /// FPS of the animation + double fps; /// Start position from the frame array of the base_image Uint16 start_pos; ///\brief The base point of the animation @@ -111,6 +111,8 @@ //@} /* calculated or given values/functions */ + /// Duration of the animation in ms + Uint32 duration; /// End position from the frame array of the base_image Uint16 end_pos; /// True if the animation consist of one still image (frames=1,still=true) Modified: trunk/src/characters_common.cpp =================================================================== --- trunk/src/characters_common.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/characters_common.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -17,8 +17,6 @@ speed(0), gravity(900), Dgrav(0), - im_die_left(NULL), - im_die_right(NULL), dense_types(NOTHING), enemy_types(NOTHING), weapon(Weapon(0)) { @@ -66,7 +64,7 @@ } void Character::updateAnimState() { - animation=im_orig; + setAnim(anim_orig); } void Character::idle(Uint16) { Modified: trunk/src/characters_common.h =================================================================== --- trunk/src/characters_common.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/characters_common.h 2005-09-04 21:21:33 UTC (rev 144) @@ -173,9 +173,6 @@ Sint16 gravity; //temporary attributes Sint16 Dgrav; - //Die animation - Animation* im_die_left; - Animation* im_die_right; //Entered objects std::set enter; //Touched objects Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/common.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -37,6 +37,10 @@ else return a=min(0,a-b); } +double calcFPS(Uint16 frames, Uint32 duration) { + return frames*1000.0/duration; +} + void setGameMode(Uint8 newmode) { game_mode=newmode; if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) { Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/common.h 2005-09-04 21:21:33 UTC (rev 144) @@ -48,6 +48,10 @@ typedef std::set::iterator player_iterator; typedef std::set::iterator monster_iterator; +//Data +#define DATA_LVLFPS 6 +#define DATA_LVLDUR 1000 + //General definitions #define NOTHING 0x00000000 #define ALL 0xFFFFFFFF @@ -203,6 +207,8 @@ string itos(int); /// Helper function boost that increases/decreases the absolute value int boost(int,int); +/// Calculate the fps as frames*1000/duration_in_ms +double calcFPS(Uint16 frames, Uint32 duration); /// Set game mode void setGameMode(Uint8); @@ -216,6 +222,7 @@ Menu* closeMenu(); /// Close all menus (menu=NULL) void closeMenus(); + //@} //global variables Modified: trunk/src/events.cpp =================================================================== --- trunk/src/events.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/events.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -69,7 +69,7 @@ } void AnimEvent::start() { sfxeng->playWAV(sound); - if (anim) owner->setAnim(anim); + if (anim) owner->setAnim(anim,true); Event::start(); } void AnimEvent::end() { @@ -108,7 +108,7 @@ } void CAnimEvent::start() { sfxeng->playWAV(sound); - if (anim) charowner->setAnim(anim); + if (anim) charowner->setAnim(anim,true); CEvent::start(); } void CAnimEvent::end() { Modified: trunk/src/imgcache.cpp =================================================================== --- trunk/src/imgcache.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/imgcache.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -15,11 +15,15 @@ } } +/* + We add +0.5 to cleanly round the values + Alternative: We trunc the w,h values and ceil the x,y values to make the rectangle as small as possible +*/ SDL_Rect& ImageCache::scaleRectangle(SDL_Rect& base_rect, double scale_factor) { - base_rect.x=(Sint16)(base_rect.x*sqrt(scale_factor)); - base_rect.y=(Sint16)(base_rect.y*sqrt(scale_factor)); - base_rect.w=(Uint16)(base_rect.w*sqrt(scale_factor)); - base_rect.h=(Uint16)(base_rect.h*sqrt(scale_factor)); + base_rect.x=(Sint16)(base_rect.x*sqrt(scale_factor)+0.5); + base_rect.y=(Sint16)(base_rect.y*sqrt(scale_factor)+0.5); + base_rect.w=(Uint16)(base_rect.w*sqrt(scale_factor)+0.5); + base_rect.h=(Uint16)(base_rect.h*sqrt(scale_factor)+0.5); return base_rect; } @@ -114,7 +118,9 @@ // Nice return statement, isn't it ;-))) return (*(imgcache.insert(make_pair(make_pair(imagename,scale_factor),return_image))).first).second; // Return the existing Image in cache... - } else return (*imgit).second; + } else { + return (*imgit).second; + } } Image& ImageCache::loadImage(string imagename, double scale_factor, string image_desc_file) { @@ -133,8 +139,6 @@ if (!file) { cout << "Failed to open the image description file: " << loadfile << " not found!" << endl; } else { - cout << "Loading image description: " << loadfile << endl; - string arg1,arg2,arg3,arg4,arg5,arg6; Uint16 description_type=DESC_NONE; Modified: trunk/src/lost_penguins.cpp =================================================================== --- trunk/src/lost_penguins.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/lost_penguins.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -100,7 +100,7 @@ config.datadir="data/"; config.anim_file="animation_data.anim"; config.map="map1.cfg"; - config.lvlscale=4; + config.lvlscale=2; //key bindings config.keybind[KEY_LEFT] = SDLK_LEFT; Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/monsters_common.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -21,8 +21,8 @@ otype|=OTYPE_MONSTER; enemy_types|=OTYPE_PLAYER; dense_types|=OTYPE_PLAYER; - im_left=animation; - im_right=animation; + anim_left=animation; + anim_right=animation; au_hit=scenario->sndcache->loadWAV("monhit.wav"); } @@ -75,9 +75,9 @@ void Monster::updateAnimState() { if (state&STATE_LEFT) { - animation=im_left; + setAnim(anim_left); } else { - animation=im_right; + setAnim(anim_right); } } Modified: trunk/src/monsters_common.h =================================================================== --- trunk/src/monsters_common.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/monsters_common.h 2005-09-04 21:21:33 UTC (rev 144) @@ -36,8 +36,8 @@ std::set targets; virtual Hit move(Uint16 dt, bool check=false); //common animations - Animation* im_left; - Animation* im_right; + Animation* anim_left; + Animation* anim_right; Mix_Chunk* au_hit; Sint16 Dai,Dattack; }; Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objectpools.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -45,21 +45,22 @@ Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, string& arg1, string& arg2, const string& arg3) { //Set names... - if (arg1.empty()) arg1="0"; - if (arg2.empty()) arg2="0"; string name=getNextObjectName(obj); - if (arg1!="0") { + if (!arg1.empty()) { //one additional parameter - if (name=="Trigger" || name=="Door" || name=="Bomb" || name=="TriggeredBomb" || name=="Plant" || name=="Geyser" || name=="Wind" || name=="Spike") { - if (arg2!="0") name=arg2; + if (obj=="Trigger" || obj=="Door" || obj=="Bomb" || obj=="TriggeredBomb" || obj=="Plant" || obj=="Geyser" || obj=="Wind" || obj=="Spike") { + if (!arg2.empty()) name=arg2; //two additional parameter - } else if (name=="Teleporter") { + } else if (obj=="Teleporter") { if (!arg3.empty()) name=arg3; //no additional parameters } else { name=arg1; } } + if (arg1.empty()) arg1="0"; + if (arg2.empty()) arg2="0"; + //normal objects if (obj=="Wall") return (addObject(new Wall(image,x,y,name))); else if (obj=="Exit") return (addObject(new Exit(image,x,y,name))); Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/baleog.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -10,34 +10,24 @@ Baleog::Baleog(string imagename, Sint16 xcord, Sint16 ycord, string pname): Player(imagename,xcord,ycord,pname) { - im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - im_run_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),1000,8); - im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8); - im_fall_left=im_left; - im_fall_right=im_right; - im_krit_left=im_left; - im_krit_right=im_right; - im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); + anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); + anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); weapon=Weapon(-1,W_STRIKE); - im_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),1000,8,ATYPE_ONCE_END); - im_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),1000,8,ATYPE_ONCE_END); + anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,ATYPE_ONCE_END); + anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,ATYPE_ONCE_END); au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } Baleog::~Baleog() { - delete im_left; - delete im_right; - delete im_run_left; - delete im_run_right; - delete im_land_left; - delete im_land_right; - delete im_sword_left; - delete im_sword_right; + delete anim_sword_left; + delete anim_sword_right; } //Baleog1: Sword attack void Baleog::in_sp1() { - setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? im_sword_left : im_sword_right)); + setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_sword_left : anim_sword_right)); } Modified: trunk/src/objects/baleog.h =================================================================== --- trunk/src/objects/baleog.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/baleog.h 2005-09-04 21:21:33 UTC (rev 144) @@ -11,6 +11,6 @@ virtual void in_sp1(); private: Mix_Chunk* au_sword; - Animation* im_sword_left; - Animation* im_sword_right; + Animation* anim_sword_left; + Animation* anim_sword_right; }; Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/erik.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -16,38 +16,52 @@ jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); /* - im_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); - im_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); - im_run_right=im_right; - im_run_left=im_left; - im_fall_left=im_left; - im_fall_right=im_right; - im_krit_left=im_left; - im_krit_right=im_right; - im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); + anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); + anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); + anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); */ - im_left=loadAnimation("eric_idle_left",config.lvlscale,1000); - im_right=loadAnimation("eric_idle_right",config.lvlscale,1000); - im_run_left=loadAnimation("eric_run_left",config.lvlscale,1000); - im_run_right=loadAnimation("eric_run_right",config.lvlscale,1000); - im_fall_left=loadAnimation("eric_fall_left",config.lvlscale,1000); - im_fall_right=loadAnimation("eric_fall_right",config.lvlscale,1000); - im_krit_left=loadAnimation("eric_fall_fast_left",config.lvlscale,1000); - im_krit_right=loadAnimation("eric_fall_fast_right",config.lvlscale,1000); - im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_die_left=loadAnimation("eric_idle_left",config.lvlscale,1000); - im_die_right=loadAnimation("eric_idle_left",config.lvlscale,1000); + anim_left=loadAnimation("erik_idle_left",config.lvlscale); + anim_right=loadAnimation("erik_idle_right",config.lvlscale); + anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale); + anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale); + anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale); + anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale); + anim_push_left=loadAnimation("erik_push_left",config.lvlscale); + anim_push_right=loadAnimation("erik_push_right",config.lvlscale); + anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); + anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale); + anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale); + anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale); + anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale); + anim_land_left=loadAnimation("erik_land_left",config.lvlscale,ATYPE_ONCE_END); + anim_land_right=loadAnimation("erik_land_right",config.lvlscale,ATYPE_ONCE_END); + anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale); + anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale); + anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,ATYPE_ONCE_END); + anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,ATYPE_ONCE_END); + anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,ATYPE_ONCE_END); + anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,ATYPE_ONCE_END); + anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,ATYPE_ONCE_END); + anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,ATYPE_ONCE_END); + anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,ATYPE_ONCE_END); + anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,ATYPE_ONCE_END); + anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,ATYPE_ONCE_END); + anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,ATYPE_ONCE_END); + anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,ATYPE_ONCE_END); + anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,ATYPE_ONCE_END); + anim_bar=loadAnimation("bar_erik",config.lvlscale,ATYPE_ONCE); + + /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ au_jump=scenario->sndcache->loadWAV("rboots.wav"); au_hit=scenario->sndcache->loadWAV("erikhit.wav"); au_run=NULL; } Erik::~Erik() { - delete im_left; - delete im_right; - delete im_land_left; - delete im_land_right; } void Erik::idle(Uint16 dt) { Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/fang.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -12,31 +12,21 @@ Player(imagename,xcord,ycord,pname), jump(V_JUMP) { weapon=Weapon(-1,W_STRIKE); - im_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),1000,4); - im_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),1000,4); - im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),1000,8); - im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),1000,8); - im_fall_left=im_left; - im_fall_right=im_right; - im_krit_left=im_left; - im_krit_right=im_right; - im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),1000,8,ATYPE_ONCE_END); - im_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),1000,8,ATYPE_ONCE_END); + anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); + anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); + anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); + anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8); + anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav"); au_jump=scenario->sndcache->loadWAV("fangjump.wav"); } Fang::~Fang() { - delete im_left; - delete im_right; - delete im_run_left; - delete im_run_right; - delete im_land_left; - delete im_land_right; - delete im_claw_left; - delete im_claw_right; + delete anim_claw_left; + delete anim_claw_right; } void Fang::in_left(Uint16 dt) { @@ -94,7 +84,7 @@ } void Fang::in_sp2() { - setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? im_claw_left : im_claw_right)); + setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? anim_claw_left : anim_claw_right)); } void Fang::crash(Uint16 dir) { Modified: trunk/src/objects/fang.h =================================================================== --- trunk/src/objects/fang.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/fang.h 2005-09-04 21:21:33 UTC (rev 144) @@ -34,8 +34,8 @@ virtual void clearStates(bool reset=false); private: virtual void crash(Uint16 dir=DIR_DOWN); - Animation* im_claw_left; - Animation* im_claw_right; + Animation* anim_claw_left; + Animation* anim_claw_right; Mix_Chunk* au_jump; Mix_Chunk* au_claw; Sint16 jump; Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/olaf.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -12,73 +12,98 @@ Olaf::Olaf(string imagename, Sint16 xcord, Sint16 ycord, string pname): Player(imagename,xcord,ycord,pname), fart(V_FART) { - im_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); - im_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); - im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),1000,8); - im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),1000,8); - im_fall_left=im_left; - im_fall_right=im_right; - im_krit_left=im_left; - im_krit_right=im_right; - im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); + anim_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); + anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); + anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8); + anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,ATYPE_ONCE_END,25); - im_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),0,1); - im_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),0,1); - im_run_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),500,7); - im_run_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),500,7); - im_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); - im_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); - im_run_shield_right=im_shield_right; - im_run_shield_left=im_shield_left; - im_fall_shield_left=im_shield_left; - im_fall_shield_right=im_shield_right; - im_die_left=loadAnimation(scenario->imgcache->loadImage(60,"kuru.bmp"),2000,12,0,ATYPE_ONCE_END); - im_die_right=im_die_left; + anim_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1); + anim_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),1); + anim_walk_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),7,ATYPE_LOOP,3.5); + anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,ATYPE_LOOP,3.5); + anim_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); + anim_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); + anim_walk_shield_left=NULL; + anim_walk_shield_right=NULL; + anim_fall_shield_left=NULL; + anim_fall_shield_right=NULL; au_small=scenario->sndcache->loadWAV("blob.wav"); au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); au_hit=scenario->sndcache->loadWAV("fathit.wav"); } Olaf::~Olaf() { - delete im_left; - delete im_right; - delete im_run_left; - delete im_run_right; - delete im_land_left; - delete im_land_right; - delete im_small_left; - delete im_small_right; - delete im_run_small_left; - delete im_run_small_right; - delete im_shield_right; - delete im_shield_left; + delete anim_small_left; + delete anim_small_right; + delete anim_walk_small_left; + delete anim_walk_small_right; + delete anim_walk_shield_left; + delete anim_walk_shield_right; + delete anim_shield_left; + delete anim_shield_right; + delete anim_fall_shield_left; + delete anim_fall_shield_right; } void Olaf::updateAnimState() { if (state&STATE_SMALL) { if (state&STATE_LEFT) { - if (state&STATE_MLEFT) animation=im_run_small_left; - else animation=im_small_left; + if (!setAnim(anim_walk_small_left)) { + if (!setAnim(anim_small_left)) setAnim(anim_left); + } } else { - if (state&STATE_MRIGHT) animation=im_run_small_right; - else animation=im_small_right; + if (!setAnim(anim_walk_small_right)) { + if (!setAnim(anim_small_right)) setAnim(anim_right); + } } } else if (state&STATE_SHIELD) { otype|=OTYPE_DENSE_D; if (state&STATE_LEFT) { if (state&STATE_FALL) { - animation=im_fall_shield_left; + if (state&STATE_MLEFT) { + if (!setAnim(anim_fall_shield_left)) { + if (!setAnim(anim_shield_left)) { + if (!setAnim(anim_fall_left)) setAnim(anim_left); + } + } + } else if (!setAnim(anim_fall_shield_left)) { + if (!setAnim(anim_fall_left)) setAnim(anim_left); + } } else { - if (state&STATE_MLEFT) animation=im_run_shield_left; - else animation=im_shield_left; + if (state&STATE_MLEFT) { + if (!setAnim(anim_walk_shield_left)) { + if (!setAnim(anim_shield_left)) { + if (!setAnim(anim_walk_left)) setAnim(anim_left); + } + } + } else { + if (!setAnim(anim_shield_left)) setAnim(anim_left); + } } } else { if (state&STATE_FALL) { - animation=im_fall_shield_right; + if (state&STATE_MRIGHT) { + if (!setAnim(anim_fall_shield_right)) { + if (!setAnim(anim_shield_right)) { + if (!setAnim(anim_fall_right)) setAnim(anim_right); + } + } + } else if (!setAnim(anim_fall_shield_right)) { + if (!setAnim(anim_fall_right)) setAnim(anim_right); + } } else { - if (state&STATE_MRIGHT) animation=im_run_shield_right; - else animation=im_shield_right; + if (state&STATE_MRIGHT) { + if (!setAnim(anim_walk_shield_right)) { + if (!setAnim(anim_shield_right)) { + if (!setAnim(anim_walk_right)) setAnim(anim_right); + } + } + } else { + if (!setAnim(anim_shield_right)) setAnim(anim_right); + } } } } else { @@ -106,9 +131,9 @@ Animation* tmpanim; SDL_Rect tmppos=pos; - if (small) tmpanim=im_small_left; + if (small) tmpanim=anim_small_left; //Assume both images have the same dimension - else tmpanim=im_orig; + else tmpanim=anim_orig; //IDEA: left/right edge instead of bottom? tmppos.x+=(Sint16)((tmppos.w-tmpanim->getFrameDim().w)/2); tmppos.y+=tmppos.h-tmpanim->getFrameDim().h; Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/olaf.h 2005-09-04 21:21:33 UTC (rev 144) @@ -41,16 +41,16 @@ /// \return True if successfull inline bool trySmall(bool small); //@{ - Animation* im_small_left; - Animation* im_small_right; - Animation* im_run_small_left; - Animation* im_run_small_right; - Animation* im_shield_left; - Animation* im_shield_right; - Animation* im_run_shield_left; - Animation* im_run_shield_right; - Animation* im_fall_shield_left; - Animation* im_fall_shield_right; + Animation* anim_small_left; + Animation* anim_small_right; + Animation* anim_walk_small_left; + Animation* anim_walk_small_right; + Animation* anim_shield_left; + Animation* anim_shield_right; + Animation* anim_walk_shield_left; + Animation* anim_walk_shield_right; + Animation* anim_fall_shield_left; + Animation* anim_fall_shield_right; //@} //@{ Mix_Chunk* au_small; Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/scorch.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -12,27 +12,17 @@ Player(imagename,xcord,ycord,pname), left_wings(SCORCH_MAX_WINGS), wing(V_FLY) { - im_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - im_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - im_run_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),1000,8); - im_run_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),1000,8); - im_fall_left=im_left; - im_fall_right=im_right; - im_krit_left=im_left; - im_krit_right=im_right; - im_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),T_IRR,1,ATYPE_ONCE_END); - im_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),T_IRR,1,ATYPE_ONCE_END); + anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); + anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); au_tired=scenario->sndcache->loadWAV("flwings.wav"); au_hit=scenario->sndcache->loadWAV("draghit.wav"); } Scorch::~Scorch() { - delete im_left; - delete im_right; - delete im_run_left; - delete im_run_right; - delete im_land_left; - delete im_land_right; } void Scorch::idle(Uint16 dt) { Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects/zombie.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -15,14 +15,12 @@ au_attack(scenario->sndcache->loadWAV("clang.wav")), T_Attack_Bite(1500) { maxspeedx=80; - im_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),1000,2); - im_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),1000,2); + anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,ATYPE_LOOP,2); + anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,ATYPE_LOOP,2); weapon=Weapon(-1,W_STRIKE); } Zombie::~Zombie() { - delete im_left; - delete im_right; } void Zombie::idle(Uint16 dt) { Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects_common.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -10,11 +10,11 @@ Object::Object(string imagename, Sint16 xcord, Sint16 ycord, string oname): state(NOTHING), event(NULL), - im_orig(loadAnimation(scenario->imgcache->loadImage(1,imagename))), otype(NOTHING), name(oname), delete_flag(false) { - animation=im_orig; + anim_orig=loadAnimation(scenario->imgcache->loadImage(1,imagename)); + animation=anim_orig; pos=animation->getFrameDim(); pos.x=xcord; pos.y=ycord; @@ -61,8 +61,8 @@ Animation* Object::loadAnimation(string anim_name, double scale_factor, - Uint32 aduration, Uint16 aanimation_type, + double afps, BasePointType abp_type, AllignType aallign_type, Sint16 ashift_x, @@ -110,7 +110,7 @@ aframes=(Uint16)atoi(arg4.c_str()); if (anim_name==tmp_anim_name) { - return loadAnimation(imgcache->loadImage(imagename,scale_factor),aduration,aframes,aanimation_type,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); + return loadAnimation(imgcache->loadImage(imagename,scale_factor),aframes,aanimation_type,afps,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); } } } @@ -120,15 +120,15 @@ } Animation* Object::loadAnimation(const Image& abase_image, - Uint32 aduration, Uint16 aframes, Uint16 aanimation_type, + double afps, Uint16 astart_pos, BasePointType abp_type, AllignType aallign_type, Sint16 ashift_x, Sint16 ashift_y) { - Animation* anim=new Animation(abase_image,aduration,aframes,aanimation_type,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); + Animation* anim=new Animation(abase_image,aframes,aanimation_type,afps,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); anim->setBasePos(&pos); return anim; } @@ -142,13 +142,21 @@ bool Object::updateAnim(Uint16 dt) { return (animation->updateAnim(dt)); } -void Object::setAnim(Animation* anim) { - animation=anim; - animation->setBasePos(&pos); - animation->runAnim(); +bool Object::setAnim(Animation* anim, bool start) { + if (anim) { + animation=anim; + if (start) { + animation->setBasePos(&pos); + animation->runAnim(); + } + return true; + } else { + animation=anim_orig; + return false; + } } void Object::resetAnimState() { - animation=im_orig; + setAnim(anim_orig); animation->setBasePos(&pos); animation->runAnim(); } Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/objects_common.h 2005-09-04 21:21:33 UTC (rev 144) @@ -88,7 +88,7 @@ /// and starts it right away. Should not be used with updateAnimState, /// set ESTATE_ANIM to deactivate an updateAnimState. This is usually /// controlled by an AnimationEvent - void setAnim(Animation* anim); + bool setAnim(Animation* anim, bool start=false); /// Sets the animation back to the default one. virtual void resetAnimState(); bool isRunning() const; @@ -108,17 +108,17 @@ /// Load an animation bound onto this object from an animation data file Animation* loadAnimation(string anim_name, double scale_factor=1, - Uint32 aduration=0, Uint16 aanimation_type=ATYPE_LOOP, + double afps=DATA_LVLFPS, BasePointType abp_type=BP_MD, AllignType aallign_type=AT_MD, Sint16 ashift_x=0, Sint16 ashift_y=0); /// Load an animation bound onto this object Animation* loadAnimation(const Image& abase_image, - Uint32 aduration=0, Uint16 aframes=1, Uint16 aanimation_type=ATYPE_LOOP, + double afps=DATA_LVLFPS, Uint16 astart_pos=0, BasePointType abp_type=BP_MD, AllignType aallign_type=AT_MD, @@ -183,7 +183,7 @@ protected: Uint32 state; Event* event; - Animation* im_orig; + Animation* anim_orig; Animation* animation; ///\todo Document this! /// Upper left logical position of the object (used for decisions) Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/players_common.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -26,16 +26,25 @@ state=STATE_FALL; otype|=OTYPE_PLAYER; enemy_types|=OTYPE_MONSTER; - im_left=animation; - im_right=animation; - im_run_left=animation; - im_run_right=animation; - im_fall_left=animation; - im_fall_right=animation; - im_krit_left=animation; - im_krit_right=animation; - im_land_left=animation; - im_land_right=animation; + anim_left=anim_right=NULL; + anim_rock_left=anim_rock_right=NULL; + anim_walk_left=anim_walk_right=NULL; + anim_push_left=anim_push_right=NULL; + anim_fall_left=anim_fall_right=NULL; + anim_fall_fast_left=anim_fall_fast_right=NULL; + anim_land_left=anim_land_right=NULL; + anim_crash_left=anim_crash_right=NULL; + anim_rope_left=anim_rope_right=NULL; + anim_teleport_left=anim_teleport_right=NULL; + anim_die_crash_left=anim_die_crash_right=NULL; + anim_die_burn_left=anim_die_burn_right=NULL; + anim_die_bones_left=anim_die_bones_right=NULL; + anim_die_elec_left=anim_die_elec_right=NULL; + anim_die_spike_left=anim_die_spike_right=NULL; + anim_die_water_left=anim_die_water_right=NULL; + anim_fall_middle=NULL; + anim_climb=NULL; + anim_bar=NULL; au_land=scenario->sndcache->loadWAV("dizzy.wav"); au_act=scenario->sndcache->loadWAV("button.wav"); au_useerror=scenario->sndcache->loadWAV("useerror.wav"); @@ -49,6 +58,41 @@ } Player::~Player() { + delete anim_left; + delete anim_right; + delete anim_rock_left; + delete anim_rock_right; + delete anim_walk_left; + delete anim_walk_right; + delete anim_push_left; + delete anim_push_right; + delete anim_fall_left; + delete anim_fall_right; + delete anim_fall_fast_left; + delete anim_fall_fast_right; + delete anim_land_left; + delete anim_land_right; + delete anim_crash_left; + delete anim_crash_right; + delete anim_rope_left; + delete anim_rope_right; + delete anim_teleport_left; + delete anim_teleport_right; + delete anim_die_crash_left; + delete anim_die_crash_right; + delete anim_die_burn_left; + delete anim_die_burn_right; + delete anim_die_bones_left; + delete anim_die_bones_right; + delete anim_die_elec_left; + delete anim_die_elec_right; + delete anim_die_spike_left; + delete anim_die_spike_right; + delete anim_die_water_left; + delete anim_die_water_right; + delete anim_fall_middle; + delete anim_climb; + delete anim_bar; for (Uint8 i=0; igetBaseFrame()); + if (anim_bar) return (anim_bar->getBaseFrame()); + else if (anim_right) return (anim_right->getBaseFrame()); + else return (anim_orig->getBaseFrame()); } void Player::addEnter(std::set& aset) { @@ -150,26 +196,38 @@ if (state&STATE_LEFT) { if (state&STATE_FALL) { if (speed>V_KRIT) { - animation=im_krit_left; + if (!setAnim(anim_fall_fast_left)) { + if (!setAnim(anim_fall_left)) setAnim(anim_left); + } + } else if (state&STATE_MLEFT || speed < 0) { + if (!setAnim(anim_fall_left)) setAnim(anim_left); } else { - animation=im_fall_left; + if (!setAnim(anim_fall_middle)) { + if (!setAnim(anim_fall_left)) setAnim(anim_left); + } } } else if (state&STATE_MLEFT) { - animation=im_run_left; + if (!setAnim(anim_walk_left)) setAnim(anim_left); } else { - animation=im_left; + setAnim(anim_left); } } else { if (state&STATE_FALL) { if (speed>V_KRIT) { - animation=im_krit_right; + if (!setAnim(anim_fall_fast_right)) { + if (!setAnim(anim_fall_right)) setAnim(anim_right); + } + } else if (state&STATE_MRIGHT || speed < 0) { + if (!setAnim(anim_fall_right)) setAnim(anim_right); } else { - animation=im_fall_right; + if (!setAnim(anim_fall_middle)) { + if (!setAnim(anim_fall_right)) setAnim(anim_right); + } } } else if (state&STATE_MRIGHT) { - animation=im_run_right; + if (!setAnim(anim_walk_right)) setAnim(anim_right); } else { - animation=im_right; + setAnim(anim_right); } } } @@ -279,27 +337,24 @@ Character* deadplr=scenario->pool->addCharacter(new DeadPlayer("dead_player.bmp",pos.x,pos.y)); switch(weap.getSubType()) { case WS_FIRE: { - if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? im_die_left : im_die_right)); + if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? anim_die_burn_left : anim_die_burn_right)); else sfxeng->playWAV(au_fire); break; } case WS_WATER: { - if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_drown,(state&STATE_LEFT) ? im_die_left : im_die_right)); + if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_drown,(state&STATE_LEFT) ? anim_die_water_left : anim_die_water_right)); else sfxeng->playWAV(au_drown); break; } //WS_NORMAL, WS_ELECTRIC, WS_FIRE, WS_PRESSURE default: { - if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_die,(state&STATE_LEFT) ? im_die_left : im_die_right)); + if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_die,(state&STATE_LEFT) ? anim_die_bones_left : anim_die_bones_right)); else sfxeng->playWAV(au_die); } } //damaged or healed... } else { Mix_Chunk* aud_hit; - Animation* anim_hit; - if (state&STATE_LEFT) anim_hit=im_land_left; - else anim_hit=im_land_right; //TODO add more Animations switch(weap.getSubType()) { case WS_HEAL: { @@ -328,7 +383,7 @@ break; } case W_PRESSURE: { - setEvent(new CAnimEvent(this,T_IRR,0,ESTATE_BUSY,aud_hit,anim_hit)); + setEvent(new CAnimEvent(this,T_IRR,0,ESTATE_BUSY,aud_hit,(state & STATE_LEFT) ? anim_crash_left : anim_crash_right)); break; } case W_TOUCH: { Modified: trunk/src/players_common.h =================================================================== --- trunk/src/players_common.h 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/players_common.h 2005-09-04 21:21:33 UTC (rev 144) @@ -114,16 +114,41 @@ virtual void die(); virtual Hit move(Uint16 dt, bool check=false); //@{ - Animation* im_left; - Animation* im_right; - Animation* im_run_left; - Animation* im_run_right; - Animation* im_fall_left; - Animation* im_fall_right; - Animation* im_krit_left; - Animation* im_krit_right; - Animation* im_land_left; - Animation* im_land_right; + Animation* anim_left; + Animation* anim_right; + Animation* anim_rock_left; + Animation* anim_rock_right; + Animation* anim_walk_left; + Animation* anim_walk_right; + Animation* anim_push_left; + Animation* anim_push_right; + Animation* anim_fall_left; + Animation* anim_fall_right; + Animation* anim_fall_fast_left; + Animation* anim_fall_fast_right; + Animation* anim_land_left; + Animation* anim_land_right; + Animation* anim_crash_left; + Animation* anim_crash_right; + Animation* anim_rope_left; + Animation* anim_rope_right; + Animation* anim_teleport_left; + Animation* anim_teleport_right; + Animation* anim_die_crash_left; + Animation* anim_die_crash_right; + Animation* anim_die_burn_left; + Animation* anim_die_burn_right; + Animation* anim_die_bones_left; + Animation* anim_die_bones_right; + Animation* anim_die_elec_left; + Animation* anim_die_elec_right; + Animation* anim_die_spike_left; + Animation* anim_die_spike_right; + Animation* anim_die_water_left; + Animation* anim_die_water_right; + Animation* anim_fall_middle; + Animation* anim_climb; + Animation* anim_bar; //@} //@{ Mix_Chunk* au_hit; Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/src/scenario.cpp 2005-09-04 21:21:33 UTC (rev 144) @@ -109,8 +109,7 @@ image.erase(); x=0; y=0; - arg1=arg2="0"; - arg3=""; + arg1=arg2=arg3=""; std::istringstream tmpstream(mapbuf[linenum]); tmpstream >> cname >> image >> x >> y >> arg1 >> arg2 >> arg3; Modified: trunk/tools/lvl2magick.c =================================================================== --- trunk/tools/lvl2magick.c 2005-09-04 00:13:18 UTC (rev 143) +++ trunk/tools/lvl2magick.c 2005-09-04 21:21:33 UTC (rev 144) @@ -61,6 +61,8 @@ char data_file[20]; /* output geometry file */ char geom_file[20]; + /* output animation description file */ + char anim_file[20]; /* base name (used for output directory and output file names) */ char basename[20]; /* image format */ @@ -154,7 +156,7 @@ printf(" -h, --help Print this help message\n\n"); printf(" -debug Create additional debug files (default: off)\n\n"); printf(" -start_index Start index of the frame image names (default: 0)\n\n"); - printf(" -write <0-7> n=0: Just create the geometry data (no images)\n"); + printf(" -write <0-7> n=0: Just create the geometry and animation data (no images)\n"); printf(" n=1: Create one big image with all animations in it\n"); printf(" n=2: Create one image for each animation\n"); printf(" n=4: Create one image for each frame\n"); @@ -278,7 +280,8 @@ if (strcmp(config.data_file,"")==0) { snprintf(config.data_file,16,"%s.dat",config.basename); } - snprintf(config.geom_file,16,"%s.dsc",config.basename); + snprintf(config.geom_file,16,"%s.%s.dsc",config.basename,config.format); + snprintf(config.anim_file,16,"%s.%s.anim",config.basename,config.format); /* set colorkey in palette */ lvl_palette[0][red] = (unsigned char)(config.colorkey.red*255/MaxRGB); @@ -319,7 +322,7 @@ * */ unsigned int parseDataFile(char* data_file_name, LVLAnim** lvlanims) { - const char data_id[]="ANIMATION LVLANIM"; + const char data_id[]="LVLDATA"; unsigned int start_num, size, data_size=0; char name[50], line[80]; int match=0; @@ -333,7 +336,7 @@ return 0; } - if (!fgets(line,80,data_file) || strncmp(line,data_id,17)) { + if (!fgets(line,80,data_file) || strncmp(line,data_id,7)) { printf("Data file %s is invalid!!\n",data_file_name); fclose(data_file); return 0; @@ -430,7 +433,7 @@ const char entry_id[]="TRPS"; unsigned int data_size=0, tot_entries=0, num_entries=0, unknown=0; - FILE *lvl_file=NULL, *unknown_file=NULL, *geom_file=NULL; + FILE *lvl_file=NULL, *unknown_file=NULL, *geom_file=NULL, *anim_file=NULL; LVLAnim* lvlanims=NULL; unsigned int lvlanim_size=0; @@ -559,13 +562,11 @@ GetExceptionInfo(&exception); d_exception=1; GetMontageInfo(image_info,&montage_info); - montage_info.tile="1x3000"; montage_info.geometry="+0+0"; montage_info.background_color=config.bg; montage_info.matte_color=config.colorkey; montage_info.gravity=NorthWestGravity; GetMontageInfo(image_info,&montage_anim_info); - montage_anim_info.tile="3000x1"; montage_anim_info.geometry="+0+0"; montage_anim_info.background_color=config.bg; montage_anim_info.matte_color=config.colorkey; @@ -655,28 +656,47 @@ big_image=NULL; } - /* Create the geometry file */ - snprintf(buf,16,"%s.dsc",config.basename); - geom_file = fopen(buf,"w"); - geom_file = freopen(buf,"a",geom_file); + /* Create the animation data file */ + anim_file = fopen(config.anim_file,"w"); + anim_file = freopen(config.anim_file,"a",anim_file); - fprintf(geom_file,"DESCRIPTION LVLANIM\n"); + /* j is the current start frame number */ + j=0; + fprintf(anim_file,"ANIMATION LVLANIM\n\n"); + for (i=0; i Author: jonas Date: 2005-09-04 17:31:57 -0400 (Sun, 04 Sep 2005) New Revision: 145 Modified: trunk/TODO Log: updated the TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-04 21:21:33 UTC (rev 144) +++ trunk/TODO 2005-09-04 21:31:57 UTC (rev 145) @@ -37,12 +37,13 @@ object/whatever)... o Events/Animations: + o Invent more intelligent and more robust! fallback methods for animations o Allow empty animation, decouple (put more logic in) these relations: object (pos, draw?), game(time, state, handler), gfxeng(draw), animation(empty, frame, update, time, draw)?, frame, global/current (public, private) properties o Make all events quite short, ie. almost all events become animation events - o Do some column/row logics to easy the access? => NO + o IDEA: couple left and right animations somehow to reduce the code size - eg. set offsets for left, right, mleft, mright... o IDEA: just store one side and add some flipping logic to the image loading process... @@ -78,20 +79,25 @@ Progress ======== - o DONE?: fall logic including gravity!! - o DONE?: players, object, item, ai, weapons, character - o PART DONE: effect management (periodic events, permanent effects, etc) - o DONE: hitlogic - o IMPROVE!: move logic + o Monsters / AI: VERY BAD + o Game functionality (): BAD + o Object (including parameter) loading: BAD + o Move logic: BAD, BUGGED, MESS + o Events / Effects: BAD, MESS + o Objects (players, items, etc): ACCEPTABLE + o Input Handler: ACCEPTABLE, WORKS + o Collision detection: OK + o Fall logic: GOOD + o Animation / Image structure: VERY GOOD -Features/Ideas -============== +Features/Ideas/Wishlist +======================= o Make water movements possible (eric) - o Add better graphics - o improve the map editor + o improve the map editor even further o Simple AI + o In game scaling? o Finnish the vikings: - weapons: better run, jump2, fart, arm, fire @@ -103,7 +109,7 @@ - "deadly edges" - electric fence - o Monsters?: + o Monsters: - stone? - knight - dragon @@ -111,7 +117,7 @@ - fish - firetower - o Weapons?: + o Weapons: - fireballs - sword - claw @@ -120,5 +126,5 @@ - jump - arm - o Items?: + o Items: - special items From DONOTREPLY at icculus.org Mon Sep 5 08:46:22 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 5 Sep 2005 08:46:22 -0400 Subject: r146 - in trunk/src: . objects Message-ID: <20050905124622.19496.qmail@icculus.org> Author: jonas Date: 2005-09-05 08:46:21 -0400 (Mon, 05 Sep 2005) New Revision: 146 Modified: trunk/src/animation.cpp trunk/src/animation.h trunk/src/common.h trunk/src/events.cpp trunk/src/events.h trunk/src/gfxeng.h trunk/src/lost_penguins.cpp trunk/src/monsters_common.cpp trunk/src/monsters_common.h trunk/src/objects/baleog.cpp trunk/src/objects/baleog.h trunk/src/objects/erik.cpp trunk/src/objects/fang.cpp trunk/src/objects/fang.h trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/scorch.cpp trunk/src/objects/zombie.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp trunk/src/players_common.h Log: o The EmptyAnimation works as a Decorator for Animation: It has a fallback Animation** pointer. This way we don't need to do too much conditional logic in updateAnimState() as the animations should fallback automatically. If a fallback is state dependent it can be temporarly changed with setFallBack(). All NULL animations have been replaced with EmptyAnimations (with specified fallbacks). o The allign type has changed it's behaviour: It now acts like a gravity type (as in ImageMagick). The gravity is based on the initial frame which is now a member of the Animation class. Example: If the allign type is AT_LD it will try to position the base frame into the lower left corner of the base and then keep the base point fixed. As a consequence the shift parameters have been removed. o Minor fixes Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/animation.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -1,26 +1,72 @@ #include "common.h" #include "animation.h" +EmptyAnimation::EmptyAnimation(EmptyAnimation** afallback) : fallback(afallback) { } +void EmptyAnimation::setBasePos(SDL_Rect* abase_pos) { + if (fallback) (*fallback)->setBasePos(abase_pos); +} +void EmptyAnimation::unsetBasePos() { + if (fallback) (*fallback)->unsetBasePos(); +} +void EmptyAnimation::runAnim() { + if (fallback) (*fallback)->runAnim(); +} +bool EmptyAnimation::updateAnim(Uint16 dt) { + if (fallback) return (*fallback)->updateAnim(dt); + return false; +} +Frame EmptyAnimation::getFrame() const { + if (fallback) return (*fallback)->getFrame(); + else return base_frame; +} +SDL_Rect EmptyAnimation::getDrawPos() const { + if (fallback) return (*fallback)->getDrawPos(); + else return base_frame.pos; +} +SDL_Rect EmptyAnimation::getFrameDim() const { + if (fallback) return (*fallback)->getDrawPos(); + else return base_frame.pos; +} +Frame EmptyAnimation::getBaseFrame() const { + if (fallback) return (*fallback)->getBaseFrame(); + return base_frame; +} +bool EmptyAnimation::isValid() const { + if (fallback) return (*fallback)->isValid(); + else return false; +} +bool EmptyAnimation::isRunning() const { + if (fallback) return (*fallback)->isRunning(); + else return false; +} +bool EmptyAnimation::isImage() const { + if (fallback) return (*fallback)->isImage(); + else return true; +} +bool EmptyAnimation::isFixed() const { + if (fallback) return (*fallback)->isFixed(); + else return true; +} +void EmptyAnimation::setFallBack(EmptyAnimation** newfallback) { + fallback=newfallback; +} + Animation::Animation(const Image& abase_image, Uint16 aframes, + BasePointType abp_type, Uint16 aanimation_type, double afps, Uint16 astart_pos, - BasePointType abp_type, - AllignType aallign_type, - Sint16 ashift_x, - Sint16 ashift_y): + AllignType aallign_type): EmptyAnimation(NULL), base_image(abase_image), frames(aframes), + bp_type(abp_type), animation_type(aanimation_type), fps(afps), start_pos(astart_pos), - bp_type(abp_type), allign_type(aallign_type), - shift_x(ashift_x), - shift_y(ashift_y), - end_pos(start_pos+frames), - base_pos(NULL) { + base_pos(NULL), + end_pos(start_pos+frames) { if (fps==0) { fps=calcFPS(frames,DATA_LVLDUR); } else if (fps<0) { @@ -29,7 +75,7 @@ duration=(Uint32)(frames*1000.0/fps+0.5); checkAnim(); } -Animation::~Animation() { } +Animation::~Animation() { is_valid=false; } void Animation::runAnim() { if (!isValid()) { cout << "Starting an invalid animation!" << endl; @@ -134,10 +180,7 @@ } Frame Animation::getBaseFrame() const { if (!isValid()) cout << "Invalid Base Frame of an invalid animation!" << endl; - Uint16 num; - if (animation_type&ATYPE_ALL_NORMAL) num=start_pos; - else num=end_pos; - return Frame(base_image.surface,base_image.description[num]); + return base_frame; } SDL_Rect Animation::getDrawPos() const { SDL_Rect draw_pos=base_image.description[cur_frame_num]; @@ -147,85 +190,85 @@ draw_pos.x=draw_pos.y=draw_pos.w=draw_pos.h=0; return draw_pos; } - draw_pos.x=base_pos->x; - draw_pos.y=base_pos->y; /* calculate the base point */ Sint16 base_point_x=0; Sint16 base_point_y=0; - /* BP_MD is used most times */ if (bp_type==BP_MD) { - base_point_x=(Uint16)draw_pos.w/2; + base_point_x=(Uint16)(draw_pos.w/2+0.5); base_point_y=draw_pos.h; + } else if (bp_type==BP_LD) { + base_point_x=0; + base_point_y=draw_pos.h; + } else if (bp_type==BP_RD) { + base_point_x=draw_pos.w; + base_point_y=draw_pos.h; } else if (bp_type==BP_LU) { base_point_x=0; base_point_y=0; + } else if (bp_type==BP_RU) { + base_point_x=draw_pos.w; + base_point_y=0; } else if (bp_type==BP_LM) { base_point_x=0; - base_point_y=(Uint16)draw_pos.h/2; - } else if (bp_type==BP_LD) { - base_point_x=0; - base_point_y=draw_pos.h; + base_point_y=(Uint16)(draw_pos.h/2+0.5); } else if (bp_type==BP_MU) { - base_point_x=(Uint16)draw_pos.w/2; + base_point_x=(Uint16)(draw_pos.w/2+0.5); base_point_y=0; } else if (bp_type==BP_MM) { - base_point_x=(Uint16)draw_pos.w/2; - base_point_y=(Uint16)draw_pos.h/2; - } else if (bp_type==BP_RU) { - base_point_x=draw_pos.w; - base_point_y=0; + base_point_x=(Uint16)(draw_pos.w/2+0.5); + base_point_y=(Uint16)(draw_pos.h/2+0.5); } else if (bp_type==BP_RM) { base_point_x=draw_pos.w; - base_point_y=(Uint16)draw_pos.h/2; - } else if (bp_type==BP_RD) { - base_point_x=draw_pos.w; - base_point_y=draw_pos.h; + base_point_y=(Uint16)(draw_pos.h/2+0.5); } else { cout << "This shouldn't happen: Unknown base point type!" << endl; - base_point_x=(Uint16)draw_pos.w/2; + base_point_x=(Uint16)(draw_pos.w/2+0.5); base_point_y=draw_pos.h; } - /* calculate the draw_pos using the allignment type */ + /* add the shift value */ + base_point_x+=shift_x; + base_point_y+=shift_y; + + /* calculate the draw position */ + draw_pos.x=base_pos->x; + draw_pos.y=base_pos->y; + if (allign_type==AT_MD) { - draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.x+=(Uint16)(base_pos->w/2+0.5)-base_point_x; draw_pos.y+=base_pos->h-base_point_y; } else if (allign_type==AT_LU) { draw_pos.x-=base_point_x; draw_pos.y-=base_point_y; } else if (allign_type==AT_LM) { draw_pos.x-=base_point_x; - draw_pos.y+=(Uint16)base_pos->h/2-base_point_y; + draw_pos.y+=(Uint16)(base_pos->h/2+0.5)-base_point_y; } else if (allign_type==AT_LD) { draw_pos.x-=base_point_x; draw_pos.y+=base_pos->h-base_point_y; } else if (allign_type==AT_MU) { - draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.x+=(Uint16)(base_pos->w/2+0.5)-base_point_x; draw_pos.y-=base_point_y; } else if (allign_type==AT_MM) { - draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; - draw_pos.y+=(Uint16)base_pos->h/2-base_point_y; + draw_pos.x+=(Uint16)(base_pos->w/2+0.5)-base_point_x; + draw_pos.y+=(Uint16)(base_pos->h/2+0.5)-base_point_y; } else if (allign_type==AT_RU) { draw_pos.x+=base_pos->w-base_point_x; draw_pos.y-=base_point_y; } else if (allign_type==AT_RM) { draw_pos.x+=base_pos->w-base_point_x; - draw_pos.y+=(Uint16)base_pos->h/2-base_point_y; + draw_pos.y+=(Uint16)(base_pos->h/2+0.5)-base_point_y; } else if (allign_type==AT_RD) { draw_pos.x+=base_pos->w-base_point_x; draw_pos.y+=base_pos->h-base_point_y; } else { cout << "This shouldn't happen: Unknown allign type!" << endl; - draw_pos.x+=(Uint16)base_pos->w/2-base_point_x; + draw_pos.x+=(Uint16)(base_pos->w/2+0.5)-base_point_x; draw_pos.y+=base_pos->h-base_point_y; } - /* substract shift ("add" it to the bp position) */ - draw_pos.x-=shift_x; - draw_pos.y-=shift_y; - return draw_pos; } @@ -238,15 +281,92 @@ return rect; } +void Animation::setShift() { + /* calculate the base point */ + Sint16 base_point_x=0; + Sint16 base_point_y=0; + + if (bp_type==BP_MD) { + base_point_x=(Uint16)(base_frame.pos.w/2+0.5); + base_point_y=base_frame.pos.h; + } else if (bp_type==BP_LD) { + base_point_x=0; + base_point_y=base_frame.pos.h; + } else if (bp_type==BP_RD) { + base_point_x=base_frame.pos.w; + base_point_y=base_frame.pos.h; + } else if (bp_type==BP_LU) { + base_point_x=0; + base_point_y=0; + } else if (bp_type==BP_RU) { + base_point_x=base_frame.pos.w; + base_point_y=0; + } else if (bp_type==BP_LM) { + base_point_x=0; + base_point_y=(Uint16)(base_frame.pos.h/2+0.5); + } else if (bp_type==BP_MU) { + base_point_x=(Uint16)(base_frame.pos.w/2+0.5); + base_point_y=0; + } else if (bp_type==BP_MM) { + base_point_x=(Uint16)(base_frame.pos.w/2+0.5); + base_point_y=(Uint16)(base_frame.pos.h/2+0.5); + } else if (bp_type==BP_RM) { + base_point_x=base_frame.pos.w; + base_point_y=(Uint16)(base_frame.pos.h/2+0.5); + } else { + cout << "This shouldn't happen: Unknown base point type!" << endl; + base_point_x=(Uint16)(base_frame.pos.w/2+0.5); + base_point_y=base_frame.pos.h; + } + + /* calculate the shift point */ + Sint16 shift_point_x=0; + Sint16 shift_point_y=0; + + /* AT_MD is used most times */ + if (allign_type==AT_MD) { + shift_point_x=(Uint16)(base_frame.pos.w/2+0.5); + shift_point_y=base_frame.pos.h; + } else if (allign_type==AT_LU) { + shift_point_x=0; + shift_point_y=0; + } else if (allign_type==AT_LM) { + shift_point_x=0; + shift_point_y=(Uint16)(base_frame.pos.h/2+0.5); + } else if (allign_type==AT_LD) { + shift_point_x=0; + shift_point_y=base_frame.pos.h; + } else if (allign_type==AT_MU) { + shift_point_x=(Uint16)(base_frame.pos.w/2+0.5); + shift_point_y=0; + } else if (allign_type==AT_MM) { + shift_point_x=(Uint16)(base_frame.pos.w/2+0.5); + shift_point_y=(Uint16)(base_frame.pos.h/2+0.5); + } else if (allign_type==AT_RU) { + shift_point_x=base_frame.pos.w; + shift_point_y=0; + } else if (allign_type==AT_RM) { + shift_point_x=base_frame.pos.w; + shift_point_y=(Uint16)(base_frame.pos.h/2+0.5); + } else if (allign_type==AT_RD) { + shift_point_x=base_frame.pos.w; + shift_point_y=base_frame.pos.h; + } else { + cout << "This shouldn't happen: Unknown alling type!" << endl; + shift_point_x=(Uint16)(base_frame.pos.w/2+0.5); + shift_point_y=base_frame.pos.h; + } + + /* set the shift values */ + shift_x=shift_point_x-base_point_x; + shift_y=shift_point_y-base_point_y; +} + bool Animation::checkAnim() { if (base_image.surface==NULL || base_image.description.empty()) { is_valid=false; } else if (base_image.description.size()==1 || duration==0 || frames==1) { is_image=true; - cur_time=0; - forward=true; - cur_frame_num=0; - is_running=false; is_fixed=true; is_valid=true; } else if (frames==0 || start_pos>end_pos || (start_pos+frames)>base_image.description.size()) { @@ -255,6 +375,8 @@ is_valid=true; is_image=false; is_fixed=false; + } + if (is_valid) { if (animation_type&ATYPE_ALL_ONCE) is_running=false; else is_running=true; cur_time=0; @@ -265,6 +387,8 @@ forward=false; cur_frame_num=frames-1; } + base_frame=Frame(base_image.surface,base_image.description[(animation_type&ATYPE_ALL_NORMAL) ? start_pos : end_pos]); + setShift(); } return is_valid; } Modified: trunk/src/animation.h =================================================================== --- trunk/src/animation.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/animation.h 2005-09-05 12:46:21 UTC (rev 146) @@ -1,82 +1,114 @@ #ifndef DEF_ANIMATION_H #define DEF_ANIMATION_H 1 +class EmptyAnimation { + public: + EmptyAnimation(EmptyAnimation** afallback=NULL); + virtual ~EmptyAnimation() { } + virtual void setBasePos(SDL_Rect*); + virtual void unsetBasePos(); + virtual void runAnim(); + virtual bool updateAnim(Uint16); + virtual Frame getFrame() const; + virtual SDL_Rect getDrawPos() const; + virtual SDL_Rect getFrameDim() const; + virtual Frame getBaseFrame() const; + virtual bool isValid() const; + virtual bool isRunning() const; + virtual bool isImage() const; + virtual bool isFixed() const; + virtual void setFallBack(EmptyAnimation** newfallback=NULL); + protected: + Frame base_frame; + private: + EmptyAnimation** fallback; +}; + /** \brief Animation is responsible to return the correct frame of an animation */ -class Animation { +class Animation : public EmptyAnimation { public: /// \brief Initialize the animation /// \param abase_image Base image used for the animation /// \param aframes Number of frames + /// \param abp_type Base point type + /// \param aanimation_type Animation type /// \param afps FPS of the animation, if (afps < 0) it is considered to be the duration in ms, if (afps==0) a default duration DATA_LVLDUR is taken - /// \param aanimation_type Animation type /// \param astart_pos Start position from the frame array of the base_image - /// \param abp_type Base point type /// \param aallign_type Allignment type - /// \param ashift_x x shift value - /// \param ashift_y y shift value /// /// To load one still image simply use: Animation(imgcache->loadImage(1,"image_name.png")) Animation(const Image& abase_image, Uint16 aframes=1, + BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, double afps=0, Uint16 astart_pos=0, - BasePointType abp_type=BP_MD, - AllignType aallign_type=AT_MD, - Sint16 ashift_x=0, - Sint16 ashift_y=0); - ~Animation(); + AllignType aallign_type=AT_MD); + Animation(); + virtual ~Animation(); /// Set the base position of the animation - void setBasePos(SDL_Rect* abase_pos) { + virtual void setBasePos(SDL_Rect* abase_pos) { base_pos=abase_pos; checkAnim(); } /// Unsets the base position of the animation - void unsetBasePos() { + virtual void unsetBasePos() { base_pos=NULL; } /// Start the animation from the beginning (used when the animation was still) - void runAnim(); + virtual void runAnim(); /// Updates a running animation and stops it if necessary /// return True if the animation is still running - bool updateAnim(Uint16 dt); + virtual bool updateAnim(Uint16 dt); /// Calculates and returns the current frame - Frame getFrame() const; + virtual Frame getFrame() const; /// Calculates and returns the current draw position using: - /// base_pos,bp_type,allign_type,shift - SDL_Rect getDrawPos() const; + /// base_pos,bp_type,allign_type + virtual SDL_Rect getDrawPos() const; /// HACK: Return the dimensions of the first frame - SDL_Rect getFrameDim() const; + virtual SDL_Rect getFrameDim() const; /// HACK: Return the base frame - Frame getBaseFrame() const; + virtual Frame getBaseFrame() const; /// return True if the animation is valid - bool isValid() const { + virtual bool isValid() const { return is_valid; } /// return True if the animation is running - bool isRunning() const { + virtual bool isRunning() const { return is_running; } /// return True if the animation is a still image - bool isImage() const { + virtual bool isImage() const { return is_image; } /// return True if the animation dimensions stay the same - bool isFixed() const { + virtual bool isFixed() const { return is_fixed; - } - private: + } + virtual void setFallBack(EmptyAnimation**) { } + protected: + /// Helper function to set the shift values of the animation + void setShift(); /// Helper function to stop an animation bool stopAnim(); /// check validity of the animation bool checkAnim(); - private: + protected: /// Base image for the animation (big) Image base_image; /// Number of frames Uint16 frames; + ///\brief The base point of the animation + /// + /// The base point always stays fixed during the animation. + /// It's types are: BP_xy, where x may be either L,M or R and y may be either + /// U, M or D. L: left end, M: middle, R: right end, U: upper end, D: lower end + /// + /// Example: BP_MU means the BP is the upper middle point of each frame. + /// Default: BP_MD + BasePointType bp_type; /// Animation type: ATYPE_ONCE (play once), ATYPE_ONCE_END (play once and stop at end), /// ATYPE_LOOP (always play, jump back to the beginning), ATYPE_SWING (always play, /// reverse direction when finnished). The appended _REV means that the animation is @@ -86,31 +118,23 @@ double fps; /// Start position from the frame array of the base_image Uint16 start_pos; - ///\brief The base point of the animation - /// - /// The base point always stays fixed during the animation. - /// It's types are: BP_xy, where x may be either L,M or R and y may be either - /// U, M or D. L: left end, M: middle, R: right end, U: upper end, D: lower end - /// - /// Example: BP_MU means the BP is the upper middle point of each frame. - /// Default: BP_MD - BasePointType bp_type; ///\brief Allignment of the base point onto the base_pos /// /// The allignment specifies how the base point should be positioned wrt to the /// base_pos: It's type are basically the same as in BasePointType. /// /// Example: (Assuming BP_MD) AT_LD means the middle point of each frame (BP_MD) - /// is mapped onto the lower left edge of the base_pos + /// is stays fixed wrt to the base position and the animation is placed with + /// a "south west gravity" (similar to ImageMagick) wrt to the base position /// Default: AT_MD AllignType allign_type; - //@{ + + /* calculated (checkAnim()) or given values */ + /// Pointer to the current base position of the animation + SDL_Rect* base_pos; /// shift is added as an additional value to the designated BP position. Sint16 shift_x; Sint16 shift_y; - //@} - - /* calculated or given values/functions */ /// Duration of the animation in ms Uint32 duration; /// End position from the frame array of the base_image @@ -123,8 +147,6 @@ bool is_fixed; /* temporary values */ - /// Pointer to the current base position of the animation - SDL_Rect* base_pos; /// True if the animation is running bool is_running; /// True if the animation is running forward at the moment Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/common.h 2005-09-05 12:46:21 UTC (rev 146) @@ -38,6 +38,7 @@ class Font; class Event; class Weapon; +class EmptyAnimation; class Animation; class Menu; class Box; Modified: trunk/src/events.cpp =================================================================== --- trunk/src/events.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/events.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -52,12 +52,12 @@ delete this; } -AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, Animation* runanim, bool delanim): +AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimation* runanim, bool delanim): Event(obj,length,edelay,switchstate), anim(runanim), del(delanim), sound(asound) { - if (anim) { + if (anim && anim->isValid()) { state|=ESTATE_ANIM; duration=30000; } @@ -93,13 +93,15 @@ charowner(chr) { } //Exactly the same as AnimEvent with Character* instead of Object* -CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, Animation* runanim, bool delanim): +CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimation* runanim, bool delanim): CEvent(chr,length,edelay,switchstate), anim(runanim), del(delanim), sound(asound) { - if (anim) state|=ESTATE_ANIM; - if (anim!=NULL) duration=30000; + if (anim && anim->isValid()) { + state|=ESTATE_ANIM; + duration=30000; + } } Uint16 CAnimEvent::update(Uint16 dt) { Uint16 evstate=CEvent::update(dt); @@ -127,7 +129,7 @@ } -ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, Animation* runanim, bool delanim): +ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimation* runanim, bool delanim): CAnimEvent(chr,length,edelay,(switchstate|STATE_PRESS_LR),esound,runanim,delanim), dmax(edmax), t_reset(0) { @@ -167,7 +169,7 @@ } -EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, Animation* runanim, bool delanim): +EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimation* runanim, bool delanim): CAnimEvent(chr,length,edelay,switchstate|ESTATE_BUSY,esound,runanim,delanim), weapon(atweapon), direction(dir), Modified: trunk/src/events.h =================================================================== --- trunk/src/events.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/events.h 2005-09-05 12:46:21 UTC (rev 146) @@ -62,7 +62,7 @@ /// \todo Get rid of the delanim parameter /// \param delanim True if the animation should be deleted AnimEvent(Object* obj, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING, - Mix_Chunk* asound=NULL, Animation* runanim=NULL, bool delanim=false); + Mix_Chunk* asound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false); /// \brief Updates the events /// \return Event state: either delayed (EV_DELAY), starting (EV_START), /// running (EV_RUN), stopping (EV_END) or canceled (EV_CANCEL) @@ -71,7 +71,7 @@ virtual void end(); virtual void cancel(); protected: - Animation* anim; + EmptyAnimation* anim; bool del; Mix_Chunk* sound; }; @@ -83,13 +83,13 @@ class CAnimEvent : public CEvent { public: CAnimEvent(Character* chr, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING, - Mix_Chunk* asound=NULL, Animation* runanim=NULL, bool delanim=false); + Mix_Chunk* asound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false); virtual Uint16 update(Uint16 dt); virtual void start(); virtual void end(); virtual void cancel(); protected: - Animation* anim; + EmptyAnimation* anim; bool del; Mix_Chunk* sound; }; @@ -116,7 +116,7 @@ /// \param delanim True if the animation should be deleted EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weapon_range=0, Uint16 target_mask=NOTHING, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL, - Animation* runanim=NULL, bool delanim=false); + EmptyAnimation* runanim=NULL, bool delanim=false); virtual void end(); protected: Weapon* weapon; @@ -134,7 +134,7 @@ public: /// Adds the initial speed ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay=0, - Uint32 switchstate=0, Mix_Chunk* esound=NULL, Animation* runanim=NULL, bool delanim=false); + Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false); virtual ~ERun(); /// Forces the event to continue virtual void start(); Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/gfxeng.h 2005-09-05 12:46:21 UTC (rev 146) @@ -45,7 +45,7 @@ /// player bar SDL_Rect bar; /// symbol for one life of a player - Animation* lifeimage; + EmptyAnimation* lifeimage; bool show_bar; bool show_fps; //visual flags Modified: trunk/src/lost_penguins.cpp =================================================================== --- trunk/src/lost_penguins.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/lost_penguins.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -58,6 +58,7 @@ input->update(); scenario->physic->update(); gfxeng->draw(); + SDL_Delay(1); } quitGame(-2); Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/monsters_common.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -21,12 +21,15 @@ otype|=OTYPE_MONSTER; enemy_types|=OTYPE_PLAYER; dense_types|=OTYPE_PLAYER; - anim_left=animation; - anim_right=animation; + anim_left=new EmptyAnimation(&anim_right); + anim_right=new EmptyAnimation(); au_hit=scenario->sndcache->loadWAV("monhit.wav"); } -Monster::~Monster() { } +Monster::~Monster() { + delete anim_left; + delete anim_right; +} void Monster::addEnter(std::set& aset) { Character::addEnter(aset); Modified: trunk/src/monsters_common.h =================================================================== --- trunk/src/monsters_common.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/monsters_common.h 2005-09-05 12:46:21 UTC (rev 146) @@ -36,8 +36,8 @@ std::set targets; virtual Hit move(Uint16 dt, bool check=false); //common animations - Animation* anim_left; - Animation* anim_right; + EmptyAnimation* anim_left; + EmptyAnimation* anim_right; Mix_Chunk* au_hit; Sint16 Dai,Dattack; }; Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/baleog.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -14,11 +14,11 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); weapon=Weapon(-1,W_STRIKE); - anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,ATYPE_ONCE_END); - anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,ATYPE_ONCE_END); + anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE_END); + anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE_END); au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } Modified: trunk/src/objects/baleog.h =================================================================== --- trunk/src/objects/baleog.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/baleog.h 2005-09-05 12:46:21 UTC (rev 146) @@ -11,6 +11,6 @@ virtual void in_sp1(); private: Mix_Chunk* au_sword; - Animation* anim_sword_left; - Animation* anim_sword_right; + EmptyAnimation* anim_sword_left; + EmptyAnimation* anim_sword_right; }; Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/erik.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -18,43 +18,43 @@ /* anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); - anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); */ - anim_left=loadAnimation("erik_idle_left",config.lvlscale); - anim_right=loadAnimation("erik_idle_right",config.lvlscale); - anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale); - anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale); - anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale); - anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale); - anim_push_left=loadAnimation("erik_push_left",config.lvlscale); - anim_push_right=loadAnimation("erik_push_right",config.lvlscale); + anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); + anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); + anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD); + anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD); + anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD); + anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD); + anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD); + anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD); anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); - anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale); - anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale); - anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale); - anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale); - anim_land_left=loadAnimation("erik_land_left",config.lvlscale,ATYPE_ONCE_END); - anim_land_right=loadAnimation("erik_land_right",config.lvlscale,ATYPE_ONCE_END); - anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale); - anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale); - anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,ATYPE_ONCE_END); - anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,ATYPE_ONCE_END); - anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,ATYPE_ONCE_END); - anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,ATYPE_ONCE_END); - anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,ATYPE_ONCE_END); - anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,ATYPE_ONCE_END); - anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,ATYPE_ONCE_END); - anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,ATYPE_ONCE_END); - anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,ATYPE_ONCE_END); - anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,ATYPE_ONCE_END); - anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,ATYPE_ONCE_END); - anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,ATYPE_ONCE_END); - anim_bar=loadAnimation("bar_erik",config.lvlscale,ATYPE_ONCE); + anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD); + anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); + anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); + anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); + anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); + anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); + anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ au_jump=scenario->sndcache->loadWAV("rboots.wav"); Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/fang.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -16,8 +16,8 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8); anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); Modified: trunk/src/objects/fang.h =================================================================== --- trunk/src/objects/fang.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/fang.h 2005-09-05 12:46:21 UTC (rev 146) @@ -34,8 +34,8 @@ virtual void clearStates(bool reset=false); private: virtual void crash(Uint16 dir=DIR_DOWN); - Animation* anim_claw_left; - Animation* anim_claw_right; + EmptyAnimation* anim_claw_left; + EmptyAnimation* anim_claw_right; Mix_Chunk* au_jump; Mix_Chunk* au_claw; Sint16 jump; Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/olaf.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -16,20 +16,20 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,ATYPE_ONCE_END,25); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE_END,25); anim_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1); anim_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),1); - anim_walk_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),7,ATYPE_LOOP,3.5); - anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,ATYPE_LOOP,3.5); + anim_walk_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),7,BP_MD,ATYPE_LOOP,3.5); + anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,BP_MD,ATYPE_LOOP,3.5); anim_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); anim_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); - anim_walk_shield_left=NULL; - anim_walk_shield_right=NULL; - anim_fall_shield_left=NULL; - anim_fall_shield_right=NULL; + anim_walk_shield_left=new EmptyAnimation(&anim_shield_left); + anim_walk_shield_right=new EmptyAnimation(&anim_shield_right); + anim_fall_shield_left=new EmptyAnimation(&anim_shield_left); + anim_fall_shield_right=new EmptyAnimation(&anim_shield_right); au_small=scenario->sndcache->loadWAV("blob.wav"); au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); @@ -51,58 +51,42 @@ void Olaf::updateAnimState() { if (state&STATE_SMALL) { if (state&STATE_LEFT) { - if (!setAnim(anim_walk_small_left)) { - if (!setAnim(anim_small_left)) setAnim(anim_left); - } + anim_small_left->setFallBack(&anim_walk_left); + setAnim(anim_walk_small_left); + anim_small_left->setFallBack(&anim_left); } else { - if (!setAnim(anim_walk_small_right)) { - if (!setAnim(anim_small_right)) setAnim(anim_right); - } + anim_small_right->setFallBack(&anim_walk_right); + setAnim(anim_walk_small_right); + anim_small_right->setFallBack(&anim_right); } } else if (state&STATE_SHIELD) { otype|=OTYPE_DENSE_D; if (state&STATE_LEFT) { if (state&STATE_FALL) { - if (state&STATE_MLEFT) { - if (!setAnim(anim_fall_shield_left)) { - if (!setAnim(anim_shield_left)) { - if (!setAnim(anim_fall_left)) setAnim(anim_left); - } - } - } else if (!setAnim(anim_fall_shield_left)) { - if (!setAnim(anim_fall_left)) setAnim(anim_left); - } + anim_shield_left->setFallBack(&anim_fall_left); + setAnim(anim_fall_shield_left); + anim_shield_left->setFallBack(&anim_left); } else { if (state&STATE_MLEFT) { - if (!setAnim(anim_walk_shield_left)) { - if (!setAnim(anim_shield_left)) { - if (!setAnim(anim_walk_left)) setAnim(anim_left); - } - } + anim_shield_left->setFallBack(&anim_walk_left); + setAnim(anim_walk_shield_left); + anim_shield_left->setFallBack(&anim_left); } else { - if (!setAnim(anim_shield_left)) setAnim(anim_left); + setAnim(anim_shield_left); } } } else { if (state&STATE_FALL) { - if (state&STATE_MRIGHT) { - if (!setAnim(anim_fall_shield_right)) { - if (!setAnim(anim_shield_right)) { - if (!setAnim(anim_fall_right)) setAnim(anim_right); - } - } - } else if (!setAnim(anim_fall_shield_right)) { - if (!setAnim(anim_fall_right)) setAnim(anim_right); - } + anim_shield_right->setFallBack(&anim_fall_right); + setAnim(anim_fall_shield_right); + anim_shield_right->setFallBack(&anim_right); } else { if (state&STATE_MRIGHT) { - if (!setAnim(anim_walk_shield_right)) { - if (!setAnim(anim_shield_right)) { - if (!setAnim(anim_walk_right)) setAnim(anim_right); - } - } + anim_shield_right->setFallBack(&anim_walk_right); + setAnim(anim_walk_shield_right); + anim_shield_right->setFallBack(&anim_right); } else { - if (!setAnim(anim_shield_right)) setAnim(anim_right); + setAnim(anim_shield_right); } } } @@ -129,7 +113,7 @@ //Are we already small? if ((small && (state&STATE_SMALL)) || ((!small) && (!(state&STATE_SMALL)))) return true; - Animation* tmpanim; + EmptyAnimation* tmpanim; SDL_Rect tmppos=pos; if (small) tmpanim=anim_small_left; //Assume both images have the same dimension Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/olaf.h 2005-09-05 12:46:21 UTC (rev 146) @@ -41,16 +41,16 @@ /// \return True if successfull inline bool trySmall(bool small); //@{ - Animation* anim_small_left; - Animation* anim_small_right; - Animation* anim_walk_small_left; - Animation* anim_walk_small_right; - Animation* anim_shield_left; - Animation* anim_shield_right; - Animation* anim_walk_shield_left; - Animation* anim_walk_shield_right; - Animation* anim_fall_shield_left; - Animation* anim_fall_shield_right; + EmptyAnimation* anim_small_left; + EmptyAnimation* anim_small_right; + EmptyAnimation* anim_walk_small_left; + EmptyAnimation* anim_walk_small_right; + EmptyAnimation* anim_shield_left; + EmptyAnimation* anim_shield_right; + EmptyAnimation* anim_walk_shield_left; + EmptyAnimation* anim_walk_shield_right; + EmptyAnimation* anim_fall_shield_left; + EmptyAnimation* anim_fall_shield_right; //@} //@{ Mix_Chunk* au_small; Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/scorch.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -16,8 +16,8 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); au_tired=scenario->sndcache->loadWAV("flwings.wav"); au_hit=scenario->sndcache->loadWAV("draghit.wav"); Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects/zombie.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -15,8 +15,8 @@ au_attack(scenario->sndcache->loadWAV("clang.wav")), T_Attack_Bite(1500) { maxspeedx=80; - anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,ATYPE_LOOP,2); - anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,ATYPE_LOOP,2); + anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); + anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); weapon=Weapon(-1,W_STRIKE); } Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects_common.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -61,12 +61,10 @@ Animation* Object::loadAnimation(string anim_name, double scale_factor, + BasePointType abp_type, Uint16 aanimation_type, double afps, - BasePointType abp_type, - AllignType aallign_type, - Sint16 ashift_x, - Sint16 ashift_y) { + AllignType aallign_type) { /* Parse animation data file */ ifstream file; @@ -110,7 +108,7 @@ aframes=(Uint16)atoi(arg4.c_str()); if (anim_name==tmp_anim_name) { - return loadAnimation(imgcache->loadImage(imagename,scale_factor),aframes,aanimation_type,afps,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); + return loadAnimation(imgcache->loadImage(imagename,scale_factor),aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type); } } } @@ -121,14 +119,12 @@ Animation* Object::loadAnimation(const Image& abase_image, Uint16 aframes, + BasePointType abp_type, Uint16 aanimation_type, double afps, Uint16 astart_pos, - BasePointType abp_type, - AllignType aallign_type, - Sint16 ashift_x, - Sint16 ashift_y) { - Animation* anim=new Animation(abase_image,aframes,aanimation_type,afps,astart_pos,abp_type,aallign_type,ashift_x,ashift_y); + AllignType aallign_type) { + Animation* anim=new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type); anim->setBasePos(&pos); return anim; } @@ -142,8 +138,8 @@ bool Object::updateAnim(Uint16 dt) { return (animation->updateAnim(dt)); } -bool Object::setAnim(Animation* anim, bool start) { - if (anim) { +bool Object::setAnim(EmptyAnimation* anim, bool start) { + if (anim && anim->isValid()) { animation=anim; if (start) { animation->setBasePos(&pos); @@ -151,7 +147,7 @@ } return true; } else { - animation=anim_orig; + if (anim==NULL) animation=anim_orig; return false; } } Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/objects_common.h 2005-09-05 12:46:21 UTC (rev 146) @@ -88,7 +88,7 @@ /// and starts it right away. Should not be used with updateAnimState, /// set ESTATE_ANIM to deactivate an updateAnimState. This is usually /// controlled by an AnimationEvent - bool setAnim(Animation* anim, bool start=false); + bool setAnim(EmptyAnimation* anim, bool start=false); /// Sets the animation back to the default one. virtual void resetAnimState(); bool isRunning() const; @@ -108,22 +108,18 @@ /// Load an animation bound onto this object from an animation data file Animation* loadAnimation(string anim_name, double scale_factor=1, - Uint16 aanimation_type=ATYPE_LOOP, - double afps=DATA_LVLFPS, BasePointType abp_type=BP_MD, - AllignType aallign_type=AT_MD, - Sint16 ashift_x=0, - Sint16 ashift_y=0); + Uint16 aanimation_type=ATYPE_LOOP, + double afps=0, + AllignType aallign_type=AT_MD); /// Load an animation bound onto this object Animation* loadAnimation(const Image& abase_image, Uint16 aframes=1, + BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, - double afps=DATA_LVLFPS, + double afps=0, Uint16 astart_pos=0, - BasePointType abp_type=BP_MD, - AllignType aallign_type=AT_MD, - Sint16 ashift_x=0, - Sint16 ashift_y=0); + AllignType aallign_type=AT_MD); //Events (triggered animations/effects) //@{ /// Clears the event field (sets it to NULL). This should only be used by @@ -183,8 +179,8 @@ protected: Uint32 state; Event* event; - Animation* anim_orig; - Animation* animation; + EmptyAnimation* anim_orig; + EmptyAnimation* animation; ///\todo Document this! /// Upper left logical position of the object (used for decisions) SDL_Rect pos; Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/players_common.cpp 2005-09-05 12:46:21 UTC (rev 146) @@ -26,25 +26,41 @@ state=STATE_FALL; otype|=OTYPE_PLAYER; enemy_types|=OTYPE_MONSTER; - anim_left=anim_right=NULL; - anim_rock_left=anim_rock_right=NULL; - anim_walk_left=anim_walk_right=NULL; - anim_push_left=anim_push_right=NULL; - anim_fall_left=anim_fall_right=NULL; - anim_fall_fast_left=anim_fall_fast_right=NULL; - anim_land_left=anim_land_right=NULL; - anim_crash_left=anim_crash_right=NULL; - anim_rope_left=anim_rope_right=NULL; - anim_teleport_left=anim_teleport_right=NULL; - anim_die_crash_left=anim_die_crash_right=NULL; - anim_die_burn_left=anim_die_burn_right=NULL; - anim_die_bones_left=anim_die_bones_right=NULL; - anim_die_elec_left=anim_die_elec_right=NULL; - anim_die_spike_left=anim_die_spike_right=NULL; - anim_die_water_left=anim_die_water_right=NULL; - anim_fall_middle=NULL; - anim_climb=NULL; - anim_bar=NULL; + anim_left=new EmptyAnimation(&anim_right); + anim_right=new EmptyAnimation(); + anim_rock_left=new EmptyAnimation(&anim_left); + anim_rock_right=new EmptyAnimation(&anim_right); + anim_walk_left=new EmptyAnimation(&anim_left); + anim_walk_right=new EmptyAnimation(&anim_right); + anim_push_left=new EmptyAnimation(&anim_left); + anim_push_right=new EmptyAnimation(&anim_right); + anim_fall_left=new EmptyAnimation(&anim_left); + anim_fall_right=new EmptyAnimation(&anim_right); + anim_fall_fast_left=new EmptyAnimation(&anim_fall_left); + anim_fall_fast_right=new EmptyAnimation(&anim_fall_right); + anim_land_left=new EmptyAnimation(); + anim_land_right=new EmptyAnimation(); + anim_crash_left=new EmptyAnimation(); + anim_crash_right=new EmptyAnimation(); + anim_rope_left=new EmptyAnimation(&anim_left); + anim_rope_right=new EmptyAnimation(&anim_right); + anim_teleport_left=new EmptyAnimation(); + anim_teleport_right=new EmptyAnimation(); + anim_die_crash_left=new EmptyAnimation(&anim_die_bones_left); + anim_die_crash_right=new EmptyAnimation(&anim_die_bones_right); + anim_die_burn_left=new EmptyAnimation(&anim_die_bones_left); + anim_die_burn_right=new EmptyAnimation(&anim_die_bones_right); + anim_die_bones_left=new EmptyAnimation(&anim_die_bones_right); + anim_die_bones_right=new EmptyAnimation(); + anim_die_elec_left=new EmptyAnimation(&anim_die_bones_left); + anim_die_elec_right=new EmptyAnimation(&anim_die_bones_right); + anim_die_spike_left=new EmptyAnimation(&anim_die_bones_left); + anim_die_spike_right=new EmptyAnimation(&anim_die_bones_right); + anim_die_water_left=new EmptyAnimation(&anim_die_bones_left); + anim_die_water_right=new EmptyAnimation(&anim_die_bones_right); + anim_fall_middle=new EmptyAnimation(&anim_fall_right); + anim_climb=new EmptyAnimation(&anim_right); + anim_bar=new EmptyAnimation(&anim_right); au_land=scenario->sndcache->loadWAV("dizzy.wav"); au_act=scenario->sndcache->loadWAV("button.wav"); au_useerror=scenario->sndcache->loadWAV("useerror.wav"); @@ -196,36 +212,30 @@ if (state&STATE_LEFT) { if (state&STATE_FALL) { if (speed>V_KRIT) { - if (!setAnim(anim_fall_fast_left)) { - if (!setAnim(anim_fall_left)) setAnim(anim_left); - } + setAnim(anim_fall_fast_left); } else if (state&STATE_MLEFT || speed < 0) { - if (!setAnim(anim_fall_left)) setAnim(anim_left); + setAnim(anim_fall_left); } else { - if (!setAnim(anim_fall_middle)) { - if (!setAnim(anim_fall_left)) setAnim(anim_left); - } + anim_fall_middle->setFallBack(&anim_fall_left); + setAnim(anim_fall_middle); } } else if (state&STATE_MLEFT) { - if (!setAnim(anim_walk_left)) setAnim(anim_left); + setAnim(anim_walk_left); } else { setAnim(anim_left); } } else { if (state&STATE_FALL) { if (speed>V_KRIT) { - if (!setAnim(anim_fall_fast_right)) { - if (!setAnim(anim_fall_right)) setAnim(anim_right); - } + setAnim(anim_fall_fast_right); } else if (state&STATE_MRIGHT || speed < 0) { - if (!setAnim(anim_fall_right)) setAnim(anim_right); + setAnim(anim_fall_right); } else { - if (!setAnim(anim_fall_middle)) { - if (!setAnim(anim_fall_right)) setAnim(anim_right); - } + anim_fall_middle->setFallBack(&anim_fall_right); + setAnim(anim_fall_middle); } } else if (state&STATE_MRIGHT) { - if (!setAnim(anim_walk_right)) setAnim(anim_right); + setAnim(anim_walk_right); } else { setAnim(anim_right); } Modified: trunk/src/players_common.h =================================================================== --- trunk/src/players_common.h 2005-09-04 21:31:57 UTC (rev 145) +++ trunk/src/players_common.h 2005-09-05 12:46:21 UTC (rev 146) @@ -114,41 +114,41 @@ virtual void die(); virtual Hit move(Uint16 dt, bool check=false); //@{ - Animation* anim_left; - Animation* anim_right; - Animation* anim_rock_left; - Animation* anim_rock_right; - Animation* anim_walk_left; - Animation* anim_walk_right; - Animation* anim_push_left; - Animation* anim_push_right; - Animation* anim_fall_left; - Animation* anim_fall_right; - Animation* anim_fall_fast_left; - Animation* anim_fall_fast_right; - Animation* anim_land_left; - Animation* anim_land_right; - Animation* anim_crash_left; - Animation* anim_crash_right; - Animation* anim_rope_left; - Animation* anim_rope_right; - Animation* anim_teleport_left; - Animation* anim_teleport_right; - Animation* anim_die_crash_left; - Animation* anim_die_crash_right; - Animation* anim_die_burn_left; - Animation* anim_die_burn_right; - Animation* anim_die_bones_left; - Animation* anim_die_bones_right; - Animation* anim_die_elec_left; - Animation* anim_die_elec_right; - Animation* anim_die_spike_left; - Animation* anim_die_spike_right; - Animation* anim_die_water_left; - Animation* anim_die_water_right; - Animation* anim_fall_middle; - Animation* anim_climb; - Animation* anim_bar; + EmptyAnimation* anim_left; + EmptyAnimation* anim_right; + EmptyAnimation* anim_rock_left; + EmptyAnimation* anim_rock_right; + EmptyAnimation* anim_walk_left; + EmptyAnimation* anim_walk_right; + EmptyAnimation* anim_push_left; + EmptyAnimation* anim_push_right; + EmptyAnimation* anim_fall_left; + EmptyAnimation* anim_fall_right; + EmptyAnimation* anim_fall_fast_left; + EmptyAnimation* anim_fall_fast_right; + EmptyAnimation* anim_land_left; + EmptyAnimation* anim_land_right; + EmptyAnimation* anim_crash_left; + EmptyAnimation* anim_crash_right; + EmptyAnimation* anim_rope_left; + EmptyAnimation* anim_rope_right; + EmptyAnimation* anim_teleport_left; + EmptyAnimation* anim_teleport_right; + EmptyAnimation* anim_die_crash_left; + EmptyAnimation* anim_die_crash_right; + EmptyAnimation* anim_die_burn_left; + EmptyAnimation* anim_die_burn_right; + EmptyAnimation* anim_die_bones_left; + EmptyAnimation* anim_die_bones_right; + EmptyAnimation* anim_die_elec_left; + EmptyAnimation* anim_die_elec_right; + EmptyAnimation* anim_die_spike_left; + EmptyAnimation* anim_die_spike_right; + EmptyAnimation* anim_die_water_left; + EmptyAnimation* anim_die_water_right; + EmptyAnimation* anim_fall_middle; + EmptyAnimation* anim_climb; + EmptyAnimation* anim_bar; //@} //@{ Mix_Chunk* au_hit; From DONOTREPLY at icculus.org Mon Sep 5 17:53:58 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 5 Sep 2005 17:53:58 -0400 Subject: r147 - in trunk/src: . objects Message-ID: <20050905215358.32560.qmail@icculus.org> Author: jonas Date: 2005-09-05 17:53:57 -0400 (Mon, 05 Sep 2005) New Revision: 147 Modified: trunk/src/Makefile trunk/src/animation.cpp trunk/src/common.cpp trunk/src/common.h trunk/src/events.cpp trunk/src/gfxeng.cpp trunk/src/gfxeng.h trunk/src/objects/erik.cpp trunk/src/objects/erik.h trunk/src/objects/fang.cpp trunk/src/objects/olaf.cpp trunk/src/objects/scorch.cpp trunk/src/objects/zombie.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp Log: o Fixed a huge memleak caused by forgotten deletes: The Animation* pointer handling became silly, be prepared for boost::shared_ptr... o Added a debug flag to the gfxeng to show the position of each object (used in the editor) o Fixed a big bug in anim->getDrawPos() that let it only load start_pos=0 animations properly... o Replaced some old Animation* pointers to EmptyAnimation* and NULL pointers to EmptyAnimation() Modified: trunk/src/Makefile =================================================================== --- trunk/src/Makefile 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/Makefile 2005-09-05 21:53:57 UTC (rev 147) @@ -2,7 +2,7 @@ CXX_FLAGS = -W -Wall -ansi -pedantic CXX_DEBUG = -g #-fno-inline CXX_OPT = #-O2 -march=pentium4 -ffast-math -CXX_GAME = -DSDL_MIXER -DSDL_IMAGE -DALPHA -I ./ +CXX_GAME = -DSDL_MIXER -DSDL_IMAGE -DALPHA -DDEBUG -I ./ SDL = `sdl-config --cflags` SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image -ldl -rdynamic Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/animation.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -183,7 +183,7 @@ return base_frame; } SDL_Rect Animation::getDrawPos() const { - SDL_Rect draw_pos=base_image.description[cur_frame_num]; + SDL_Rect draw_pos=base_image.description[start_pos+cur_frame_num]; if (!base_pos || !isValid()) { if (!isValid()) cout << "Invalid DrawPos of an invalid animation!" << endl; else cout << "Invalid DrawPos!" << endl; Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/common.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -1,4 +1,5 @@ #include "common.h" +#include "gfxeng.h" ImageCache* imgcache; SoundCache* sndcache; @@ -32,7 +33,7 @@ return s.str(); } -int boost(int a, int b) { +int addAbsolute(int a, int b) { if (a>=0) return a=max(0,a+b); else return a=min(0,a-b); } @@ -44,28 +45,22 @@ void setGameMode(Uint8 newmode) { game_mode=newmode; if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) { + gfxeng->setShowDebug(); SDL_ShowCursor(SDL_ENABLE); } else { + gfxeng->unsetShowDebug(); SDL_ShowCursor(SDL_DISABLE); } } void addGameMode(Uint8 addmode) { game_mode|=addmode; - if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) { - SDL_ShowCursor(SDL_ENABLE); - } else { - SDL_ShowCursor(SDL_DISABLE); - } + setGameMode(game_mode); } void removeGameMode(Uint8 rmmode) { game_mode&=~rmmode; - if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) { - SDL_ShowCursor(SDL_ENABLE); - } else { - SDL_ShowCursor(SDL_DISABLE); - } + setGameMode(game_mode); } Frame::Frame(SDL_Surface* surface,SDL_Rect rect): Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/common.h 2005-09-05 21:53:57 UTC (rev 147) @@ -206,8 +206,8 @@ void usage(); /// Helper function that converts an integer to a string string itos(int); -/// Helper function boost that increases/decreases the absolute value -int boost(int,int); +/// Helper function that increases/decreases the absolute value +int addAbsolute(int,int); /// Calculate the fps as frames*1000/duration_in_ms double calcFPS(Uint16 frames, Uint32 duration); Modified: trunk/src/events.cpp =================================================================== --- trunk/src/events.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/events.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -64,23 +64,23 @@ } Uint16 AnimEvent::update(Uint16 dt) { Uint16 evstate=Event::update(dt); - if (started && anim && (!(anim->isRunning()))) return EV_END; + if (started && state&ESTATE_ANIM && (!(anim->isRunning()))) return EV_END; else return evstate; } void AnimEvent::start() { sfxeng->playWAV(sound); - if (anim) owner->setAnim(anim,true); + if (state&ESTATE_ANIM) owner->setAnim(anim,true); Event::start(); } void AnimEvent::end() { - if (started && anim) { + if (started && state&ESTATE_ANIM) { if (del) delete anim; owner->resetAnimState(); } Event::end(); } void AnimEvent::cancel() { - if (started && anim) { + if (started && state&ESTATE_ANIM) { if (del) delete anim; owner->resetAnimState(); } @@ -105,23 +105,23 @@ } Uint16 CAnimEvent::update(Uint16 dt) { Uint16 evstate=CEvent::update(dt); - if (started && anim && (!(anim->isRunning()))) return EV_END; + if (started && state&ESTATE_ANIM && (!(anim->isRunning()))) return EV_END; else return evstate; } void CAnimEvent::start() { sfxeng->playWAV(sound); - if (anim) charowner->setAnim(anim,true); + if (state&ESTATE_ANIM) charowner->setAnim(anim,true); CEvent::start(); } void CAnimEvent::end() { - if (started && anim) { + if (started && state&ESTATE_ANIM) { if (del) delete anim; charowner->resetAnimState(); } CEvent::end(); } void CAnimEvent::cancel() { - if (started && anim) { + if (started && state&ESTATE_ANIM) { if (del) delete anim; charowner->resetAnimState(); } Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/gfxeng.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -18,6 +18,7 @@ menubg(NULL), show_bar(true), show_fps(true), + show_debug(false), fullscreen(config.full) { updatetype=UPDATE_ALL; shift.x=0; @@ -141,7 +142,7 @@ void GraphicsEngine::drawScene() { //We don't want to change pos! - SDL_Rect tmprect,srcpos; + SDL_Rect tmprect,srcpos,debugrect; if (game_mode&GAME_PLAY) { if (scenario->player!=NULL) { shift=setShift(scenario->player->getCenter()); @@ -161,6 +162,10 @@ while (obit!=scenario->pool->objectspool.end()) { tmprect=((*obit)->getDrawPos()); srcpos=(*obit)->getFrame().pos; + if (show_debug) { + debugrect=*(*obit)->getPos(); + drawRectangle(debugrect,1,SDL_MapRGB(screen->format,100,20,0)); + } SDL_BlitSurface((*obit)->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); ++obit; } @@ -274,6 +279,13 @@ } } +void GraphicsEngine::setShowDebug() { + show_debug=true; +} +void GraphicsEngine::unsetShowDebug() { + show_debug=false; +} + void GraphicsEngine::toggleFullScreen() { //on -> off if (fullscreen) { @@ -406,3 +418,35 @@ shift.y=shifty; return shift; } + +void GraphicsEngine::drawRectangle(SDL_Rect rect, Uint8 border, Uint32 color) { + SDL_Rect tmpline=*shiftMapArea(rect,shift); + rect=tmpline; + rect.x-=border; + rect.y-=border; + rect.w+=2*border; + rect.h=border; + /* horizontal top */ + SDL_FillRect(screen,&rect,color); + rect=tmpline; + rect.x-=border; + rect.y+=tmpline.h; + rect.w+=2*border; + rect.h=border; + /* horizontal bottom */ + SDL_FillRect(screen,&rect,color); + rect=tmpline; + rect.x-=border; + rect.y-=border; + rect.w=border; + rect.h+=2*border; + /* vertical left */ + SDL_FillRect(screen,&rect,color); + rect=tmpline; + rect.x+=tmpline.w; + rect.y-=border; + rect.w=border; + rect.h+=2*border; + /* vertical right */ + SDL_FillRect(screen,&rect,color); +} Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/gfxeng.h 2005-09-05 21:53:57 UTC (rev 147) @@ -29,12 +29,15 @@ void togglePlayerBar(); void toggleFPS(); void toggleFullScreen(); + void setShowDebug(); + void unsetShowDebug(); void setMenuBG(SDL_Surface* menu_background=NULL); const SDL_Rect& addShift(Sint16,Sint16); const SDL_Rect& setShift(Sint16,Sint16); const SDL_Rect& getShift() { return shift; } + void drawRectangle(SDL_Rect rect, Uint8 border=1, Uint32 color=0); protected: /// main screen SDL_Surface* screen; @@ -48,6 +51,7 @@ EmptyAnimation* lifeimage; bool show_bar; bool show_fps; + bool show_debug; //visual flags bool fullscreen; //update state Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects/erik.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -16,47 +16,60 @@ jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); /* - anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); - anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); - anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); + delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); + delete anim_land_left; anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_land_right; anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_crash_left; anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_crash_right; anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); */ - anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); - anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); - anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD); - anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD); - anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD); - anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD); - anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD); - anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD); - anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); - anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD); - anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); - anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); - anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); - anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); - anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); - anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); + delete anim_left; anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); + delete anim_right; anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); + delete anim_rock_left; anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD); + delete anim_rock_right; anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD); + delete anim_walk_left; anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD); + delete anim_walk_right; anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD); + delete anim_push_left; anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD); + delete anim_push_right; anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD); + delete anim_fall_middle; anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); + delete anim_fall_left; anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD); + delete anim_fall_right; anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); + delete anim_fall_fast_left; anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); + delete anim_fall_fast_right; anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); + delete anim_land_left; anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_land_right; anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_crash_left; anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_crash_right; anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_rope_left; anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); + delete anim_rope_right; anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); + delete anim_teleport_left; anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_teleport_right; anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_die_crash_left; anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_die_crash_right; anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_die_burn_left; anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_die_burn_right; anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_die_bones_left; anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_die_bones_right; anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_die_elec_left; anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_die_elec_right; anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_die_spike_left; anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + delete anim_die_spike_right; anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + delete anim_bar; anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); + /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ - /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ + anim_erik_jump_left=loadAnimation("erik_jump_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_jump_right=loadAnimation("erik_jump_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_erik_jump2_left=loadAnimation("erik_jump2_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_jump2_right=loadAnimation("erik_jump2_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_erik_start_run_left=loadAnimation("erik_start_run_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_start_run_right=loadAnimation("erik_start_run_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_erik_swim_left=loadAnimation("erik_swim_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_swim_right=loadAnimation("erik_swim_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_erik_swim_up_left=loadAnimation("erik_swim_up_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_swim_up_right=loadAnimation("erik_swim_up_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_erik_hit_water_left=loadAnimation("erik_hit_water_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_hit_water_right=loadAnimation("erik_hit_water_right",config.lvlscale,BP_LD,ATYPE_ONCE); + au_jump=scenario->sndcache->loadWAV("rboots.wav"); au_hit=scenario->sndcache->loadWAV("erikhit.wav"); au_run=NULL; Modified: trunk/src/objects/erik.h =================================================================== --- trunk/src/objects/erik.h 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects/erik.h 2005-09-05 21:53:57 UTC (rev 147) @@ -25,6 +25,18 @@ virtual void crash(Uint16 dir); virtual Uint16 hit(Uint16 direction,Weapon& weap); private: + EmptyAnimation* anim_erik_jump_left; + EmptyAnimation* anim_erik_jump_right; + EmptyAnimation* anim_erik_jump2_left; + EmptyAnimation* anim_erik_jump2_right; + EmptyAnimation* anim_erik_start_run_left; + EmptyAnimation* anim_erik_start_run_right; + EmptyAnimation* anim_erik_swim_left; + EmptyAnimation* anim_erik_swim_right; + EmptyAnimation* anim_erik_swim_up_left; + EmptyAnimation* anim_erik_swim_up_right; + EmptyAnimation* anim_erik_hit_water_left; + EmptyAnimation* anim_erik_hit_water_right; Mix_Chunk* au_jump; Mix_Chunk* au_run; Sint16 jump,jump2; Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects/fang.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -12,12 +12,12 @@ Player(imagename,xcord,ycord,pname), jump(V_JUMP) { weapon=Weapon(-1,W_STRIKE); - anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); - anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); - anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); - anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); + delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); + delete anim_walk_left; anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); + delete anim_walk_right; anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); + delete anim_crash_left; anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_crash_right; anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8); anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); @@ -40,8 +40,8 @@ void Fang::fall(Uint16 dt) { if (!getState(STATE_MRIGHT|STATE_MLEFT)) { - if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100); - else hspeed=boost(hspeed,-dt*HSPEED_MULT/200); + if (!getState(STATE_FALL)) hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/100); + else hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/200); } Dgrav+=dt; if (Dgrav>T_GRAV_EFFECT) { Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects/olaf.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -179,8 +179,8 @@ void Olaf::fall(Uint16 dt) { if (!getState(STATE_MRIGHT|STATE_MLEFT)) { - if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100); - else hspeed=boost(hspeed,-dt*HSPEED_MULT/200); + if (!getState(STATE_FALL)) hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/100); + else hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/200); } Dgrav+=dt; if (Dgrav>T_GRAV_EFFECT) { Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects/scorch.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -12,12 +12,12 @@ Player(imagename,xcord,ycord,pname), left_wings(SCORCH_MAX_WINGS), wing(V_FLY) { - anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); - anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + delete anim_walk_left; anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); + delete anim_walk_right; anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); + delete anim_crash_left; anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + delete anim_crash_right; anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); au_tired=scenario->sndcache->loadWAV("flwings.wav"); au_hit=scenario->sndcache->loadWAV("draghit.wav"); @@ -36,8 +36,8 @@ void Scorch::fall(Uint16 dt) { if (!getState(STATE_MRIGHT|STATE_MLEFT)) { - if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100); - else hspeed=boost(hspeed,-dt*HSPEED_MULT/200); + if (!getState(STATE_FALL)) hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/100); + else hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/200); } Dgrav+=dt; if (Dgrav>T_GRAV_EFFECT) { Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects/zombie.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -15,8 +15,8 @@ au_attack(scenario->sndcache->loadWAV("clang.wav")), T_Attack_Bite(1500) { maxspeedx=80; - anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); - anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); + delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); + delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); weapon=Weapon(-1,W_STRIKE); } Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects_common.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -59,7 +59,7 @@ return ok; } -Animation* Object::loadAnimation(string anim_name, +EmptyAnimation* Object::loadAnimation(string anim_name, double scale_factor, BasePointType abp_type, Uint16 aanimation_type, @@ -74,7 +74,7 @@ file.open(loadfile.c_str()); if (!file) { cout << "Failed to open the animation data file: " << loadfile << " => Couldn't load " << anim_name << " animation!\n" << endl; - return NULL; + return new EmptyAnimation(); } else { string arg1,arg2,arg3,arg4,arg5,arg6; string tmp_anim_name=""; @@ -114,17 +114,18 @@ } } } - return NULL; + cout << "Animation " << anim_name << " not found!" << endl; + return new EmptyAnimation(); } -Animation* Object::loadAnimation(const Image& abase_image, +EmptyAnimation* Object::loadAnimation(const Image& abase_image, Uint16 aframes, BasePointType abp_type, Uint16 aanimation_type, double afps, Uint16 astart_pos, AllignType aallign_type) { - Animation* anim=new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type); + EmptyAnimation* anim=new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type); anim->setBasePos(&pos); return anim; } Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/objects_common.h 2005-09-05 21:53:57 UTC (rev 147) @@ -106,14 +106,14 @@ } //@} /// Load an animation bound onto this object from an animation data file - Animation* loadAnimation(string anim_name, + EmptyAnimation* loadAnimation(string anim_name, double scale_factor=1, BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, double afps=0, AllignType aallign_type=AT_MD); /// Load an animation bound onto this object - Animation* loadAnimation(const Image& abase_image, + EmptyAnimation* loadAnimation(const Image& abase_image, Uint16 aframes=1, BasePointType abp_type=BP_MD, Uint16 aanimation_type=ATYPE_LOOP, Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-05 12:46:21 UTC (rev 146) +++ trunk/src/players_common.cpp 2005-09-05 21:53:57 UTC (rev 147) @@ -281,8 +281,8 @@ void Player::fall(Uint16 dt) { if (!getState(STATE_MRIGHT|STATE_MLEFT)) { - if (!getState(STATE_FALL)) hspeed=boost(hspeed,-dt*HSPEED_MULT/100); - else hspeed=boost(hspeed,-dt*HSPEED_MULT/200); + if (!getState(STATE_FALL)) hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/100); + else hspeed=addAbsolute(hspeed,-dt*HSPEED_MULT/200); } Character::fall(dt); } From DONOTREPLY at icculus.org Tue Sep 6 04:24:41 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 04:24:41 -0400 Subject: r148 - in trunk: . src src/objects Message-ID: <20050906082441.7147.qmail@icculus.org> Author: jonas Date: 2005-09-06 04:24:40 -0400 (Tue, 06 Sep 2005) New Revision: 148 Modified: trunk/INSTALL trunk/TODO trunk/src/animation.cpp trunk/src/animation.h trunk/src/common.h trunk/src/events.cpp trunk/src/events.h trunk/src/gfxeng.cpp trunk/src/gfxeng.h trunk/src/imgcache.cpp trunk/src/monsters_common.cpp trunk/src/monsters_common.h trunk/src/objects/baleog.cpp trunk/src/objects/baleog.h trunk/src/objects/erik.cpp trunk/src/objects/erik.h trunk/src/objects/fang.cpp trunk/src/objects/fang.h trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/scorch.cpp trunk/src/objects/scorch.h trunk/src/objects/zombie.cpp trunk/src/objects/zombie.h trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp trunk/src/players_common.h Log: o We depend on Boost: boost::shared_ptr at the moment o Replaced all EmptyAnimation* with typedef boost::shared_ptr EmptyAnimationPtr... o Check for the validity of the returned surface in imgcache->loadImage(...) Modified: trunk/INSTALL =================================================================== --- trunk/INSTALL 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/INSTALL 2005-09-06 08:24:40 UTC (rev 148) @@ -4,6 +4,7 @@ You need the data files from a game (atm only lost vikings), put the data directory into your lost_penguins/ directory... +libboost-dev libsdl1.2 libsdl-mixer1.2 (if compiled with -DSDL_MIXER) libsdl-image1.2 (if compiled with -DSDL_IMAGE) Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/TODO 2005-09-06 08:24:40 UTC (rev 148) @@ -5,6 +5,8 @@ o left/right move + switchPlayer (keeps moving) o key vs. trigger in map2 o fall event (DONE?) + o left/right fallback? + o players die event segfault (eg. olaf) Code Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/animation.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -1,7 +1,7 @@ #include "common.h" #include "animation.h" -EmptyAnimation::EmptyAnimation(EmptyAnimation** afallback) : fallback(afallback) { } +EmptyAnimation::EmptyAnimation(EmptyAnimationPtr* afallback) : fallback(afallback) { } void EmptyAnimation::setBasePos(SDL_Rect* abase_pos) { if (fallback) (*fallback)->setBasePos(abase_pos); } @@ -47,7 +47,7 @@ if (fallback) return (*fallback)->isFixed(); else return true; } -void EmptyAnimation::setFallBack(EmptyAnimation** newfallback) { +void EmptyAnimation::setFallBack(EmptyAnimationPtr* newfallback) { fallback=newfallback; } Modified: trunk/src/animation.h =================================================================== --- trunk/src/animation.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/animation.h 2005-09-06 08:24:40 UTC (rev 148) @@ -3,7 +3,7 @@ class EmptyAnimation { public: - EmptyAnimation(EmptyAnimation** afallback=NULL); + EmptyAnimation(EmptyAnimationPtr* afallback=NULL); virtual ~EmptyAnimation() { } virtual void setBasePos(SDL_Rect*); virtual void unsetBasePos(); @@ -17,11 +17,11 @@ virtual bool isRunning() const; virtual bool isImage() const; virtual bool isFixed() const; - virtual void setFallBack(EmptyAnimation** newfallback=NULL); + virtual void setFallBack(EmptyAnimationPtr* newfallback=NULL); protected: Frame base_frame; private: - EmptyAnimation** fallback; + EmptyAnimationPtr* fallback; }; /** \brief Animation is responsible to return the correct frame of an animation @@ -87,7 +87,7 @@ virtual bool isFixed() const { return is_fixed; } - virtual void setFallBack(EmptyAnimation**) { } + virtual void setFallBack(EmptyAnimationPtr*) { } protected: /// Helper function to set the shift values of the animation void setShift(); Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/common.h 2005-09-06 08:24:40 UTC (rev 148) @@ -19,6 +19,7 @@ #ifdef SDL_IMAGE #include #endif +#include using namespace std; @@ -48,6 +49,7 @@ typedef std::set::iterator character_iterator; typedef std::set::iterator player_iterator; typedef std::set::iterator monster_iterator; +typedef boost::shared_ptr EmptyAnimationPtr; //Data #define DATA_LVLFPS 6 Modified: trunk/src/events.cpp =================================================================== --- trunk/src/events.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/events.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -52,7 +52,7 @@ delete this; } -AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimation* runanim, bool delanim): +AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim, bool delanim): Event(obj,length,edelay,switchstate), anim(runanim), del(delanim), @@ -74,14 +74,12 @@ } void AnimEvent::end() { if (started && state&ESTATE_ANIM) { - if (del) delete anim; owner->resetAnimState(); } Event::end(); } void AnimEvent::cancel() { if (started && state&ESTATE_ANIM) { - if (del) delete anim; owner->resetAnimState(); } Event::cancel(); @@ -93,7 +91,7 @@ charowner(chr) { } //Exactly the same as AnimEvent with Character* instead of Object* -CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimation* runanim, bool delanim): +CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim, bool delanim): CEvent(chr,length,edelay,switchstate), anim(runanim), del(delanim), @@ -115,21 +113,19 @@ } void CAnimEvent::end() { if (started && state&ESTATE_ANIM) { - if (del) delete anim; charowner->resetAnimState(); } CEvent::end(); } void CAnimEvent::cancel() { if (started && state&ESTATE_ANIM) { - if (del) delete anim; charowner->resetAnimState(); } CEvent::cancel(); } -ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimation* runanim, bool delanim): +ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim, bool delanim): CAnimEvent(chr,length,edelay,(switchstate|STATE_PRESS_LR),esound,runanim,delanim), dmax(edmax), t_reset(0) { @@ -169,7 +165,7 @@ } -EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimation* runanim, bool delanim): +EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim, bool delanim): CAnimEvent(chr,length,edelay,switchstate|ESTATE_BUSY,esound,runanim,delanim), weapon(atweapon), direction(dir), Modified: trunk/src/events.h =================================================================== --- trunk/src/events.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/events.h 2005-09-06 08:24:40 UTC (rev 148) @@ -62,7 +62,7 @@ /// \todo Get rid of the delanim parameter /// \param delanim True if the animation should be deleted AnimEvent(Object* obj, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING, - Mix_Chunk* asound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false); + Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); /// \brief Updates the events /// \return Event state: either delayed (EV_DELAY), starting (EV_START), /// running (EV_RUN), stopping (EV_END) or canceled (EV_CANCEL) @@ -71,7 +71,7 @@ virtual void end(); virtual void cancel(); protected: - EmptyAnimation* anim; + EmptyAnimationPtr anim; bool del; Mix_Chunk* sound; }; @@ -83,13 +83,13 @@ class CAnimEvent : public CEvent { public: CAnimEvent(Character* chr, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING, - Mix_Chunk* asound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false); + Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); virtual Uint16 update(Uint16 dt); virtual void start(); virtual void end(); virtual void cancel(); protected: - EmptyAnimation* anim; + EmptyAnimationPtr anim; bool del; Mix_Chunk* sound; }; @@ -116,7 +116,7 @@ /// \param delanim True if the animation should be deleted EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weapon_range=0, Uint16 target_mask=NOTHING, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL, - EmptyAnimation* runanim=NULL, bool delanim=false); + EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); virtual void end(); protected: Weapon* weapon; @@ -134,7 +134,7 @@ public: /// Adds the initial speed ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay=0, - Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimation* runanim=NULL, bool delanim=false); + Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); virtual ~ERun(); /// Forces the event to continue virtual void start(); Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/gfxeng.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -24,11 +24,10 @@ shift.x=0; shift.y=0; resize(config.width, config.height); - lifeimage=new Animation(imgcache->loadImage(1,"life.bmp")); + lifeimage.reset(new Animation(imgcache->loadImage(1,"life.bmp"))); } GraphicsEngine::~GraphicsEngine() { - delete lifeimage; if (menubg) SDL_FreeSurface(menubg); SDL_FreeSurface(screen); } Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/gfxeng.h 2005-09-06 08:24:40 UTC (rev 148) @@ -47,8 +47,6 @@ SDL_Surface* menubg; /// player bar SDL_Rect bar; - /// symbol for one life of a player - EmptyAnimation* lifeimage; bool show_bar; bool show_fps; bool show_debug; @@ -58,6 +56,8 @@ Uint8 updatetype; // current shift SDL_Rect shift; + /// symbol for one life of a player + EmptyAnimationPtr lifeimage; protected: /// Draw the background and all objects in the pool. This is a very time /// consuming function... Modified: trunk/src/imgcache.cpp =================================================================== --- trunk/src/imgcache.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/imgcache.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -115,6 +115,17 @@ } SDL_FreeSurface(tmp_surface); } + if (return_image.surface==NULL) { + cout << "Couldn't load the image " << imagename << ": probably failed at setting to display format...." << endl; + //Even the fallback image was not found + if (not_found==imagename) { + quitGame(3); + //Try to load the fallback image... + } else { + std::vector empty_vector; + return loadImage(empty_vector,not_found); + } + } // Nice return statement, isn't it ;-))) return (*(imgcache.insert(make_pair(make_pair(imagename,scale_factor),return_image))).first).second; // Return the existing Image in cache... Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/monsters_common.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -13,7 +13,9 @@ Monster::Monster(string imagename, Sint16 xcord, Sint16 ycord, string pname): Character(imagename,xcord,ycord,pname), Dai(0), - Dattack(0) { + Dattack(0), + anim_left(new EmptyAnimation(&anim_right)), + anim_right(new EmptyAnimation()) { health=1; maxspeedx=50; maxspeedy=0; @@ -21,14 +23,10 @@ otype|=OTYPE_MONSTER; enemy_types|=OTYPE_PLAYER; dense_types|=OTYPE_PLAYER; - anim_left=new EmptyAnimation(&anim_right); - anim_right=new EmptyAnimation(); au_hit=scenario->sndcache->loadWAV("monhit.wav"); } Monster::~Monster() { - delete anim_left; - delete anim_right; } void Monster::addEnter(std::set& aset) { Modified: trunk/src/monsters_common.h =================================================================== --- trunk/src/monsters_common.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/monsters_common.h 2005-09-06 08:24:40 UTC (rev 148) @@ -36,10 +36,10 @@ std::set targets; virtual Hit move(Uint16 dt, bool check=false); //common animations - EmptyAnimation* anim_left; - EmptyAnimation* anim_right; Mix_Chunk* au_hit; Sint16 Dai,Dattack; + EmptyAnimationPtr anim_left; + EmptyAnimationPtr anim_right; }; #endif Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/baleog.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -22,11 +22,6 @@ au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } -Baleog::~Baleog() { - delete anim_sword_left; - delete anim_sword_right; -} - //Baleog1: Sword attack void Baleog::in_sp1() { setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_sword_left : anim_sword_right)); Modified: trunk/src/objects/baleog.h =================================================================== --- trunk/src/objects/baleog.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/baleog.h 2005-09-06 08:24:40 UTC (rev 148) @@ -6,11 +6,10 @@ class Baleog : public Player { public: Baleog(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Baleog"); - virtual ~Baleog(); /// \brief Baleog attacks with a sword virtual void in_sp1(); private: Mix_Chunk* au_sword; - EmptyAnimation* anim_sword_left; - EmptyAnimation* anim_sword_right; + EmptyAnimationPtr anim_sword_left; + EmptyAnimationPtr anim_sword_right; }; Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/erik.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -16,45 +16,45 @@ jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); /* - delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); - delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); - delete anim_land_left; anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_land_right; anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_crash_left; anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_crash_right; anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); + anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); + anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); */ - delete anim_left; anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); - delete anim_right; anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); - delete anim_rock_left; anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD); - delete anim_rock_right; anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD); - delete anim_walk_left; anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD); - delete anim_walk_right; anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD); - delete anim_push_left; anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD); - delete anim_push_right; anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD); - delete anim_fall_middle; anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); - delete anim_fall_left; anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD); - delete anim_fall_right; anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); - delete anim_fall_fast_left; anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); - delete anim_fall_fast_right; anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); - delete anim_land_left; anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_land_right; anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_crash_left; anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_crash_right; anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_rope_left; anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); - delete anim_rope_right; anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); - delete anim_teleport_left; anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_teleport_right; anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_die_crash_left; anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_die_crash_right; anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_die_burn_left; anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_die_burn_right; anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_die_bones_left; anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_die_bones_right; anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_die_elec_left; anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_die_elec_right; anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_die_spike_left; anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - delete anim_die_spike_right; anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - delete anim_bar; anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); + anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); + anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); + anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD); + anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD); + anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD); + anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD); + anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD); + anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD); + anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); + anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD); + anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); + anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); + anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); + anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); + anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); + anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ anim_erik_jump_left=loadAnimation("erik_jump_left",config.lvlscale,BP_RD,ATYPE_ONCE); @@ -74,8 +74,6 @@ au_hit=scenario->sndcache->loadWAV("erikhit.wav"); au_run=NULL; } -Erik::~Erik() { -} void Erik::idle(Uint16 dt) { Player::idle(dt); Modified: trunk/src/objects/erik.h =================================================================== --- trunk/src/objects/erik.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/erik.h 2005-09-06 08:24:40 UTC (rev 148) @@ -14,7 +14,6 @@ class Erik : public Player { public: Erik(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Erik"); - virtual ~Erik(); virtual void idle(Uint16); /// \brief Erik jumps virtual void in_sp1(); @@ -25,18 +24,18 @@ virtual void crash(Uint16 dir); virtual Uint16 hit(Uint16 direction,Weapon& weap); private: - EmptyAnimation* anim_erik_jump_left; - EmptyAnimation* anim_erik_jump_right; - EmptyAnimation* anim_erik_jump2_left; - EmptyAnimation* anim_erik_jump2_right; - EmptyAnimation* anim_erik_start_run_left; - EmptyAnimation* anim_erik_start_run_right; - EmptyAnimation* anim_erik_swim_left; - EmptyAnimation* anim_erik_swim_right; - EmptyAnimation* anim_erik_swim_up_left; - EmptyAnimation* anim_erik_swim_up_right; - EmptyAnimation* anim_erik_hit_water_left; - EmptyAnimation* anim_erik_hit_water_right; + EmptyAnimationPtr anim_erik_jump_left; + EmptyAnimationPtr anim_erik_jump_right; + EmptyAnimationPtr anim_erik_jump2_left; + EmptyAnimationPtr anim_erik_jump2_right; + EmptyAnimationPtr anim_erik_start_run_left; + EmptyAnimationPtr anim_erik_start_run_right; + EmptyAnimationPtr anim_erik_swim_left; + EmptyAnimationPtr anim_erik_swim_right; + EmptyAnimationPtr anim_erik_swim_up_left; + EmptyAnimationPtr anim_erik_swim_up_right; + EmptyAnimationPtr anim_erik_hit_water_left; + EmptyAnimationPtr anim_erik_hit_water_right; Mix_Chunk* au_jump; Mix_Chunk* au_run; Sint16 jump,jump2; Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/fang.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -12,22 +12,18 @@ Player(imagename,xcord,ycord,pname), jump(V_JUMP) { weapon=Weapon(-1,W_STRIKE); - delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); - delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); - delete anim_walk_left; anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); - delete anim_walk_right; anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); - delete anim_crash_left; anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_crash_right; anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); + anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); + anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); + anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8); anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav"); au_jump=scenario->sndcache->loadWAV("fangjump.wav"); } -Fang::~Fang() { - delete anim_claw_left; - delete anim_claw_right; -} void Fang::in_left(Uint16 dt) { Player::in_left(dt); Modified: trunk/src/objects/fang.h =================================================================== --- trunk/src/objects/fang.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/fang.h 2005-09-06 08:24:40 UTC (rev 148) @@ -23,7 +23,6 @@ class Fang : public Player { public: Fang(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Fang"); - virtual ~Fang(); virtual void fall(Uint16); virtual void in_left(Uint16); virtual void in_right(Uint16); @@ -34,8 +33,8 @@ virtual void clearStates(bool reset=false); private: virtual void crash(Uint16 dir=DIR_DOWN); - EmptyAnimation* anim_claw_left; - EmptyAnimation* anim_claw_right; + EmptyAnimationPtr anim_claw_left; + EmptyAnimationPtr anim_claw_right; Mix_Chunk* au_jump; Mix_Chunk* au_claw; Sint16 jump; Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/olaf.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -26,27 +26,15 @@ anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,BP_MD,ATYPE_LOOP,3.5); anim_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); anim_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); - anim_walk_shield_left=new EmptyAnimation(&anim_shield_left); - anim_walk_shield_right=new EmptyAnimation(&anim_shield_right); - anim_fall_shield_left=new EmptyAnimation(&anim_shield_left); - anim_fall_shield_right=new EmptyAnimation(&anim_shield_right); + anim_walk_shield_left.reset(new EmptyAnimation(&anim_shield_left)); + anim_walk_shield_right.reset(new EmptyAnimation(&anim_shield_right)); + anim_fall_shield_left.reset(new EmptyAnimation(&anim_shield_left)); + anim_fall_shield_right.reset(new EmptyAnimation(&anim_shield_right)); au_small=scenario->sndcache->loadWAV("blob.wav"); au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); au_hit=scenario->sndcache->loadWAV("fathit.wav"); } -Olaf::~Olaf() { - delete anim_small_left; - delete anim_small_right; - delete anim_walk_small_left; - delete anim_walk_small_right; - delete anim_walk_shield_left; - delete anim_walk_shield_right; - delete anim_shield_left; - delete anim_shield_right; - delete anim_fall_shield_left; - delete anim_fall_shield_right; -} void Olaf::updateAnimState() { if (state&STATE_SMALL) { @@ -113,16 +101,13 @@ //Are we already small? if ((small && (state&STATE_SMALL)) || ((!small) && (!(state&STATE_SMALL)))) return true; - EmptyAnimation* tmpanim; SDL_Rect tmppos=pos; - if (small) tmpanim=anim_small_left; //Assume both images have the same dimension - else tmpanim=anim_orig; //IDEA: left/right edge instead of bottom? - tmppos.x+=(Sint16)((tmppos.w-tmpanim->getFrameDim().w)/2); - tmppos.y+=tmppos.h-tmpanim->getFrameDim().h; - tmppos.w=tmpanim->getFrameDim().w; - tmppos.h=tmpanim->getFrameDim().h; + tmppos.x+=(Sint16)((tmppos.w-(small ? anim_small_left : anim_orig)->getFrameDim().w)/2); + tmppos.y+=tmppos.h-(small ? anim_small_left : anim_orig)->getFrameDim().h; + tmppos.w=(small ? anim_small_left : anim_orig)->getFrameDim().w; + tmppos.h=(small ? anim_small_left : anim_orig)->getFrameDim().h; if (!(checkMove(tmppos,true).enter&DIR_ALL)) { pos=tmppos; if (small) { Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/olaf.h 2005-09-06 08:24:40 UTC (rev 148) @@ -17,7 +17,6 @@ class Olaf : public Player { public: Olaf(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Olaf"); - virtual ~Olaf(); /// Additionally checks if Olaf is small and how he wears his shield virtual void updateAnimState(); virtual void in_left(Uint16); @@ -41,16 +40,16 @@ /// \return True if successfull inline bool trySmall(bool small); //@{ - EmptyAnimation* anim_small_left; - EmptyAnimation* anim_small_right; - EmptyAnimation* anim_walk_small_left; - EmptyAnimation* anim_walk_small_right; - EmptyAnimation* anim_shield_left; - EmptyAnimation* anim_shield_right; - EmptyAnimation* anim_walk_shield_left; - EmptyAnimation* anim_walk_shield_right; - EmptyAnimation* anim_fall_shield_left; - EmptyAnimation* anim_fall_shield_right; + EmptyAnimationPtr anim_small_left; + EmptyAnimationPtr anim_small_right; + EmptyAnimationPtr anim_walk_small_left; + EmptyAnimationPtr anim_walk_small_right; + EmptyAnimationPtr anim_shield_left; + EmptyAnimationPtr anim_shield_right; + EmptyAnimationPtr anim_walk_shield_left; + EmptyAnimationPtr anim_walk_shield_right; + EmptyAnimationPtr anim_fall_shield_left; + EmptyAnimationPtr anim_fall_shield_right; //@} //@{ Mix_Chunk* au_small; Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/scorch.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -12,18 +12,16 @@ Player(imagename,xcord,ycord,pname), left_wings(SCORCH_MAX_WINGS), wing(V_FLY) { - delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - delete anim_walk_left; anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); - delete anim_walk_right; anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - delete anim_crash_left; anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - delete anim_crash_right; anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); + anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); au_tired=scenario->sndcache->loadWAV("flwings.wav"); au_hit=scenario->sndcache->loadWAV("draghit.wav"); } -Scorch::~Scorch() { -} void Scorch::idle(Uint16 dt) { Player::idle(dt); Modified: trunk/src/objects/scorch.h =================================================================== --- trunk/src/objects/scorch.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/scorch.h 2005-09-06 08:24:40 UTC (rev 148) @@ -17,7 +17,6 @@ class Scorch : public Player { public: Scorch(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Scorch"); - virtual ~Scorch(); virtual void fall(Uint16); /// \brief Scorch uses his wings virtual void idle(Uint16); Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/zombie.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -15,14 +15,11 @@ au_attack(scenario->sndcache->loadWAV("clang.wav")), T_Attack_Bite(1500) { maxspeedx=80; - delete anim_left; anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); - delete anim_right; anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); + anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); + anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); weapon=Weapon(-1,W_STRIKE); } -Zombie::~Zombie() { -} - void Zombie::idle(Uint16 dt) { Character::idle(dt); runAI(dt); Modified: trunk/src/objects/zombie.h =================================================================== --- trunk/src/objects/zombie.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects/zombie.h 2005-09-06 08:24:40 UTC (rev 148) @@ -9,7 +9,6 @@ class Zombie : public Monster { public: Zombie(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Zombie"); - virtual ~Zombie(); virtual void idle(Uint16); private: virtual void runAI(Uint16); Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects_common.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -12,8 +12,8 @@ event(NULL), otype(NOTHING), name(oname), - delete_flag(false) { - anim_orig=loadAnimation(scenario->imgcache->loadImage(1,imagename)); + delete_flag(false), + anim_orig(loadAnimation(scenario->imgcache->loadImage(1,imagename))) { animation=anim_orig; pos=animation->getFrameDim(); pos.x=xcord; @@ -23,7 +23,6 @@ Object::~Object() { if (event) event->cancel(); - if (!(otype&OTYPE_CHARACTER)) delete animation; } bool Object::operator<(const Object& obj) const { @@ -59,13 +58,12 @@ return ok; } -EmptyAnimation* Object::loadAnimation(string anim_name, - double scale_factor, - BasePointType abp_type, - Uint16 aanimation_type, - double afps, - AllignType aallign_type) { - +EmptyAnimationPtr Object::loadAnimation(string anim_name, + double scale_factor, + BasePointType abp_type, + Uint16 aanimation_type, + double afps, + AllignType aallign_type) { /* Parse animation data file */ ifstream file; string tmpline; @@ -74,7 +72,7 @@ file.open(loadfile.c_str()); if (!file) { cout << "Failed to open the animation data file: " << loadfile << " => Couldn't load " << anim_name << " animation!\n" << endl; - return new EmptyAnimation(); + return EmptyAnimationPtr(new EmptyAnimation()); } else { string arg1,arg2,arg3,arg4,arg5,arg6; string tmp_anim_name=""; @@ -115,17 +113,17 @@ } } cout << "Animation " << anim_name << " not found!" << endl; - return new EmptyAnimation(); + return EmptyAnimationPtr(new EmptyAnimation()); } -EmptyAnimation* Object::loadAnimation(const Image& abase_image, - Uint16 aframes, - BasePointType abp_type, - Uint16 aanimation_type, - double afps, - Uint16 astart_pos, - AllignType aallign_type) { - EmptyAnimation* anim=new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type); +EmptyAnimationPtr Object::loadAnimation(const Image& abase_image, + Uint16 aframes, + BasePointType abp_type, + Uint16 aanimation_type, + double afps, + Uint16 astart_pos, + AllignType aallign_type) { + EmptyAnimationPtr anim(new Animation(abase_image,aframes,abp_type,aanimation_type,afps,astart_pos,aallign_type)); anim->setBasePos(&pos); return anim; } @@ -139,7 +137,7 @@ bool Object::updateAnim(Uint16 dt) { return (animation->updateAnim(dt)); } -bool Object::setAnim(EmptyAnimation* anim, bool start) { +bool Object::setAnim(EmptyAnimationPtr anim, bool start) { if (anim && anim->isValid()) { animation=anim; if (start) { Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/objects_common.h 2005-09-06 08:24:40 UTC (rev 148) @@ -88,7 +88,7 @@ /// and starts it right away. Should not be used with updateAnimState, /// set ESTATE_ANIM to deactivate an updateAnimState. This is usually /// controlled by an AnimationEvent - bool setAnim(EmptyAnimation* anim, bool start=false); + bool setAnim(EmptyAnimationPtr anim, bool start=false); /// Sets the animation back to the default one. virtual void resetAnimState(); bool isRunning() const; @@ -106,20 +106,20 @@ } //@} /// Load an animation bound onto this object from an animation data file - EmptyAnimation* loadAnimation(string anim_name, - double scale_factor=1, - BasePointType abp_type=BP_MD, - Uint16 aanimation_type=ATYPE_LOOP, - double afps=0, - AllignType aallign_type=AT_MD); + EmptyAnimationPtr loadAnimation(string anim_name, + double scale_factor=1, + BasePointType abp_type=BP_MD, + Uint16 aanimation_type=ATYPE_LOOP, + double afps=0, + AllignType aallign_type=AT_MD); /// Load an animation bound onto this object - EmptyAnimation* loadAnimation(const Image& abase_image, - Uint16 aframes=1, - BasePointType abp_type=BP_MD, - Uint16 aanimation_type=ATYPE_LOOP, - double afps=0, - Uint16 astart_pos=0, - AllignType aallign_type=AT_MD); + EmptyAnimationPtr loadAnimation(const Image& abase_image, + Uint16 aframes=1, + BasePointType abp_type=BP_MD, + Uint16 aanimation_type=ATYPE_LOOP, + double afps=0, + Uint16 astart_pos=0, + AllignType aallign_type=AT_MD); //Events (triggered animations/effects) //@{ /// Clears the event field (sets it to NULL). This should only be used by @@ -179,8 +179,6 @@ protected: Uint32 state; Event* event; - EmptyAnimation* anim_orig; - EmptyAnimation* animation; ///\todo Document this! /// Upper left logical position of the object (used for decisions) SDL_Rect pos; @@ -190,6 +188,8 @@ string name; //delete me flag bool delete_flag; + EmptyAnimationPtr anim_orig; + EmptyAnimationPtr animation; }; /** \brief Item Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-05 21:53:57 UTC (rev 147) +++ trunk/src/players_common.cpp 2005-09-06 08:24:40 UTC (rev 148) @@ -15,7 +15,42 @@ Player::Player(string imagename, Sint16 xcord, Sint16 ycord, string pname): Character(imagename,xcord,ycord,pname), - currentitem(0) { + currentitem(0), + anim_left(new EmptyAnimation(&anim_right)), + anim_right(new EmptyAnimation()), + anim_rock_left(new EmptyAnimation(&anim_left)), + anim_rock_right(new EmptyAnimation(&anim_right)), + anim_walk_left(new EmptyAnimation(&anim_left)), + anim_walk_right(new EmptyAnimation(&anim_right)), + anim_push_left(new EmptyAnimation(&anim_left)), + anim_push_right(new EmptyAnimation(&anim_right)), + anim_fall_left(new EmptyAnimation(&anim_left)), + anim_fall_right(new EmptyAnimation(&anim_right)), + anim_fall_fast_left(new EmptyAnimation(&anim_fall_left)), + anim_fall_fast_right(new EmptyAnimation(&anim_fall_right)), + anim_land_left(new EmptyAnimation()), + anim_land_right(new EmptyAnimation()), + anim_crash_left(new EmptyAnimation()), + anim_crash_right(new EmptyAnimation()), + anim_rope_left(new EmptyAnimation(&anim_left)), + anim_rope_right(new EmptyAnimation(&anim_right)), + anim_teleport_left(new EmptyAnimation()), + anim_teleport_right(new EmptyAnimation()), + anim_die_crash_left(new EmptyAnimation(&anim_die_bones_left)), + anim_die_crash_right(new EmptyAnimation(&anim_die_bones_right)), + anim_die_burn_left(new EmptyAnimation(&anim_die_bones_left)), + anim_die_burn_right(new EmptyAnimation(&anim_die_bones_right)), + anim_die_bones_left(new EmptyAnimation(&anim_die_bones_right)), + anim_die_bones_right(new EmptyAnimation()), + anim_die_elec_left(new EmptyAnimation(&anim_die_bones_left)), + anim_die_elec_right(new EmptyAnimation(&anim_die_bones_right)), + anim_die_spike_left(new EmptyAnimation(&anim_die_bones_left)), + anim_die_spike_right(new EmptyAnimation(&anim_die_bones_right)), + anim_die_water_left(new EmptyAnimation(&anim_die_bones_left)), + anim_die_water_right(new EmptyAnimation(&anim_die_bones_right)), + anim_fall_middle(new EmptyAnimation(&anim_fall_right)), + anim_climb(new EmptyAnimation(&anim_right)), + anim_bar(new EmptyAnimation(&anim_right)) { health=3; maxhealth=4; maxspeedx=300; @@ -26,41 +61,6 @@ state=STATE_FALL; otype|=OTYPE_PLAYER; enemy_types|=OTYPE_MONSTER; - anim_left=new EmptyAnimation(&anim_right); - anim_right=new EmptyAnimation(); - anim_rock_left=new EmptyAnimation(&anim_left); - anim_rock_right=new EmptyAnimation(&anim_right); - anim_walk_left=new EmptyAnimation(&anim_left); - anim_walk_right=new EmptyAnimation(&anim_right); - anim_push_left=new EmptyAnimation(&anim_left); - anim_push_right=new EmptyAnimation(&anim_right); - anim_fall_left=new EmptyAnimation(&anim_left); - anim_fall_right=new EmptyAnimation(&anim_right); - anim_fall_fast_left=new EmptyAnimation(&anim_fall_left); - anim_fall_fast_right=new EmptyAnimation(&anim_fall_right); - anim_land_left=new EmptyAnimation(); - anim_land_right=new EmptyAnimation(); - anim_crash_left=new EmptyAnimation(); - anim_crash_right=new EmptyAnimation(); - anim_rope_left=new EmptyAnimation(&anim_left); - anim_rope_right=new EmptyAnimation(&anim_right); - anim_teleport_left=new EmptyAnimation(); - anim_teleport_right=new EmptyAnimation(); - anim_die_crash_left=new EmptyAnimation(&anim_die_bones_left); - anim_die_crash_right=new EmptyAnimation(&anim_die_bones_right); - anim_die_burn_left=new EmptyAnimation(&anim_die_bones_left); - anim_die_burn_right=new EmptyAnimation(&anim_die_bones_right); - anim_die_bones_left=new EmptyAnimation(&anim_die_bones_right); - anim_die_bones_right=new EmptyAnimation(); - anim_die_elec_left=new EmptyAnimation(&anim_die_bones_left); - anim_die_elec_right=new EmptyAnimation(&anim_die_bones_right); - anim_die_spike_left=new EmptyAnimation(&anim_die_bones_left); - anim_die_spike_right=new EmptyAnimation(&anim_die_bones_right); - anim_die_water_left=new EmptyAnimation(&anim_die_bones_left); - anim_die_water_right=new EmptyAnimation(&anim_die_bones_right); - anim_fall_middle=new EmptyAnimation(&anim_fall_right); - anim_climb=new EmptyAnimation(&anim_right); - anim_bar=new EmptyAnimation(&anim_right); au_land=scenario->sndcache->loadWAV("dizzy.wav"); au_act=scenario->sndcache->loadWAV("button.wav"); au_useerror=scenario->sndcache->loadWAV("useerror.wav"); @@ -74,41 +74,6 @@ } Player::~Player() { - delete anim_left; - delete anim_right; - delete anim_rock_left; - delete anim_rock_right; - delete anim_walk_left; - delete anim_walk_right; - delete anim_push_left; - delete anim_push_right; - delete anim_fall_left; - delete anim_fall_right; - delete anim_fall_fast_left; - delete anim_fall_fast_right; - delete anim_land_left; - delete anim_land_right; - delete anim_crash_left; - delete anim_crash_right; - delete anim_rope_left; - delete anim_rope_right; - delete anim_teleport_left; - delete anim_teleport_right; - delete anim_die_crash_left; - delete anim_die_crash_right; - delete anim_die_burn_left; - delete anim_die_burn_right; - delete anim_die_bones_left; - delete anim_die_bones_right; - delete anim_die_elec_left; - delete anim_die_elec_right; - delete anim_die_spike_left; - delete anim_die_spike_right; - delete anim_die_water_left; - delete anim_die_water_right; - delete anim_fall_middle; - delete anim_climb; - delete anim_bar; for (Uint8 i=0; i Author: jonas Date: 2005-09-06 04:34:41 -0400 (Tue, 06 Sep 2005) New Revision: 149 Modified: trunk/TODO trunk/src/events.cpp trunk/src/events.h trunk/src/players_common.cpp Log: removed the delanim parameter of all AnimationEvents, fixed the switchPlayer bug Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-06 08:24:40 UTC (rev 148) +++ trunk/TODO 2005-09-06 08:34:41 UTC (rev 149) @@ -2,7 +2,6 @@ ==== o rewrite zombie (bug in movement!, attacks too often, use events, etc...) o memleaks, segfaults? - o left/right move + switchPlayer (keeps moving) o key vs. trigger in map2 o fall event (DONE?) o left/right fallback? Modified: trunk/src/events.cpp =================================================================== --- trunk/src/events.cpp 2005-09-06 08:24:40 UTC (rev 148) +++ trunk/src/events.cpp 2005-09-06 08:34:41 UTC (rev 149) @@ -52,10 +52,9 @@ delete this; } -AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim, bool delanim): +AnimEvent::AnimEvent(Object* obj, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim): Event(obj,length,edelay,switchstate), anim(runanim), - del(delanim), sound(asound) { if (anim && anim->isValid()) { state|=ESTATE_ANIM; @@ -91,10 +90,9 @@ charowner(chr) { } //Exactly the same as AnimEvent with Character* instead of Object* -CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim, bool delanim): +CAnimEvent::CAnimEvent(Character* chr, Uint16 length, Uint16 edelay, Uint32 switchstate, Mix_Chunk* asound, EmptyAnimationPtr runanim): CEvent(chr,length,edelay,switchstate), anim(runanim), - del(delanim), sound(asound) { if (anim && anim->isValid()) { state|=ESTATE_ANIM; @@ -125,8 +123,8 @@ } -ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim, bool delanim): - CAnimEvent(chr,length,edelay,(switchstate|STATE_PRESS_LR),esound,runanim,delanim), +ERun::ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim): + CAnimEvent(chr,length,edelay,(switchstate|STATE_PRESS_LR),esound,runanim), dmax(edmax), t_reset(0) { charowner->setState(STATE_RUN); @@ -165,8 +163,8 @@ } -EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim, bool delanim): - CAnimEvent(chr,length,edelay,switchstate|ESTATE_BUSY,esound,runanim,delanim), +EAttack::EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weap_range, Uint16 target_mask, Uint16 edelay, Uint32 switchstate, Mix_Chunk* esound, EmptyAnimationPtr runanim): + CAnimEvent(chr,length,edelay,switchstate|ESTATE_BUSY,esound,runanim), weapon(atweapon), direction(dir), range(weap_range), Modified: trunk/src/events.h =================================================================== --- trunk/src/events.h 2005-09-06 08:24:40 UTC (rev 148) +++ trunk/src/events.h 2005-09-06 08:34:41 UTC (rev 149) @@ -60,9 +60,8 @@ /// \param asound Sound (Mix_Chunk) to be played when the event starts /// \param runanim Animation to be run when the event starts /// \todo Get rid of the delanim parameter - /// \param delanim True if the animation should be deleted AnimEvent(Object* obj, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING, - Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); + Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr()); /// \brief Updates the events /// \return Event state: either delayed (EV_DELAY), starting (EV_START), /// running (EV_RUN), stopping (EV_END) or canceled (EV_CANCEL) @@ -72,7 +71,6 @@ virtual void cancel(); protected: EmptyAnimationPtr anim; - bool del; Mix_Chunk* sound; }; @@ -83,14 +81,13 @@ class CAnimEvent : public CEvent { public: CAnimEvent(Character* chr, Uint16 length, Uint16 edelay=0, Uint32 switchstate=NOTHING, - Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); + Mix_Chunk* asound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr()); virtual Uint16 update(Uint16 dt); virtual void start(); virtual void end(); virtual void cancel(); protected: EmptyAnimationPtr anim; - bool del; Mix_Chunk* sound; }; @@ -112,11 +109,9 @@ /// \param switchstate States that will be switched when the animation starts/ends /// \param esound Sound (Mix_Chunk) to be played when the event starts /// \param runanim Animation to be run when the event starts - /// \todo Get rid of the delanim parameter - /// \param delanim True if the animation should be deleted EAttack(Character* chr, Uint16 length, Weapon* atweapon, Uint16 dir, Uint16 weapon_range=0, Uint16 target_mask=NOTHING, Uint16 edelay=0, Uint32 switchstate=0, Mix_Chunk* esound=NULL, - EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); + EmptyAnimationPtr runanim=EmptyAnimationPtr()); virtual void end(); protected: Weapon* weapon; @@ -134,7 +129,7 @@ public: /// Adds the initial speed ERun(Character* chr, Uint16 length, Sint16 edmax, Uint16 edelay=0, - Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr(), bool delanim=false); + Uint32 switchstate=0, Mix_Chunk* esound=NULL, EmptyAnimationPtr runanim=EmptyAnimationPtr()); virtual ~ERun(); /// Forces the event to continue virtual void start(); Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-06 08:24:40 UTC (rev 148) +++ trunk/src/players_common.cpp 2005-09-06 08:34:41 UTC (rev 149) @@ -297,6 +297,8 @@ unsetState(STATE_ACT_2); unsetState(STATE_ACT_3); } + unsetState(STATE_MLEFT); + unsetState(STATE_MRIGHT); } Uint16 Player::hit(Uint16 direction, Weapon& weap) { From DONOTREPLY at icculus.org Tue Sep 6 05:34:31 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 05:34:31 -0400 Subject: r150 - in trunk/src: . objects Message-ID: <20050906093431.13612.qmail@icculus.org> Author: jonas Date: 2005-09-06 05:34:31 -0400 (Tue, 06 Sep 2005) New Revision: 150 Modified: trunk/src/objects/erik.cpp trunk/src/objects/erik.h trunk/src/players_common.cpp trunk/src/players_common.h Log: a few additional erik animations, removed anim_land_[left|right] Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-06 08:34:41 UTC (rev 149) +++ trunk/src/objects/erik.cpp 2005-09-06 09:34:31 UTC (rev 150) @@ -36,8 +36,6 @@ anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); - anim_land_left=loadAnimation("erik_land_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_land_right=loadAnimation("erik_land_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); @@ -63,6 +61,8 @@ anim_erik_jump2_right=loadAnimation("erik_jump2_right",config.lvlscale,BP_LD,ATYPE_ONCE); anim_erik_start_run_left=loadAnimation("erik_start_run_left",config.lvlscale,BP_RD,ATYPE_ONCE); anim_erik_start_run_right=loadAnimation("erik_start_run_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_erik_run_left=loadAnimation("erik_run_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_erik_run_right=loadAnimation("erik_run_right",config.lvlscale,BP_LD,ATYPE_ONCE); anim_erik_swim_left=loadAnimation("erik_swim_left",config.lvlscale,BP_RD,ATYPE_ONCE); anim_erik_swim_right=loadAnimation("erik_swim_right",config.lvlscale,BP_LD,ATYPE_ONCE); anim_erik_swim_up_left=loadAnimation("erik_swim_up_left",config.lvlscale,BP_RD,ATYPE_ONCE); @@ -91,7 +91,7 @@ if (state&(STATE_MLEFT|STATE_MRIGHT)) { if (state&STATE_MRIGHT) run_right=true; else run_right=false; - setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run)); + setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,(state&STATE_LEFT) ? anim_erik_run_left : anim_erik_run_right)); } } } @@ -104,11 +104,11 @@ } else if (state&STATE_ACT_1) { setState(STATE_ACT_2); addSpeed(jump2); - setEvent(new CAnimEvent(this,DE_JUMP,0,0,au_jump)); + setEvent(new CAnimEvent(this,DE_JUMP,0,ESTATE_ABORT,au_jump,(state&STATE_LEFT) ? anim_erik_jump2_left : anim_erik_jump2_right)); } else { setState(STATE_ACT_1); addSpeed(jump); - setEvent(new CAnimEvent(this,DE_JUMP)); + setEvent(new CAnimEvent(this,DE_JUMP,0,ESTATE_ABORT,NULL,(state&STATE_LEFT) ? anim_erik_jump_left : anim_erik_jump_right)); } } @@ -117,7 +117,7 @@ if (state&(STATE_MLEFT|STATE_MRIGHT)) { if (state&STATE_MRIGHT) run_right=true; else run_right=false; - setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run)); + setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,(state&STATE_LEFT) ? anim_erik_run_left : anim_erik_run_right)); } } Modified: trunk/src/objects/erik.h =================================================================== --- trunk/src/objects/erik.h 2005-09-06 08:34:41 UTC (rev 149) +++ trunk/src/objects/erik.h 2005-09-06 09:34:31 UTC (rev 150) @@ -30,6 +30,8 @@ EmptyAnimationPtr anim_erik_jump2_right; EmptyAnimationPtr anim_erik_start_run_left; EmptyAnimationPtr anim_erik_start_run_right; + EmptyAnimationPtr anim_erik_run_left; + EmptyAnimationPtr anim_erik_run_right; EmptyAnimationPtr anim_erik_swim_left; EmptyAnimationPtr anim_erik_swim_right; EmptyAnimationPtr anim_erik_swim_up_left; Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-06 08:34:41 UTC (rev 149) +++ trunk/src/players_common.cpp 2005-09-06 09:34:31 UTC (rev 150) @@ -28,8 +28,6 @@ anim_fall_right(new EmptyAnimation(&anim_right)), anim_fall_fast_left(new EmptyAnimation(&anim_fall_left)), anim_fall_fast_right(new EmptyAnimation(&anim_fall_right)), - anim_land_left(new EmptyAnimation()), - anim_land_right(new EmptyAnimation()), anim_crash_left(new EmptyAnimation()), anim_crash_right(new EmptyAnimation()), anim_rope_left(new EmptyAnimation(&anim_left)), @@ -280,7 +278,9 @@ speed=0; Weapon tmpweap(-1,W_PRESSURE,WS_PRESSURE); hit(DIR_UP,tmpweap); - } else speed=0; + } else { + speed=0; + } break; } } Modified: trunk/src/players_common.h =================================================================== --- trunk/src/players_common.h 2005-09-06 08:34:41 UTC (rev 149) +++ trunk/src/players_common.h 2005-09-06 09:34:31 UTC (rev 150) @@ -142,8 +142,6 @@ EmptyAnimationPtr anim_fall_right; EmptyAnimationPtr anim_fall_fast_left; EmptyAnimationPtr anim_fall_fast_right; - EmptyAnimationPtr anim_land_left; - EmptyAnimationPtr anim_land_right; EmptyAnimationPtr anim_crash_left; EmptyAnimationPtr anim_crash_right; EmptyAnimationPtr anim_rope_left; From DONOTREPLY at icculus.org Tue Sep 6 07:07:57 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 07:07:57 -0400 Subject: r151 - in trunk: . src src/objects Message-ID: <20050906110757.21751.qmail@icculus.org> Author: jonas Date: 2005-09-06 07:07:57 -0400 (Tue, 06 Sep 2005) New Revision: 151 Modified: trunk/TODO trunk/src/common.cpp trunk/src/objects/baleog.cpp trunk/src/objects/baleog.h trunk/src/objects/erik.cpp trunk/src/objects/erik.h trunk/src/objects/fang.cpp trunk/src/objects/fang.h trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/scorch.cpp trunk/src/objects/scorch.h trunk/src/objects/zombie.cpp trunk/src/objects/zombie.h Log: enable debug with -DEBUG, added destructors again => fixes bug Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/TODO 2005-09-06 11:07:57 UTC (rev 151) @@ -4,7 +4,6 @@ o memleaks, segfaults? o key vs. trigger in map2 o fall event (DONE?) - o left/right fallback? o players die event segfault (eg. olaf) @@ -24,8 +23,16 @@ concrete class depending on the game_mode instead of using if... o Move/Fall/push/crash/collisions: - o the character should have more information what he hits - o IDEA: movements into dense objects should involve a push() + o move should be a property of a common object + o Hit should give either much more information or all logic should be done inside + move (BAD) + o collision reactions should depend on the corresponding types and whether we + already are near the object or not => getCollisionType(obj1,obj2)? + o First priority (first run): find out where the object will move to (HARD) + => add a bool notchange parameter and pass it on to all actions + o movement into a movable object should just move the object + o if the movement is "forced" the moved object should be hit hard when it collides + otherwise a hit would stop the moving object as well... -> I have no idea about how the push should look like, elevators can be pushed up, even though you don't collide with them on top -> characters should be "pushable", eg. a stone that falls down pushes the @@ -82,9 +89,9 @@ o Monsters / AI: VERY BAD o Game functionality (): BAD + o Events / Effects: BAD, MESS o Object (including parameter) loading: BAD - o Move logic: BAD, BUGGED, MESS - o Events / Effects: BAD, MESS + o Move logic: ACCEPTABLE, BUGGED o Objects (players, items, etc): ACCEPTABLE o Input Handler: ACCEPTABLE, WORKS o Collision detection: OK Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/common.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -51,6 +51,9 @@ gfxeng->unsetShowDebug(); SDL_ShowCursor(SDL_DISABLE); } +#ifdef DEBUG + gfxeng->setShowDebug(); +#endif } void addGameMode(Uint8 addmode) { Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/baleog.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -22,6 +22,8 @@ au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } +Baleog::~Baleog() { } + //Baleog1: Sword attack void Baleog::in_sp1() { setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_sword_left : anim_sword_right)); Modified: trunk/src/objects/baleog.h =================================================================== --- trunk/src/objects/baleog.h 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/baleog.h 2005-09-06 11:07:57 UTC (rev 151) @@ -6,6 +6,7 @@ class Baleog : public Player { public: Baleog(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Baleog"); + virtual ~Baleog(); /// \brief Baleog attacks with a sword virtual void in_sp1(); private: Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/erik.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -36,8 +36,8 @@ anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); - anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); + anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); @@ -75,6 +75,8 @@ au_run=NULL; } +Erik::~Erik() { } + void Erik::idle(Uint16 dt) { Player::idle(dt); //TODO: this is an ugly hack... Modified: trunk/src/objects/erik.h =================================================================== --- trunk/src/objects/erik.h 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/erik.h 2005-09-06 11:07:57 UTC (rev 151) @@ -14,6 +14,7 @@ class Erik : public Player { public: Erik(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Erik"); + virtual ~Erik(); virtual void idle(Uint16); /// \brief Erik jumps virtual void in_sp1(); Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/fang.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -25,6 +25,8 @@ au_jump=scenario->sndcache->loadWAV("fangjump.wav"); } +Fang::~Fang() { } + void Fang::in_left(Uint16 dt) { Player::in_left(dt); unsetState(STATE_CLIMB_R); Modified: trunk/src/objects/fang.h =================================================================== --- trunk/src/objects/fang.h 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/fang.h 2005-09-06 11:07:57 UTC (rev 151) @@ -23,6 +23,7 @@ class Fang : public Player { public: Fang(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Fang"); + virtual ~Fang(); virtual void fall(Uint16); virtual void in_left(Uint16); virtual void in_right(Uint16); Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/olaf.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -36,6 +36,8 @@ au_hit=scenario->sndcache->loadWAV("fathit.wav"); } +Olaf::~Olaf() { } + void Olaf::updateAnimState() { if (state&STATE_SMALL) { if (state&STATE_LEFT) { Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/olaf.h 2005-09-06 11:07:57 UTC (rev 151) @@ -17,6 +17,7 @@ class Olaf : public Player { public: Olaf(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Olaf"); + virtual ~Olaf(); /// Additionally checks if Olaf is small and how he wears his shield virtual void updateAnimState(); virtual void in_left(Uint16); Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/scorch.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -23,6 +23,8 @@ au_hit=scenario->sndcache->loadWAV("draghit.wav"); } +Scorch::~Scorch() { } + void Scorch::idle(Uint16 dt) { Player::idle(dt); if (!input->keyState(KEY_SP1)) { Modified: trunk/src/objects/scorch.h =================================================================== --- trunk/src/objects/scorch.h 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/scorch.h 2005-09-06 11:07:57 UTC (rev 151) @@ -17,6 +17,7 @@ class Scorch : public Player { public: Scorch(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Scorch"); + virtual ~Scorch(); virtual void fall(Uint16); /// \brief Scorch uses his wings virtual void idle(Uint16); Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/zombie.cpp 2005-09-06 11:07:57 UTC (rev 151) @@ -20,6 +20,8 @@ weapon=Weapon(-1,W_STRIKE); } +Zombie::~Zombie() { } + void Zombie::idle(Uint16 dt) { Character::idle(dt); runAI(dt); Modified: trunk/src/objects/zombie.h =================================================================== --- trunk/src/objects/zombie.h 2005-09-06 09:34:31 UTC (rev 150) +++ trunk/src/objects/zombie.h 2005-09-06 11:07:57 UTC (rev 151) @@ -9,6 +9,7 @@ class Zombie : public Monster { public: Zombie(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Zombie"); + virtual ~Zombie(); virtual void idle(Uint16); private: virtual void runAI(Uint16); From DONOTREPLY at icculus.org Tue Sep 6 07:37:46 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 07:37:46 -0400 Subject: r152 - trunk/src/objects Message-ID: <20050906113746.24012.qmail@icculus.org> Author: jonas Date: 2005-09-06 07:37:46 -0400 (Tue, 06 Sep 2005) New Revision: 152 Modified: trunk/src/objects/erik.cpp trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h Log: improved erik's run handling, added private members to olaf to save the different base positions Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-06 11:07:57 UTC (rev 151) +++ trunk/src/objects/erik.cpp 2005-09-06 11:37:46 UTC (rev 152) @@ -116,11 +116,6 @@ void Erik::in_sp2() { //TODO: check STATE_WATER - if (state&(STATE_MLEFT|STATE_MRIGHT)) { - if (state&STATE_MRIGHT) run_right=true; - else run_right=false; - setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,(state&STATE_LEFT) ? anim_erik_run_left : anim_erik_run_right)); - } } void Erik::in_left(Uint16 dt) { @@ -128,6 +123,9 @@ if (state&STATE_LEFT) event->reset(); //changed directions, TODO: play decelerate animation else cancelEvent(); + } else if (input->keyState(KEY_SP2)) { + run_right=false; + setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,anim_erik_run_left)); } Player::in_left(dt); } @@ -137,6 +135,9 @@ if (!(state&STATE_LEFT)) event->reset(); //changed directions, TODO: play decelerate animation else cancelEvent(); + } else if (input->keyState(KEY_SP2)) { + run_right=true; + setEvent(new ERun(this,10000,maxspeedx,500,ESTATE_ABORT,au_run,anim_erik_run_right)); } Player::in_right(dt); } Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-06 11:07:57 UTC (rev 151) +++ trunk/src/objects/olaf.cpp 2005-09-06 11:37:46 UTC (rev 152) @@ -34,6 +34,8 @@ au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); au_hit=scenario->sndcache->loadWAV("fathit.wav"); + normal_size=anim_orig->getFrameDim(); + small_size=anim_small_right->getFrameDim(); } Olaf::~Olaf() { } @@ -106,10 +108,10 @@ SDL_Rect tmppos=pos; //Assume both images have the same dimension //IDEA: left/right edge instead of bottom? - tmppos.x+=(Sint16)((tmppos.w-(small ? anim_small_left : anim_orig)->getFrameDim().w)/2); - tmppos.y+=tmppos.h-(small ? anim_small_left : anim_orig)->getFrameDim().h; - tmppos.w=(small ? anim_small_left : anim_orig)->getFrameDim().w; - tmppos.h=(small ? anim_small_left : anim_orig)->getFrameDim().h; + tmppos.x+=(Sint16)((tmppos.w-(small ? small_size.w : normal_size.w))/2); + tmppos.y+=tmppos.h-(small ? small_size.h : normal_size.h); + tmppos.w=(small ? small_size.w : normal_size.w); + tmppos.h=(small ? small_size.h : normal_size.h); if (!(checkMove(tmppos,true).enter&DIR_ALL)) { pos=tmppos; if (small) { Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-06 11:07:57 UTC (rev 151) +++ trunk/src/objects/olaf.h 2005-09-06 11:37:46 UTC (rev 152) @@ -58,4 +58,6 @@ Mix_Chunk* au_fart; //@} Sint16 fart; + SDL_Rect small_size; + SDL_Rect normal_size; }; From DONOTREPLY at icculus.org Tue Sep 6 08:12:40 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 08:12:40 -0400 Subject: r153 - in trunk/src: . objects Message-ID: <20050906121240.26785.qmail@icculus.org> Author: jonas Date: 2005-09-06 08:12:40 -0400 (Tue, 06 Sep 2005) New Revision: 153 Modified: trunk/src/animation.cpp trunk/src/animation.h trunk/src/common.h trunk/src/objects/baleog.cpp trunk/src/objects/erik.cpp trunk/src/objects/fang.cpp trunk/src/objects/olaf.cpp trunk/src/objects/scorch.cpp Log: removed ATYPE_ONCE_END and added a new additional type for ATYPE_ALL_ONCE: ATYPE_ST_SWITCH, it will play the animation and then switch the direction Modified: trunk/src/animation.cpp =================================================================== --- trunk/src/animation.cpp 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/animation.cpp 2005-09-06 12:12:40 UTC (rev 153) @@ -75,7 +75,7 @@ duration=(Uint32)(frames*1000.0/fps+0.5); checkAnim(); } -Animation::~Animation() { is_valid=false; } +Animation::~Animation() { } void Animation::runAnim() { if (!isValid()) { cout << "Starting an invalid animation!" << endl; @@ -95,12 +95,26 @@ if (!isValid()) { cout << "Stopping an invalid animation!" << endl; return is_running=false; - } else if (animation_type&ATYPE_ALL_ONCE) { + } else if (animation_type&ATYPE_ONCE) { is_running=false; cur_time=0; - if (animation_type&ATYPE_ALL_LSTART) { + if (animation_type&ATYPE_ST_SWITCH) { + animation_type&=~ATYPE_ONCE; + animation_type|=ATYPE_ONCE_REV; + checkAnim(); + } else { + forward=true; cur_frame_num=0; + } + } else if (animation_type&ATYPE_ONCE_REV) { + is_running=false; + cur_time=0; + if (animation_type&ATYPE_ST_SWITCH) { + animation_type&=~ATYPE_ONCE_REV; + animation_type|=ATYPE_ONCE; + checkAnim(); } else { + forward=false; cur_frame_num=frames-1; } } @@ -116,7 +130,7 @@ cur_time+=dt; Uint32 durationh=(Uint32)duration/2; - if (animation_type&ATYPE_ONCE || animation_type&ATYPE_ONCE_END) { + if (animation_type&ATYPE_ONCE) { if (cur_time>=duration) { return stopAnim(); } else { @@ -127,7 +141,7 @@ while(cur_time>=duration) cur_time-=duration; } cur_frame_num=(Uint16)(cur_time*frames/duration); - } else if (animation_type&ATYPE_ONCE_REV || animation_type&ATYPE_ONCE_END_REV) { + } else if (animation_type&ATYPE_ONCE_REV) { if (cur_time>=duration) { return stopAnim(); } else { @@ -383,11 +397,13 @@ if (animation_type&ATYPE_ALL_NORMAL) { forward=true; cur_frame_num=0; + base_frame_pos=start_pos; } else { forward=false; cur_frame_num=frames-1; + base_frame_pos=end_pos; } - base_frame=Frame(base_image.surface,base_image.description[(animation_type&ATYPE_ALL_NORMAL) ? start_pos : end_pos]); + base_frame=Frame(base_image.surface,base_image.description[base_frame_pos]); setShift(); } return is_valid; Modified: trunk/src/animation.h =================================================================== --- trunk/src/animation.h 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/animation.h 2005-09-06 12:12:40 UTC (rev 153) @@ -109,10 +109,10 @@ /// Example: BP_MU means the BP is the upper middle point of each frame. /// Default: BP_MD BasePointType bp_type; - /// Animation type: ATYPE_ONCE (play once), ATYPE_ONCE_END (play once and stop at end), - /// ATYPE_LOOP (always play, jump back to the beginning), ATYPE_SWING (always play, - /// reverse direction when finnished). The appended _REV means that the animation is - /// started at the end and played backwards. + /// Animation type: ATYPE_ONCE (play once), ATYPE_LOOP (always play, jump back to + /// the beginning), ATYPE_SWING (always play, reverse direction when finnished), + /// ATYPE_ST_SWITCH (parameter for ATYPE_ALL_ONCE: switch state when finnished). + /// The appended _REV means that the animation is started at the end and played backwards. Uint16 animation_type; /// FPS of the animation double fps; @@ -137,6 +137,8 @@ Sint16 shift_y; /// Duration of the animation in ms Uint32 duration; + /// Position of the base frame + Uint16 base_frame_pos; /// End position from the frame array of the base_image Uint16 end_pos; /// True if the animation consist of one still image (frames=1,still=true) Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/common.h 2005-09-06 12:12:40 UTC (rev 153) @@ -79,20 +79,21 @@ //Animation types #define ATYPE_ONCE 0x00000001 -#define ATYPE_ONCE_END 0x00000002 -#define ATYPE_LOOP 0x00000004 -#define ATYPE_SWING 0x00000008 +#define ATYPE_LOOP 0x00000002 +#define ATYPE_SWING 0x00000004 +#define ATYPE_STEP 0x00000008 #define ATYPE_ONCE_REV 0x00000010 -#define ATYPE_ONCE_END_REV 0x00000020 -#define ATYPE_LOOP_REV 0x00000040 -#define ATYPE_SWING_REV 0x00000080 -#define ATYPE_ALL_ONCE 0x00000033 -#define ATYPE_ALL_LSTART 0x00000021 -#define ATYPE_ALL_LEND 0x00000012 -#define ATYPE_ALL_LOOP 0x00000044 -#define ATYPE_ALL_SWING 0x00000088 +#define ATYPE_LOOP_REV 0x00000020 +#define ATYPE_SWING_REV 0x00000040 +#define ATYPE_STEP_REV 0x00000080 +#define ATYPE_ALL_ONCE 0x00000011 +#define ATYPE_ALL_LOOP 0x00000022 +#define ATYPE_ALL_SWING 0x00000044 #define ATYPE_ALL_NORMAL 0x0000000F #define ATYPE_ALL_REV 0x000000F0 +#define ATYPE_ST_SWITCH 0x00000100 +#define ATYPE_ONCE_S 0x00000101 +#define ATYPE_ONCE_S_REV 0x00000110 //Description formats #define DESC_NONE 0x00000000 Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/objects/baleog.cpp 2005-09-06 12:12:40 UTC (rev 153) @@ -14,11 +14,11 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); weapon=Weapon(-1,W_STRIKE); - anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE_END); - anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE_END); + anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE); + anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE); au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/objects/erik.cpp 2005-09-06 12:12:40 UTC (rev 153) @@ -18,10 +18,10 @@ /* anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); - anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); */ anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); @@ -36,22 +36,22 @@ anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); - anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE); anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); - anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); - anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE_END); - anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE_END); + anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE); + anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE); + anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE); anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/objects/fang.cpp 2005-09-06 12:12:40 UTC (rev 153) @@ -16,8 +16,8 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8); anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/objects/olaf.cpp 2005-09-06 12:12:40 UTC (rev 153) @@ -16,9 +16,9 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE_END,25); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE,25); anim_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1); anim_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),1); Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-06 11:37:46 UTC (rev 152) +++ trunk/src/objects/scorch.cpp 2005-09-06 12:12:40 UTC (rev 153) @@ -16,8 +16,8 @@ anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE_END,calcFPS(1,T_IRR)); + anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); au_tired=scenario->sndcache->loadWAV("flwings.wav"); au_hit=scenario->sndcache->loadWAV("draghit.wav"); From DONOTREPLY at icculus.org Tue Sep 6 08:25:30 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 08:25:30 -0400 Subject: r154 - trunk/src Message-ID: <20050906122530.27669.qmail@icculus.org> Author: jonas Date: 2005-09-06 08:25:30 -0400 (Tue, 06 Sep 2005) New Revision: 154 Modified: trunk/src/players_common.cpp Log: removed the STATE_M* resets on hit. This fixes the flickering when moving into a dense object... Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-06 12:12:40 UTC (rev 153) +++ trunk/src/players_common.cpp 2005-09-06 12:25:30 UTC (rev 154) @@ -254,17 +254,14 @@ if (event) event->cancel(); switch (dir) { case DIR_LEFT: { - unsetState(STATE_MLEFT); hspeed=0; break; } case DIR_RIGHT: { - unsetState(STATE_MRIGHT); hspeed=0; break; } case DIR_UP: { - unsetState(STATE_MUP); speed=0; break; } @@ -272,7 +269,6 @@ case DIR_DOWN: default : { clearStates(true); unsetState(STATE_FALL); - unsetState(STATE_MDOWN); Dgrav=0; if (speed>V_KRIT) { speed=0; From DONOTREPLY at icculus.org Tue Sep 6 10:46:57 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 10:46:57 -0400 Subject: r155 - trunk/src Message-ID: <20050906144657.7220.qmail@icculus.org> Author: jonas Date: 2005-09-06 10:46:56 -0400 (Tue, 06 Sep 2005) New Revision: 155 Modified: trunk/src/Makefile Log: remove -DDEBUG by default Modified: trunk/src/Makefile =================================================================== --- trunk/src/Makefile 2005-09-06 12:25:30 UTC (rev 154) +++ trunk/src/Makefile 2005-09-06 14:46:56 UTC (rev 155) @@ -2,7 +2,7 @@ CXX_FLAGS = -W -Wall -ansi -pedantic CXX_DEBUG = -g #-fno-inline CXX_OPT = #-O2 -march=pentium4 -ffast-math -CXX_GAME = -DSDL_MIXER -DSDL_IMAGE -DALPHA -DDEBUG -I ./ +CXX_GAME = -DSDL_MIXER -DSDL_IMAGE -DALPHA -I ./ SDL = `sdl-config --cflags` SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image -ldl -rdynamic From DONOTREPLY at icculus.org Tue Sep 6 16:16:54 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 6 Sep 2005 16:16:54 -0400 Subject: r156 - in trunk: . src src/objects Message-ID: <20050906201654.16353.qmail@icculus.org> Author: jonas Date: 2005-09-06 16:16:53 -0400 (Tue, 06 Sep 2005) New Revision: 156 Modified: trunk/TODO trunk/src/Makefile trunk/src/common.cpp trunk/src/common.h trunk/src/editor.cpp trunk/src/gfxeng.cpp trunk/src/gfxeng.h trunk/src/input.cpp trunk/src/lost_penguins.cpp trunk/src/menu.cpp trunk/src/objects/Makefile trunk/src/objects/exit.cpp trunk/src/physics.cpp trunk/src/players_common.cpp trunk/src/scenario.cpp trunk/src/scenario.h Log: o Updated TODO o Added toggleShowDebug and KEY_DEBUG (F4) o Added prelimenary Scenario support o Introduced a bool finnished to indicate that the PhysicEngine should finnish the map => Fixes a bug in Exit o Removed the -dl -rdynamic options in the Makefile o startScreen() should always return you back to the main start screen with all settings reseted Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/TODO 2005-09-06 20:16:53 UTC (rev 156) @@ -1,7 +1,6 @@ Bugs ==== - o rewrite zombie (bug in movement!, attacks too often, use events, etc...) - o memleaks, segfaults? + o zombie (bug in movement!, attacks too often, use events, etc...) o key vs. trigger in map2 o fall event (DONE?) o players die event segfault (eg. olaf) @@ -10,19 +9,17 @@ Code ==== - o General: + o General / Interface: o (BIG) move drawing to the objects/menus/etc (create a draw() function)! - o pointers => references where possible - o Describe everything using Doxygen styles, move the documentation from - *.cpp to the headers... - o Idea: _all_ objects should have a "core" like the players (curpos thing) - This would help in many ways and should be a frame information and not an - image as done for players atm! + o pointers => shared_ptr/references where possible + o Complete the doxygen documentation and keep it up-to-date o Use Singletons - o IDEA: Introduce abstract classes for all engines and load the corresponding - concrete class depending on the game_mode instead of using if... + o Create a better class hierarchy so we don't have a class playground... + o Better handle the different game states and replace the current conditional model + o IDEA: Use boost to support better constructors (name loading) + o IDEA: create dynamical plugins for all objects (or compile all in) - o Move/Fall/push/crash/collisions: + o Move/crash/collisions: o move should be a property of a common object o Hit should give either much more information or all logic should be done inside move (BAD) @@ -33,35 +30,44 @@ o movement into a movable object should just move the object o if the movement is "forced" the moved object should be hit hard when it collides otherwise a hit would stop the moving object as well... - -> I have no idea about how the push should look like, elevators can be pushed - up, even though you don't collide with them on top - -> characters should be "pushable", eg. a stone that falls down pushes the - character down or better: an elevator should push the characters up + o I have no idea about how the push should look like, elevators can be pushed + up, even though you don't collide with them on top + o IDEA: characters should be "pushable", eg. a stone that falls down pushes the + character down or better: an elevator should push the characters up o In case of the elevator, the players are somehow "bound" to the elevator (ie. it's not like: the elevator moves, the character falls, but they move together) Solution: The elevators move function checks all objects it would hit, if they are pushable (not dense) they are moved first if possible. If it's not possible, do sthg else (stop the elevator and hit the object/whatever)... + o IMPROVE?: cleanup set_difference stuff => targets should be updated if + an object dies in an intelligent way... + o IDEA: merge otype and ctype and make all moves/etc depend on it + o IDEA (old): Add attributes: + - crushable (ie. weapon fart, jump, run destroys them?) + - bombable (ie. bomb destroys them) + - multistates? => bridges, door, stone block + o REWRITE: the whole crash system!!! o Events/Animations: + o Replace the anim_orig by a base rectangle o Invent more intelligent and more robust! fallback methods for animations o Allow empty animation, decouple (put more logic in) these relations: object (pos, draw?), game(time, state, handler), gfxeng(draw), animation(empty, frame, update, time, draw)?, frame, global/current (public, private) properties - o Make all events quite short, ie. almost all events become animation - events o IDEA: couple left and right animations somehow to reduce the code size - eg. set offsets for left, right, mleft, mright... o IDEA: just store one side and add some flipping logic to the image loading process... - o IDEA: change Animation* pointers to Animation (or references or auto_ptr), - leave only animation as a pointer and get the address each time... - o introduce animation events that play an animation and end when it's - finnished (always ESTATE_BUSY or abort animation?) o allow an event length depending on animation length, or: relate events more with animations!!! + o REWRITE: the whole event system!!! + o Scenario: + o Add some nice animation, text box, etc when a level was completed (including printing + the map name). + o Simplify the scenario class and drastically reduce the public variables!! + o Placement code: o IDEA: allow moves from NULL and/or to NULL o units should be placed in a way they won't give conflicts, examples: @@ -70,37 +76,26 @@ illegaly placed! - the placement should somehow involve checkPlace... - o (Plugins): - o move object creation code (addObjectByName) to the objects - o create dynamical plugins for all objects (or compile all in) - o Ideas/Improvements: - o IMPROVE?: cleanup set_difference stuff => targets should be updated if - an object dies in an intelligent way... - o IDEA: merge otype and ctype and make all moves/etc depend on it - o IDEA (old): Add attributes: - - crushable (ie. weapon fart, jump, run destroys them?) - - bombable (ie. bomb destroys them) - - multistates? => bridges, door, stone block - - Progress ======== o Monsters / AI: VERY BAD o Game functionality (): BAD - o Events / Effects: BAD, MESS + o Events / Effects: BAD, MESS, NESTED o Object (including parameter) loading: BAD - o Move logic: ACCEPTABLE, BUGGED + o Move logic: ACCEPTABLE, BUGGED, NESTED o Objects (players, items, etc): ACCEPTABLE + o Physic Handler: ACCEPTABLE, NESTED o Input Handler: ACCEPTABLE, WORKS + o Scenario: OK, MESS, WORKS o Collision detection: OK o Fall logic: GOOD o Animation / Image structure: VERY GOOD -Features/Ideas/Wishlist -======================= +Feature Wishlist (Ideas) +======================== o Make water movements possible (eric) o improve the map editor even further Modified: trunk/src/Makefile =================================================================== --- trunk/src/Makefile 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/Makefile 2005-09-06 20:16:53 UTC (rev 156) @@ -4,7 +4,7 @@ CXX_OPT = #-O2 -march=pentium4 -ffast-math CXX_GAME = -DSDL_MIXER -DSDL_IMAGE -DALPHA -I ./ SDL = `sdl-config --cflags` -SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image -ldl -rdynamic +SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image #-ldl -rdynamic OBJS = common.o gfxeng.o input.o font.o lost_penguins.o scenario.o\ objects_common.o sfxeng.o players_common.o monsters_common.o\ Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/common.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -1,5 +1,6 @@ #include "common.h" #include "gfxeng.h" +#include "editor.h" ImageCache* imgcache; SoundCache* sndcache; @@ -51,6 +52,7 @@ gfxeng->unsetShowDebug(); SDL_ShowCursor(SDL_DISABLE); } + if (!editor) editor=new Editor(); #ifdef DEBUG gfxeng->setShowDebug(); #endif Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/common.h 2005-09-06 20:16:53 UTC (rev 156) @@ -118,7 +118,8 @@ KEY_BAR, KEY_FULL, KEY_QUIT, - KEY_NOANIM + KEY_NOANIM, + KEY_DEBUG }; enum BasePointType { @@ -165,9 +166,11 @@ int audio_channels; string datadir; string map; + string scenario; string anim_file; SDLKey keybind[30]; double lvlscale; + bool onlymap; }; /**\brief Frame format @@ -191,6 +194,8 @@ //global functions //@{ +/// Resets everything and shows the start screen again +void startScreen(); /// Quits the game with a error code /// \return Error code, 0 if successfull int quitGame(int); Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/editor.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -406,12 +406,12 @@ OpenMapBox::OpenMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) { title="Open Map"; - einput.push_back(scenario->name); - currententry=0; + einput.push_back(scenario->mapname); update(); } void OpenMapBox::evaluateEntry() { + scenario->resetScenario(); scenario->loadMap(einput[0]); editor->closeBox(); } @@ -426,7 +426,8 @@ } void NewMapBox::evaluateEntry() { - scenario->name=einput[0]; + scenario->resetScenario(); + scenario->mapname=einput[0]; scenario->newMap(einput[1]); scenario->reloadMap(); editor->closeBox(); Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/gfxeng.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -278,12 +278,12 @@ } } -void GraphicsEngine::setShowDebug() { - show_debug=true; +void GraphicsEngine::setShowDebug() { show_debug=true; } +void GraphicsEngine::unsetShowDebug() { show_debug=false; } +void GraphicsEngine::toggleShowDebug() { + if (show_debug) show_debug=false; + else show_debug=true; } -void GraphicsEngine::unsetShowDebug() { - show_debug=false; -} void GraphicsEngine::toggleFullScreen() { //on -> off Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/gfxeng.h 2005-09-06 20:16:53 UTC (rev 156) @@ -31,6 +31,7 @@ void toggleFullScreen(); void setShowDebug(); void unsetShowDebug(); + void toggleShowDebug(); void setMenuBG(SDL_Surface* menu_background=NULL); const SDL_Rect& addShift(Sint16,Sint16); const SDL_Rect& setShift(Sint16,Sint16); Modified: trunk/src/input.cpp =================================================================== --- trunk/src/input.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/input.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -164,6 +164,8 @@ gfxeng->toggleFPS(); } else if (key==config.keybind[KEY_FULL]) { gfxeng->toggleFullScreen(); + } else if (key==config.keybind[KEY_DEBUG]) { + gfxeng->toggleShowDebug(); } else if (key==config.keybind[KEY_QUIT]) { quitGame(0); } Modified: trunk/src/lost_penguins.cpp =================================================================== --- trunk/src/lost_penguins.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/lost_penguins.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -51,8 +51,7 @@ cout << "Initializing Scenario...\n"; scenario=new Scenario(); - gfxeng->setMenuBG(); - setMenu(new StartMenu()); + startScreen(); while (true) { input->update(); @@ -64,6 +63,13 @@ quitGame(-2); } +void startScreen() { + scenario->resetScenario(); + gfxeng->setMenuBG(); + setMenu(new StartMenu()); + setGameMode(GAME_MENU); +} + int quitGame(int errorcode=0) { cout << endl << "Quitting game (exit code: " << errorcode << ")...\n"; closeMenus(); @@ -100,8 +106,10 @@ config.audio_channels = 2; config.datadir="data/"; config.anim_file="animation_data.anim"; - config.map="map1.cfg"; + config.map=""; + config.scenario="lv1.sce"; config.lvlscale=2; + config.onlymap=false; //key bindings config.keybind[KEY_LEFT] = SDLK_LEFT; @@ -116,6 +124,7 @@ config.keybind[KEY_SWITCH] = SDLK_LCTRL; config.keybind[KEY_PAUSE] = SDLK_TAB; config.keybind[KEY_MENU] = SDLK_ESCAPE; + config.keybind[KEY_DEBUG] = SDLK_F4; config.keybind[KEY_NOANIM] = SDLK_F3; config.keybind[KEY_FPS] = SDLK_F2; config.keybind[KEY_BAR] = SDLK_F1; @@ -148,6 +157,9 @@ else config.full=false; } else if (option=="map") { config.map=arg1; + config.onlymap=true; + } else if (option=="scenario") { + config.scenario=arg1; //TODO: add keybindings } else { cout << "Unknown option: " << option << endl; @@ -170,7 +182,12 @@ } else if ( strcmp(argv[i], "-map") == 0 ) { config.map=argv[i+1]; config.map+=".cfg"; + config.onlymap=true; i++; + } else if ( strcmp(argv[i], "-scenario") == 0 ) { + config.scenario=argv[i+1]; + config.scenario+=".sce"; + i++; } else if ( strcmp(argv[i], "-datadir") == 0 ) { config.datadir=argv[i+1]; if (config.datadir.substr(config.datadir.size() - 1, 1)!="/") config.datadir+="/"; @@ -191,7 +208,8 @@ cout << " -w, -width Changes resolution (width) of game. Default: 640\n"; cout << " -h, -height Changes resolution (height) of game. Default: 480\n"; cout << " -fs, -full Enable fullscreen. Default: disabled\n"; - cout << " -map Load specified map from data dir. Default: map1\n"; + cout << " -map Load specified map from data dir. Default: disabled (map1 as a fallback)\n"; + cout << " -scenario Load specified Scenario from data dir. Default: lv1\n"; cout << " -h, --help Show this text \n"; quitGame(4); } Modified: trunk/src/menu.cpp =================================================================== --- trunk/src/menu.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/menu.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -64,24 +64,35 @@ void StartMenu::act() { switch (currententry) { case 0: { - if ((config.map!="") && (scenario->loadMap(config.map)==0)) { + if (config.onlymap && (config.map!="") && (scenario->loadMap(config.map)==0)) { closeMenu(); addGameMode(GAME_PLAY); - cout << "Starting game...\n" << endl; + cout << "Starting Scenario (1 map)...\n" << endl; + } else if (config.onlymap) { + cout << "Selected Map is invalid...\n" << endl; + } else if (scenario->loadScenario(config.scenario)==0 && scenario->startScenario()==0) { + closeMenu(); + addGameMode(GAME_PLAY); + cout << "Starting Scenario...\n" << endl; } else { - cout << "Select a valid map first...\n" << endl; + cout << "Selected Scenario is invalid...\n" << endl; } break; } case 1: { //Add a proper Map creation menu, etc..., FIXME - if ((config.map!="") && (scenario->loadMap(config.map)==0)) { + if (config.onlymap && (config.map!="") && (scenario->loadMap(config.map)==0)) { closeMenu(); - cout << "Starting editor...\n" << endl; + cout << "Starting Map Editor...\n" << endl; addGameMode(GAME_EDIT); - if (!editor) editor=new Editor(); + } else if (config.onlymap) { + cout << "Selected Map is invalid...\n" << endl; + } else if (scenario->loadScenario(config.scenario)==0 && scenario->startScenario()==0) { + closeMenu(); + addGameMode(GAME_EDIT); + cout << "Starting Map Editor...\n" << endl; } else { - cout << "Select a valid map first...\n" << endl; + cout << "Selected Scenario is invalid...\n" << endl; } break; } Modified: trunk/src/objects/Makefile =================================================================== --- trunk/src/objects/Makefile 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/objects/Makefile 2005-09-06 20:16:53 UTC (rev 156) @@ -4,7 +4,7 @@ CXX_OPT = #-O2 -march=pentium4 -ffast-math CXX_GAME = -DSDL_MIXER -DSDL_IMAGE -DALPHA -I ../ SDL = `sdl-config --cflags` -SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image -ldl -rdynamic +SDL_LINK = `sdl-config --libs` -lSDL_mixer -lSDL_image #-ldl -rdynamic AR = ar OBJS = baleog.o bomb.o door.o erik.o exit.o fang.o geyser.o heart.o\ Modified: trunk/src/objects/exit.cpp =================================================================== --- trunk/src/objects/exit.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/objects/exit.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -16,8 +16,6 @@ if (!((*it)->isIn(pos))) return false; ++it; } - if (scenario->failed) cout << "Again?\n"; - else cout << "You won!!!!\n"; - quitGame(0); + scenario->finnished=true; return true; } Modified: trunk/src/physics.cpp =================================================================== --- trunk/src/physics.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/physics.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -53,6 +53,12 @@ } inline void PhysicHandler::updateGame() { + if (scenario->finnished) { + cout << endl; + if (scenario->failed) cout << "Mission failed: Replay?" << endl; + scenario->loadNextMap(); + return; + } object_iterator obit=scenario->pool->objectspool.begin(); while (obit!=scenario->pool->objectspool.end()) { //remove marked objects Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/players_common.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -210,10 +210,11 @@ } void Player::in_act() { + Mix_Chunk* au_act_bak=au_act; object_iterator i=enter.begin(); while (i!=enter.end()) { if ((*i)->act(this)) { - sfxeng->playWAV(au_act); + sfxeng->playWAV(au_act_bak); return; } ++i; @@ -283,6 +284,7 @@ } void Player::die() { + /* todo add box and ask for a continue / redo */ scenario->failed=true; Character::die(); } Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/scenario.cpp 2005-09-06 20:16:53 UTC (rev 156) @@ -13,8 +13,11 @@ area(NULL), player(NULL), failed(false), - name(""), - bgimage("") { + finnished(false), + mapname(""), + scenarioname(""), + bgimage(""), + currentmap(0) { cout << "Scenario: ImageCache...\n"; imgcache=new ImageCache(); cout << "Scenario: SoundCache...\n"; @@ -48,28 +51,31 @@ if (background) delete background; if (physic) delete physic; physic=new PhysicHandler(); + sfxeng->stopMusic(); background=NULL; area=NULL; player=NULL; max_obj_num=0; + finnished=false; + failed=false; } void Scenario::newMap(string bgimage) { mapbuf.clear(); mapbuf.push_back("Background "+bgimage); } -int Scenario::loadMapBuf(string mapname) { - name=mapname; +int Scenario::loadMapBuf(string mapn) { + mapname=mapn; ifstream mapfile; string tmpline; - string loadfile=config.datadir+name; + string loadfile=config.datadir+mapname; mapfile.open(loadfile.c_str()); if (mapfile) { cout << "Loading new map: " << loadfile << endl; } else { cout << "Map loading failed: " << loadfile << " not found!\n"; - return -2; + return 2; } mapbuf.clear(); @@ -144,16 +150,113 @@ if (player==NULL) cout << "No player found!\n"; return 0; } else { - cout << "Map loading failed: No background found!\n"; - return -1; + cout << "Map loading failed: No background found!\n"; + return 1; } } -int Scenario::loadMap(string mapname) { - if (!loadMapBuf(mapname) && !reloadMap()) return 0; - else return -1; +int Scenario::loadMap(string mapn) { + if (loadMapBuf(mapn)==0 && reloadMap()==0) return 0; + else return 1; } +int Scenario::loadMap(Uint8 level) { + if (level> mname >> arg1 >> arg2; + if (mname[0]=='#') { + if (mname=="#ENDHEADER") header=false; + continue; + } + continue; + } + mname.erase(); + arg1=arg2=""; + std::istringstream tmpstream(tmpline); + tmpstream >> mname >> arg1 >> arg2; + + //Skip empty lines + if (mname.empty()) continue; + //Skip comments + if (mname[0]=='#') { + if (mname=="#HEADER") header=true; + continue; + } + + maps.push_back(mname); + } + + scenariofile.close(); + scenariofile.clear(); + + if (maps.size()>0) return 0; + else return 1; +} + Uint16 Scenario::getDirection(const SDL_Rect& src, const SDL_Rect& dest) const { Uint16 dir=NOTHING; if ((src.x+src.w) < (dest.x+dest.w)) dir|=DIR_RIGHT; Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-06 14:46:56 UTC (rev 155) +++ trunk/src/scenario.h 2005-09-06 20:16:53 UTC (rev 156) @@ -46,6 +46,8 @@ /// \param src Source rectangle /// \param dest Destination rectangle Uint16 getDirection(const SDL_Rect& src, const SDL_Rect& dest) const; + /// Load a new scenario + int loadScenario(string scenarioname); /// Background Background* background; @@ -73,15 +75,27 @@ /// \param mapname Map file name without the data directory in it /// \return 0 if a Background was found, -1 if not, -2 if the loading failed int loadMap(string mapname); + int loadMap(Uint8 level=0); + void loadNextMap(); + int startScenario(); + void winScenario(); + void resetScenario(); /// True if the mission failed bool failed; - /// Name of the map file - string name; + /// True if the mission is finnished (suceeded or failed) + bool finnished; + /// Name of the current map file + string mapname; + /// Name of the scenario + string scenarioname; /// Name of the map background image string bgimage; std::vector mapbuf; /// The number of created objects Uint32 max_obj_num; + std::vector maps; + std::vector playlist; + Uint8 currentmap; private: inline void reinitMap(); }; From DONOTREPLY at icculus.org Thu Sep 8 06:09:02 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 06:09:02 -0400 Subject: r157 - in trunk: . src src/objects Message-ID: <20050908100902.3252.qmail@icculus.org> Author: jonas Date: 2005-09-08 06:09:00 -0400 (Thu, 08 Sep 2005) New Revision: 157 Modified: trunk/TODO trunk/src/characters_common.cpp trunk/src/characters_common.h trunk/src/common.cpp trunk/src/common.h trunk/src/editor.cpp trunk/src/editor.h trunk/src/gfxeng.h trunk/src/monsters_common.cpp trunk/src/monsters_common.h trunk/src/objectpools.cpp trunk/src/objectpools.h trunk/src/objects/baleog.cpp trunk/src/objects/baleog.h trunk/src/objects/bomb.cpp trunk/src/objects/bomb.h trunk/src/objects/door.cpp trunk/src/objects/door.h trunk/src/objects/erik.cpp trunk/src/objects/erik.h trunk/src/objects/exit.cpp trunk/src/objects/exit.h trunk/src/objects/fang.cpp trunk/src/objects/fang.h trunk/src/objects/geyser.cpp trunk/src/objects/geyser.h trunk/src/objects/heart.cpp trunk/src/objects/heart.h trunk/src/objects/key.cpp trunk/src/objects/key.h trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/plant.cpp trunk/src/objects/plant.h trunk/src/objects/scorch.cpp trunk/src/objects/scorch.h trunk/src/objects/spike.cpp trunk/src/objects/spike.h trunk/src/objects/teleport.cpp trunk/src/objects/teleport.h trunk/src/objects/trigger.cpp trunk/src/objects/trigger.h trunk/src/objects/triggered_bomb.cpp trunk/src/objects/triggered_bomb.h trunk/src/objects/wall.cpp trunk/src/objects/wall.h trunk/src/objects/water.cpp trunk/src/objects/water.h trunk/src/objects/wind.cpp trunk/src/objects/wind.h trunk/src/objects/zombie.cpp trunk/src/objects/zombie.h trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp trunk/src/players_common.h trunk/src/scenario.cpp trunk/src/scenario.h Log: Big rewrite of the map/object loading: o Introduced a ParameterMap (map) to be used for specifying object (and other) parameters in a common way o An object constructor now has only 3 arguments: Object(Sint16 x, Sint16 y, ParameterMap& parameters) o All or many of the objects parameter can now be passed using the new ParameterMap. If the parameter was not specified it will fallback to a default parameter. o Introduced static member default_parameters to each object and set the values in objectspool ctor. This is used in the map editor... o Added prelimenary loadAnimation(ParameterMap&) support (atm it only is capable of loading a single image, using option "image") o Changed the map format (see scenario.h) -> There is now only one header at the beginning -> Background belongs to the header now -> Added getParameters() to get a ParameterMap from a paramlist string -> Added putParameters() to get a paramlist string from a ParameterMap o Added various helper functions: hasParam, getDirFromString, ObjectsPool:: setDefaultObjParam and getDefaultObjParambyName, GraphicsEngine::resetShift o Editor saves map to the data directory now... o Fixed a bug that caused the map editor to restart with a shift!=0 o Bomb places the TriggeredBomb useing addObjectbyName(), actually _only_ this function should be used from now on as the other functions don't set the correct name... o All Object ctor, ObjectsPool, Editor, map file parsing code has been changed accordingly o updated TODO Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/TODO 2005-09-08 10:09:00 UTC (rev 157) @@ -1,11 +1,7 @@ Bugs ==== o zombie (bug in movement!, attacks too often, use events, etc...) - o key vs. trigger in map2 - o fall event (DONE?) - o players die event segfault (eg. olaf) - Code ==== @@ -16,7 +12,6 @@ o Use Singletons o Create a better class hierarchy so we don't have a class playground... o Better handle the different game states and replace the current conditional model - o IDEA: Use boost to support better constructors (name loading) o IDEA: create dynamical plugins for all objects (or compile all in) o Move/crash/collisions: @@ -63,7 +58,8 @@ with animations!!! o REWRITE: the whole event system!!! - o Scenario: + o Scenario / Map: + o Specify Background in header o Add some nice animation, text box, etc when a level was completed (including printing the map name). o Simplify the scenario class and drastically reduce the public variables!! @@ -83,7 +79,6 @@ o Monsters / AI: VERY BAD o Game functionality (): BAD o Events / Effects: BAD, MESS, NESTED - o Object (including parameter) loading: BAD o Move logic: ACCEPTABLE, BUGGED, NESTED o Objects (players, items, etc): ACCEPTABLE o Physic Handler: ACCEPTABLE, NESTED @@ -91,6 +86,7 @@ o Scenario: OK, MESS, WORKS o Collision detection: OK o Fall logic: GOOD + o Object loading (parameters) loading: GOOD o Animation / Image structure: VERY GOOD Modified: trunk/src/characters_common.cpp =================================================================== --- trunk/src/characters_common.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/characters_common.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -7,8 +7,8 @@ #include "characters_common.h" -Character::Character(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Object(imagename,xcord,ycord,pname), +Character::Character(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters), health(1), maxhealth(1), maxspeedx(300), @@ -22,6 +22,16 @@ weapon(Weapon(0)) { state=STATE_FALL; otype|=OTYPE_CHARACTER; + + /* Parameters */ + if (hasParam(parameters,"maxhealth")) health=atoi(parameters["maxhealth"].c_str()); + else maxhealth=1; + if (hasParam(parameters,"health")) health=min((int)maxhealth,atoi(parameters["health"].c_str())); + else health=min(1,(int)maxhealth); + if (hasParam(parameters,"maxspeedx")) health=atoi(parameters["maxspeedx"].c_str()); + else maxspeedx=300; + if (hasParam(parameters,"maxspeedy")) health=atoi(parameters["maxspeedy"].c_str()); + else maxspeedy=0; } Character::~Character() { } Modified: trunk/src/characters_common.h =================================================================== --- trunk/src/characters_common.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/characters_common.h 2005-09-08 10:09:00 UTC (rev 157) @@ -35,8 +35,9 @@ */ class Character : public Object { public: - Character(string img, Sint16 xpos=0, Sint16 ypos=0, string name="Character"); + Character(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Character(); + static ParameterMap default_parameters; Uint8 getHealth(); //@{ Sint16 getSpeed() const { Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/common.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -26,7 +26,7 @@ const Uint32 bmask=0x00ff0000; const Uint32 amask=0xff000000; #endif -Uint32 vflags=SDL_HWSURFACE|SDL_RESIZABLE|SDL_DOUBLEBUF; +Uint32 vflags=SDL_HWSURFACE|SDL_RESIZABLE|SDL_DOUBLEBUF|SDL_HWACCEL; string itos(int i) { std::stringstream s; @@ -34,6 +34,65 @@ return s.str(); } +ParameterMap getParameters(const string& parameterlist, char delim, char delimsub) { + ParameterMap parameters; + istringstream parameterlist_s(parameterlist); + string parameter,name,value,tmpstr; + + while (std::getline(parameterlist_s,parameter,delim)) { + istringstream parameter_s(parameter); + std::getline(parameter_s,name,delimsub); + std::getline(parameter_s,value); + + /* get rid of leading and trailing spaces: this part is silly ;) + all spaces, tabs, etc are converted to one single space */ + istringstream name_s(name); + name=""; + while (name_s >> tmpstr) { + if (!name.empty()) name+=" "; + name+=tmpstr; + } + istringstream value_s(value); + value=""; + while (value_s >> tmpstr) { + if (!value.empty()) value+=" "; + value+=tmpstr; + } + parameters[name]=value; + } + return parameters; +} + +string putParameters(const ParameterMap& parameters, char delim, char delimsub) { + string parameterlist; + ParameterMap::const_iterator it=parameters.begin(); + while (it!=parameters.end()) { + if (!parameterlist.empty()) { + parameterlist+=delim; + parameterlist+=" "; + } + parameterlist+=(*it).first; + parameterlist+=delimsub; + parameterlist+=(*it).second; + ++it; + } + return parameterlist; +} + +bool hasParam(ParameterMap& parameters, const string& str) { + if (parameters.find(str)!=parameters.end()) return true; + else return false; +} + +Uint16 getDirFromString(const string& str) { + Uint16 direction=NOTHING; + if (str.find("up") !=string::npos) direction|=DIR_UP; + if (str.find("down") !=string::npos) direction|=DIR_DOWN; + if (str.find("left") !=string::npos) direction|=DIR_LEFT; + if (str.find("right") !=string::npos) direction|=DIR_RIGHT; + return direction; +} + int addAbsolute(int a, int b) { if (a>=0) return a=max(0,a+b); else return a=min(0,a-b); @@ -48,6 +107,7 @@ if (game_mode&GAME_EDIT && !(game_mode&GAME_MENU)) { gfxeng->setShowDebug(); SDL_ShowCursor(SDL_ENABLE); + gfxeng->resetShift(); } else { gfxeng->unsetShowDebug(); SDL_ShowCursor(SDL_DISABLE); Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/common.h 2005-09-08 10:09:00 UTC (rev 157) @@ -50,10 +50,13 @@ typedef std::set::iterator player_iterator; typedef std::set::iterator monster_iterator; typedef boost::shared_ptr EmptyAnimationPtr; +typedef std::map ParameterMap; //Data #define DATA_LVLFPS 6 #define DATA_LVLDUR 1000 +#define DATA_LVLPLAYER_W 25 +#define DATA_LVLPLAYER_H 30 //General definitions #define NOTHING 0x00000000 @@ -207,6 +210,15 @@ /// \return 1 if the file was found, 0 otherwise /// \todo Create a better config format int readConfig(const string& filename); +/// Parse a string parameter list and return it as a map +ParameterMap getParameters(const string& parameterlist, char delim=',', char delimsub='='); +/// Convert the parameter map to a string +string putParameters(const ParameterMap& parameters, char delim=',', char delimsub='='); +/// Returns true if the parameter was found +bool hasParam(ParameterMap& parameters, const string& str); +/// Returns the direction from the given string: simply include one or a +/// combination of "up", "down", "left", "right" in the string +Uint16 getDirFromString(const string& str); /// Parse the command line options void parseInput(int argc,char* argv[]); Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/editor.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -12,7 +12,6 @@ string place_name=""; save_name="newmap.cfg"; box=NULL; - place_obj_name=NULL; } Editor::~Editor() { @@ -39,11 +38,10 @@ if (box) box->act(box->getCurrentEntry(x,y)); } else if (action&EDIT_PLACE_OBJECT) { scenario->reloadMap(); - if (scenario->pool->addObjectbyName(place_name,place_image,xs,ys,place_arg1,place_arg2,place_arg3)) { - appendtoBuf(place_name+" "+place_image+" "+itos(xs)+" "+itos(ys)+" "+place_arg1+" "+place_arg2+" "+place_arg3); + if (scenario->pool->addObjectbyName(place_name,xs,ys,place_parameters)) { + appendtoBuf(place_name+" "+itos(xs)+" "+itos(ys)+" "+putParameters(place_parameters)); } - if (place_obj_name) (*place_obj_name)=scenario->pool->getNextObjectName(place_name); -// action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX; + place_parameters["name"]=scenario->pool->getNextObjectName(place_name); } else { } } @@ -269,67 +267,9 @@ gfxeng->update(UPDATE_ALL); if (curentry==-1 || curentry >= (Sint8)entries.size()) { } else { - string next_name=scenario->pool->getNextObjectName(entries[curentry]); - if (entries[curentry]=="Wall") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Water") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"water.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Exit") { - editor->setBox(new ObjectBox(entries[curentry],"exit.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Teleporter") { - editor->place_obj_name=&editor->place_arg3; - editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Teleport Destination (x coordinate): ","0","Teleport Destination (y coordinate): ","0","Name: ",next_name)); - } else if (entries[curentry]=="Wind") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"teleport_01.bmp",area.x,area.y,"Wind acceleration: ","0","Name: ",next_name)); - } else if (entries[curentry]=="Geyser") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Geyser force: ","0","Name: ",next_name)); - } else if (entries[curentry]=="Trigger") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Trigger target name: ","","Name: ",next_name,"Key name: ","")); - } else if (entries[curentry]=="Door") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Key name: ","","Name: ",next_name)); - } else if (entries[curentry]=="Spike") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Direction (R=1,L=2,U=4,D=8): ","4","Name: ",next_name)); - } else if (entries[curentry]=="Heart") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"heart.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Key") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"key.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Bomb") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"bomb_fire.bmp",area.x,area.y,"Exploding time (in ms): ","0","Name: ",next_name)); - } else if (entries[curentry]=="Erik") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Olaf") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Baleog") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Fang") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Scorch") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); - } else if (entries[curentry]=="Plant") { - editor->place_obj_name=&editor->place_arg2; - editor->setBox(new ObjectBox(entries[curentry],"viking1.bmp",area.x,area.y,"Recovery time (in ms): ","0","Name: ",next_name)); - } else if (entries[curentry]=="Zombie") { - editor->place_obj_name=&editor->place_arg1; - editor->setBox(new ObjectBox(entries[curentry],"viking.bmp",area.x,area.y,"Name: ",next_name)); - } else { - editor->run_action(EDIT_RESET_ACTIONS); - editor->closeBox(); - } + ParameterMap parameters=scenario->pool->getDefaultObjParambyName(entries[curentry]); + parameters["name"]=scenario->pool->getNextObjectName(entries[curentry]); + editor->setBox(new ObjectBox(entries[curentry],area.x,area.y,parameters)); } } @@ -400,22 +340,32 @@ void SaveAsBox::evaluateEntry() { editor->save_name=einput[0]; - editor->saveBuf(editor->save_name); + editor->saveBuf(config.datadir+editor->save_name); editor->closeBox(); } OpenMapBox::OpenMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) { title="Open Map"; + currententry=0; einput.push_back(scenario->mapname); update(); } void OpenMapBox::evaluateEntry() { scenario->resetScenario(); - scenario->loadMap(einput[0]); + string oldname=scenario->mapname; + if (scenario->loadMap(einput[0])!=0) { + cout << "Map loading failed!" << endl; + if (scenario->loadMap(oldname)!=0) { + cout << "Couldn't even load the original map!" << endl; + startScreen(); + } + } editor->closeBox(); } +/* TODO: support not just image bgs + TODO: support additional header options */ NewMapBox::NewMapBox(Sint16 x, Sint16 y): TextInputBox(x,y) { title="New Map"; centered=false; @@ -427,39 +377,34 @@ void NewMapBox::evaluateEntry() { scenario->resetScenario(); + ParameterMap bg_parameters; + bg_parameters["image"]=einput[1]; scenario->mapname=einput[0]; - scenario->newMap(einput[1]); + scenario->newMap(bg_parameters); scenario->reloadMap(); editor->closeBox(); } -ObjectBox::ObjectBox(string name, string image, Sint16 x, Sint16 y, string targ1, string arg1, string targ2, string arg2, string targ3, string arg3): TextInputBox(x,y), +ObjectBox::ObjectBox(string name, Sint16 x, Sint16 y, ParameterMap& parameters): TextInputBox(x,y), objname(name) { title=name+" Properties"; centered=false; currententry=0; - etitles.push_back("Image name: "); einput.push_back(image); - if (targ1!="" || arg1!="") { - etitles.push_back(targ1); - einput.push_back(arg1); + ParameterMap::iterator it=parameters.begin(); + while (it!=parameters.end()) { + etitles.push_back((*it).first); + einput.push_back((*it).second); + ++it; } - if (targ2!="" || arg2!="") { - etitles.push_back(targ2); - einput.push_back(arg2); - } - if (targ3!="" || arg3!="") { - etitles.push_back(targ3); - einput.push_back(arg3); - } update(); } void ObjectBox::evaluateEntry() { editor->place_name=objname; - editor->place_image=einput[0]; - if (einput.size()>=2) editor->place_arg1=einput[1]; - if (einput.size()>=3) editor->place_arg2=einput[2]; - if (einput.size()>=4) editor->place_arg3=einput[3]; + editor->place_parameters.clear(); + for (Uint8 i=0; iplace_parameters[etitles[i]]=einput[i]; + } editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT; editor->closeBox(); } Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/editor.h 2005-09-08 10:09:00 UTC (rev 157) @@ -84,7 +84,7 @@ */ class ObjectBox : public TextInputBox { public: - ObjectBox(string,string,Sint16,Sint16,string targ1="",string arg1="",string targ2="",string arg2="",string targ3="",string arg3=""); + ObjectBox(string,Sint16,Sint16,ParameterMap& parameters); protected: virtual void evaluateEntry(); string objname; @@ -150,16 +150,8 @@ string save_name; /// Object to place when clicking the left mouse button string place_name; - /// Image name of the placed object - string place_image; - /// Object name to place when clicking the left mouse button - string* place_obj_name; - /// First additonal parameter of the placed object - string place_arg1; - /// Seconds additional parameter of the placed object - string place_arg2; - /// Third additional parameter of the placed object - string place_arg3; + /// Parameter list used to create the object + ParameterMap place_parameters; /// Append a command to the buffered map file void appendtoBuf(string); /* TODO: add header modifiers */ Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/gfxeng.h 2005-09-08 10:09:00 UTC (rev 157) @@ -38,6 +38,9 @@ const SDL_Rect& getShift() { return shift; } + void resetShift() { + shift.x=shift.y=0; + } void drawRectangle(SDL_Rect rect, Uint8 border=1, Uint32 color=0); protected: /// main screen Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/monsters_common.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -10,20 +10,24 @@ #include "players_common.h" -Monster::Monster(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Character(imagename,xcord,ycord,pname), +Monster::Monster(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Character(xcord,ycord,parameters), Dai(0), Dattack(0), anim_left(new EmptyAnimation(&anim_right)), anim_right(new EmptyAnimation()) { - health=1; - maxspeedx=50; - maxspeedy=0; state=STATE_FALL; otype|=OTYPE_MONSTER; enemy_types|=OTYPE_PLAYER; dense_types|=OTYPE_PLAYER; - au_hit=scenario->sndcache->loadWAV("monhit.wav"); + + /* Parameters */ + if (!hasParam(parameters,"maxhealth")) maxhealth=1; + if (!hasParam(parameters,"health")) health=min(1,(int)maxhealth); + if (!hasParam(parameters,"maxspeedx")) maxspeedx=50; + if (!hasParam(parameters,"maxspeedy")) maxspeedy=0; + if (hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV(parameters["audio_hit"]); + else au_hit=scenario->sndcache->loadWAV("monhit.wav"); } Monster::~Monster() { Modified: trunk/src/monsters_common.h =================================================================== --- trunk/src/monsters_common.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/monsters_common.h 2005-09-08 10:09:00 UTC (rev 157) @@ -9,8 +9,9 @@ */ class Monster : public Character { public: - Monster(string img, Sint16 xpos=0, Sint16 ypos=0, string name="Monster"); + Monster(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Monster(); + static ParameterMap default_parameters; virtual void removedObject(Object*); virtual void updateAnimState(); virtual void idle(Uint16); Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objectpools.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -30,6 +30,37 @@ #include "objects/zombie.h" +ParameterMap Object::default_parameters; +ParameterMap Background::default_parameters; +ParameterMap Trigger::default_parameters; +ParameterMap Door::default_parameters; +ParameterMap Exit::default_parameters; +ParameterMap Teleporter::default_parameters; +ParameterMap Wall::default_parameters; +ParameterMap Water::default_parameters; +ParameterMap Wind::default_parameters; +ParameterMap Spike::default_parameters; + +ParameterMap Item::default_parameters; +ParameterMap Heart::default_parameters; +ParameterMap Key::default_parameters; +ParameterMap Bomb::default_parameters; + +ParameterMap Character::default_parameters; +ParameterMap DeadPlayer::default_parameters; +ParameterMap TriggeredBomb::default_parameters; + +ParameterMap Monster::default_parameters; +ParameterMap Plant::default_parameters; +ParameterMap Zombie::default_parameters; + +ParameterMap Player::default_parameters; +ParameterMap Erik::default_parameters; +ParameterMap Olaf::default_parameters; +ParameterMap Scorch::default_parameters; +ParameterMap Fang::default_parameters; +ParameterMap Baleog::default_parameters; + bool Compare::operator()(const Object* obj1, const Object* obj2) { if (obj1->onumonum) return true; else return false; @@ -37,60 +68,148 @@ ObjectsPool::ObjectsPool(): currentplayer(playerspool.begin()), - au_switch(sndcache->loadWAV("newchar.wav")) { } + au_switch(sndcache->loadWAV("newchar.wav")) { + setDefaultObjParam(); +} ObjectsPool::~ObjectsPool() { object_iterator i=objectspool.begin(); while (i!=objectspool.end()) i=removeObject(i); } +void ObjectsPool::setDefaultObjParam() { + Object::default_parameters["name"]=""; + Object::default_parameters["w"]=""; + Object::default_parameters["h"]=""; + Object::default_parameters["image"]=""; + Background::default_parameters=Object::default_parameters; + Exit::default_parameters=Object::default_parameters; + Exit::default_parameters["image"]="exit.bmp"; + Wall::default_parameters=Object::default_parameters; + Door::default_parameters=Object::default_parameters; + Door::default_parameters["key"]="Key"; + Door::default_parameters["start_open"]=""; + Door::default_parameters["audio_open"]="dooropn.wav"; + Door::default_parameters["audio_close"]="dooropn.wav"; + Teleporter::default_parameters=Object::default_parameters; + Teleporter::default_parameters["exitx"]="0"; + Teleporter::default_parameters["exity"]="0"; + Teleporter::default_parameters["audio_teleport"]="teleprt.wav"; + Water::default_parameters=Object::default_parameters; + Water::default_parameters["audio_water_land"]="splash2.wav"; + Wind::default_parameters=Object::default_parameters; + Wind::default_parameters["accel"]="0"; + Trigger::default_parameters=Object::default_parameters; + Trigger::default_parameters["image"]="key.bmp"; + Trigger::default_parameters["key"]="Key"; + Trigger::default_parameters["target"]="Target"; + Spike::default_parameters=Object::default_parameters; + Spike::default_parameters["direction"]="up"; -Object* ObjectsPool::addObjectbyName(const string& obj, const string& image, Sint16 x, Sint16 y, string& arg1, string& arg2, const string& arg3) { - //Set names... - string name=getNextObjectName(obj); - if (!arg1.empty()) { - //one additional parameter - if (obj=="Trigger" || obj=="Door" || obj=="Bomb" || obj=="TriggeredBomb" || obj=="Plant" || obj=="Geyser" || obj=="Wind" || obj=="Spike") { - if (!arg2.empty()) name=arg2; - //two additional parameter - } else if (obj=="Teleporter") { - if (!arg3.empty()) name=arg3; - //no additional parameters - } else { - name=arg1; - } - } - if (arg1.empty()) arg1="0"; - if (arg2.empty()) arg2="0"; + Item::default_parameters=Object::default_parameters; + Heart::default_parameters=Item::default_parameters; + Heart::default_parameters["image"]="heart.bmp"; + Heart::default_parameters["alife"]="1"; + Key::default_parameters=Item::default_parameters; + Key::default_parameters["image"]="key.bmp"; + Key::default_parameters["audio_key"]=""; + Bomb::default_parameters=Item::default_parameters; + Bomb::default_parameters["image"]="bomb_fire.bmp"; + Bomb::default_parameters["image_bomb"]="bomb_fire.bmp"; + Bomb::default_parameters["countdown"]="3000"; + Bomb::default_parameters["audio_bomb"]="explsn.wav"; - //normal objects - if (obj=="Wall") return (addObject(new Wall(image,x,y,name))); - else if (obj=="Exit") return (addObject(new Exit(image,x,y,name))); - else if (obj=="Water") return (addObject(new Water(image,x,y,name))); - else if (obj=="Teleporter") return (addObject(new Teleporter(image,x,y,atoi(arg1.c_str()),atoi(arg2.c_str()),name))); - else if (obj=="Wind") return (addObject(new Wind(image,x,y,atoi(arg1.c_str()),name))); - else if (obj=="Geyser") return (addObject(new Geyser(image,x,y,atoi(arg1.c_str()),name))); - else if (obj=="Trigger") return (addObject(new Trigger(image,x,y,arg1,name,arg3))); - else if (obj=="Door") return (addObject(new Door(image,x,y,arg1,name))); - else if (obj=="Spike") return (addObject(new Spike(image,x,y,atoi(arg1.c_str()),name))); - //Items - else if (obj=="Heart") return (addObject(new Heart(image,x,y,name))); - else if (obj=="Key") return (addObject(new Key(image,x,y,name))); - else if (obj=="Bomb") return (addObject(new Bomb(image,x,y,atoi(arg1.c_str()),name))); + Character::default_parameters=Object::default_parameters; + Character::default_parameters["maxhealth"]=1; + Character::default_parameters["health"]="1"; + Character::default_parameters["maxspeedx"]="300"; + Character::default_parameters["maxspeedy"]="0"; + DeadPlayer::default_parameters=Character::default_parameters; + TriggeredBomb::default_parameters=Character::default_parameters; + TriggeredBomb::default_parameters["image"]="bomb_fire.bmp"; + TriggeredBomb::default_parameters["countdown"]="3000"; + TriggeredBomb::default_parameters["audio_bomb"]="explsn.wav"; - //normal characters - else if (obj=="TriggeredBomb") return (addCharacter(new TriggeredBomb(image,x,y,atoi(arg1.c_str()),name))); + Monster::default_parameters=Character::default_parameters; + Monster::default_parameters["maxhealth"]=1; + Monster::default_parameters["health"]="1"; + Monster::default_parameters["maxspeedx"]="50"; + Monster::default_parameters["maxspeedy"]="0"; + Monster::default_parameters["audio_hit"]="monhit.wav"; + Plant::default_parameters=Character::default_parameters; + Plant::default_parameters["audio_hit"]="creeper.wav"; + Plant::default_parameters["audio_recover"]="creeper.wav"; + Plant::default_parameters["time_recover"]="3000"; + Zombie::default_parameters=Character::default_parameters; + Zombie::default_parameters["maxspeedx"]="80"; + Zombie::default_parameters["audio_attack"]="clang.wav"; - //Players - else if (obj=="Erik") return (addPlayer(new Erik(image,x,y,name))); - else if (obj=="Olaf") return (addPlayer(new Olaf(image,x,y,name))); - else if (obj=="Baleog") return (addPlayer(new Baleog(image,x,y,name))); - else if (obj=="Fang") return (addPlayer(new Fang(image,x,y,name))); - else if (obj=="Scorch") return (addPlayer(new Scorch(image,x,y,name))); + Player::default_parameters=Character::default_parameters; + Player::default_parameters["maxhealth"]="4"; + Player::default_parameters["health"]="3"; + Player::default_parameters["maxspeedx"]="300"; + Player::default_parameters["maxspeedy"]="200"; + Erik::default_parameters=Player::default_parameters; + Olaf::default_parameters=Player::default_parameters; + Scorch::default_parameters=Player::default_parameters; + Fang::default_parameters=Player::default_parameters; + Baleog::default_parameters=Player::default_parameters; +} - //Monsters - else if (obj=="Plant") return (addMonster(new Plant(image,x,y,atoi(arg1.c_str()),name))); - else if (obj=="Zombie") return (addMonster(new Zombie(image,x,y,name))); +const ParameterMap& ObjectsPool::getDefaultObjParambyName(const string& obj) { + if (obj=="Object") return Object::default_parameters; + else if (obj=="Background") return Background::default_parameters; + else if (obj=="Trigger") return Trigger::default_parameters; + else if (obj=="Door") return Door::default_parameters; + else if (obj=="Exit") return Exit::default_parameters; + else if (obj=="Teleporter") return Teleporter::default_parameters; + else if (obj=="Wall") return Wall::default_parameters; + else if (obj=="Water") return Water::default_parameters; + else if (obj=="Wind") return Wind::default_parameters; + else if (obj=="Spike") return Spike::default_parameters; - //not recognized + else if (obj=="Item") return Item::default_parameters; + else if (obj=="Heart") return Heart::default_parameters; + else if (obj=="Key") return Key::default_parameters; + else if (obj=="Bomb") return Bomb::default_parameters; + + else if (obj=="Character") return Character::default_parameters; + else if (obj=="DeadPlayer") return DeadPlayer::default_parameters; + else if (obj=="TriggeredBomb") return TriggeredBomb::default_parameters; + else if (obj=="Plant") return Plant::default_parameters; + else if (obj=="Zombie") return Zombie::default_parameters; + + else if (obj=="Player") return Player::default_parameters; + else if (obj=="Erik") return Erik::default_parameters; + else if (obj=="Olaf") return Olaf::default_parameters; + else if (obj=="Scorch") return Scorch::default_parameters; + else if (obj=="Fang") return Fang::default_parameters; + else if (obj=="Baleog") return Baleog::default_parameters; + else return empty_parameter; +} + +Object* ObjectsPool::addObjectbyName(const string& obj, Sint16 x, Sint16 y, ParameterMap& parameters) { + //Set names... + if (!hasParam(parameters,"name")) parameters["name"]=getNextObjectName(obj); + + if (obj=="Wall") return (addObject(new Wall(x,y,parameters))); + else if (obj=="Exit") return (addObject(new Exit(x,y,parameters))); + else if (obj=="Water") return (addObject(new Water(x,y,parameters))); + else if (obj=="Teleporter") return (addObject(new Teleporter(x,y,parameters))); + else if (obj=="Wind") return (addObject(new Wind(x,y,parameters))); + else if (obj=="Geyser") return (addObject(new Geyser(x,y,parameters))); + else if (obj=="Trigger") return (addObject(new Trigger(x,y,parameters))); + else if (obj=="Door") return (addObject(new Door(x,y,parameters))); + else if (obj=="Spike") return (addObject(new Spike(x,y,parameters))); + else if (obj=="Heart") return (addObject(new Heart(x,y,parameters))); + else if (obj=="Key") return (addObject(new Key(x,y,parameters))); + else if (obj=="Bomb") return (addObject(new Bomb(x,y,parameters))); + else if (obj=="TriggeredBomb") return (addCharacter(new TriggeredBomb(x,y,parameters))); + else if (obj=="Erik") return (addPlayer(new Erik(x,y,parameters))); + else if (obj=="Olaf") return (addPlayer(new Olaf(x,y,parameters))); + else if (obj=="Baleog") return (addPlayer(new Baleog(x,y,parameters))); + else if (obj=="Fang") return (addPlayer(new Fang(x,y,parameters))); + else if (obj=="Scorch") return (addPlayer(new Scorch(x,y,parameters))); + else if (obj=="Plant") return (addMonster(new Plant(x,y,parameters))); + else if (obj=="Zombie") return (addMonster(new Zombie(x,y,parameters))); else { cout << "Object " << obj << " unknown, skipping...\n"; return NULL; Modified: trunk/src/objectpools.h =================================================================== --- trunk/src/objectpools.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objectpools.h 2005-09-08 10:09:00 UTC (rev 157) @@ -18,6 +18,10 @@ public: ObjectsPool(); ~ObjectsPool(); + ///\brief sets the static default_parameters variable of all objects + void setDefaultObjParam(); + ///\brief Returns the default_parameters of the corresponding obj or an empty map + const ParameterMap& getDefaultObjParambyName(const string& obj); ///\brief Returns true if no objects were loaded so far... bool empty(); ///\todo Move this code to the objects @@ -26,15 +30,12 @@ /// Add an Object by it's name to the corresponding pool if it was /// recognized, initialized with the parsed options. /// \param obj Name of the Object class - /// \param image Name of the base image to be load /// \param x x coordinate /// \param y y coordinate - /// \param arg1 First argument as string - /// \param arg2 Second argument as string - /// \param arg3 Third argument as string + /// \param parameters A map of all parameters /// \return Pointer to the new entry in the objectspool or NULL if /// the object was not recognized - Object* addObjectbyName(const string& obj, const string& image, Sint16 x=0, Sint16 y=0, string& arg1="", string& arg2="", const string& arg3=""); + Object* addObjectbyName(const string& obj, Sint16 x=0, Sint16 y=0, ParameterMap& parameters=ParameterMap()); //@{ /// Add an Object to the objectspool /// \return Pointer to the new entry in the objectspool or NULL if it failed @@ -91,6 +92,7 @@ //player number of the currently selected player player_iterator currentplayer; Mix_Chunk* au_switch; + const ParameterMap empty_parameter; }; #endif Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/baleog.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -8,8 +8,8 @@ #include "baleog.h" -Baleog::Baleog(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Player(imagename,xcord,ycord,pname) { +Baleog::Baleog(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Player(xcord,ycord,parameters) { anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); Modified: trunk/src/objects/baleog.h =================================================================== --- trunk/src/objects/baleog.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/baleog.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,8 +5,9 @@ */ class Baleog : public Player { public: - Baleog(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Baleog"); + Baleog(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Baleog(); + static ParameterMap default_parameters; /// \brief Baleog attacks with a sword virtual void in_sp1(); private: Modified: trunk/src/objects/bomb.cpp =================================================================== --- trunk/src/objects/bomb.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/bomb.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -3,16 +3,25 @@ #include "objectpools.h" #include "scenario.h" #include "players_common.h" +#include "imgcache.h" #include "triggered_bomb.h" #include "bomb.h" -Bomb::Bomb(string imagename, Sint16 xcord, Sint16 ycord, Uint16 explode_time, string iname): - Item(imagename,xcord,ycord,iname), - countdown(explode_time) { } +Bomb::Bomb(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Item(xcord,ycord,parameters) { + /* Parameters */ + if (!hasParam(parameters,"image")) anim_orig=loadAnimation(scenario->imgcache->loadImage(1,"bomb_fire.bmp")); + if (hasParam(parameters,"image_bomb")) triggered_bomb_param["image"]=parameters["image_bomb"]; + else triggered_bomb_param["image"]="bomb_fire.bmp"; + if (hasParam(parameters,"countdown")) triggered_bomb_param["countdown"]="3000"; + else triggered_bomb_param["countdown"]=parameters["countdown"]; + if (hasParam(parameters,"audio_bomb")) triggered_bomb_param["audio_bomb"]=parameters["audio_bomb"]; + else triggered_bomb_param["audio_bomb"]="explsn.wav"; +} Bomb::~Bomb() { } bool Bomb::act(Object*) { - if (scenario->pool->addCharacter(new TriggeredBomb("bomb_fire.bmp",owner->getPos()->x,owner->getPos()->y,countdown,"TriggeredBomb"))) { + if (scenario->pool->addObjectbyName("TriggeredBomb",owner->getPos()->x,owner->getPos()->y-20,triggered_bomb_param)) { owner->removeItem(); return true; } else { Modified: trunk/src/objects/bomb.h =================================================================== --- trunk/src/objects/bomb.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/bomb.h 2005-09-08 10:09:00 UTC (rev 157) @@ -8,10 +8,10 @@ */ class Bomb : public Item { public: - Bomb(string imagename, Sint16 xpos=0, Sint16 ypos=0, Uint16 explode_time=3000, string name="Bomb"); + Bomb(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Bomb(); + static ParameterMap default_parameters; virtual bool act(Object* obj); private: - Uint16 countdown; - Mix_Chunk* au_bomb; + ParameterMap triggered_bomb_param; }; Modified: trunk/src/objects/door.cpp =================================================================== --- trunk/src/objects/door.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/door.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -6,13 +6,19 @@ #include "door.h" -Door::Door(string imagename, Sint16 xcord, Sint16 ycord, string keyname, string oname): - Object(imagename,xcord,ycord,oname), - open(false), - key(keyname), - au_open(scenario->sndcache->loadWAV("dooropn.wav")), - au_close(au_open) { +Door::Door(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { otype=OTYPE_DENSE; + + /* Parameters */ + if (hasParam(parameters,"key")) key=parameters["key"]; + else key="Key"; + if (hasParam(parameters,"audio_open")) au_open =scenario->sndcache->loadWAV(parameters["audio_open"]); + else au_open=scenario->sndcache->loadWAV("dooropn.wav"); + if (hasParam(parameters,"audio_close")) au_close=scenario->sndcache->loadWAV(parameters["audio_close"]); + else au_close=scenario->sndcache->loadWAV("dooropn.wav"); + if (hasParam(parameters,"start_open")) open=true; + else open=false; } Door::~Door() { } Modified: trunk/src/objects/door.h =================================================================== --- trunk/src/objects/door.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/door.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,8 +5,9 @@ */ class Door : public Object { public: - Door(string imagename, Sint16 xcord=0, Sint16 ycord=0, string keyname="Key", string oname="Door"); + Door(Sint16 xcord=0, Sint16 ycord=0, ParameterMap& parameters=ParameterMap()); virtual ~Door(); + static ParameterMap default_parameters; virtual bool act(Object* obj); private: bool open; Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/erik.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -10,8 +10,8 @@ #include "erik.h" -Erik::Erik(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Player(imagename,xcord,ycord,pname), +Erik::Erik(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Player(xcord,ycord,parameters), jump(V_JUMP), jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); Modified: trunk/src/objects/erik.h =================================================================== --- trunk/src/objects/erik.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/erik.h 2005-09-08 10:09:00 UTC (rev 157) @@ -13,8 +13,9 @@ */ class Erik : public Player { public: - Erik(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Erik"); + Erik(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Erik(); + static ParameterMap default_parameters; virtual void idle(Uint16); /// \brief Erik jumps virtual void in_sp1(); Modified: trunk/src/objects/exit.cpp =================================================================== --- trunk/src/objects/exit.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/exit.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -2,12 +2,16 @@ #include "objectpools.h" //shouldn't be here... #include "scenario.h" +#include "imgcache.h" #include "players_common.h" #include "exit.h" -Exit::Exit(string imagename, Sint16 xcord, Sint16 ycord, string oname): - Object(imagename,xcord,ycord,oname) { } +Exit::Exit(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { + /* Parameters */ + if (!hasParam(parameters,"image")) anim_orig=loadAnimation(scenario->imgcache->loadImage(1,"exit.bmp")); +} Exit::~Exit() { } bool Exit::act(Object*) { Modified: trunk/src/objects/exit.h =================================================================== --- trunk/src/objects/exit.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/exit.h 2005-09-08 10:09:00 UTC (rev 157) @@ -6,7 +6,8 @@ */ class Exit : public Object { public: - Exit(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Exit"); + Exit(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Exit(); + static ParameterMap default_parameters; virtual bool act(Object* obj); }; Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/fang.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -8,8 +8,8 @@ #include "fang.h" -Fang::Fang(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Player(imagename,xcord,ycord,pname), +Fang::Fang(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Player(xcord,ycord,parameters), jump(V_JUMP) { weapon=Weapon(-1,W_STRIKE); anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); Modified: trunk/src/objects/fang.h =================================================================== --- trunk/src/objects/fang.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/fang.h 2005-09-08 10:09:00 UTC (rev 157) @@ -22,8 +22,9 @@ */ class Fang : public Player { public: - Fang(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Fang"); + Fang(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Fang(); + static ParameterMap default_parameters; virtual void fall(Uint16); virtual void in_left(Uint16); virtual void in_right(Uint16); Modified: trunk/src/objects/geyser.cpp =================================================================== --- trunk/src/objects/geyser.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/geyser.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -8,11 +8,15 @@ #include "geyser.h" -Geyser::Geyser(string imagename, Sint16 xcord, Sint16 ycord, Sint16 yAdd, string oname): - Object(imagename,xcord,ycord,oname), - aspeed(yAdd), - au_geyser(scenario->sndcache->loadWAV("geyser.wav")), - Deffect(0) { } +Geyser::Geyser(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters), + Deffect(0) { + /* Parameters */ + if (hasParam(parameters,"aspeed")) aspeed=atoi(parameters["aspeed"].c_str()); + else aspeed=0; + if (hasParam(parameters,"audio_geyser")) au_geyser=scenario->sndcache->loadWAV(parameters["audio_geyser"]); + else au_geyser=scenario->sndcache->loadWAV("geyser.wav"); +} Geyser::~Geyser() { } void Geyser::idle(Uint16 dt) { Modified: trunk/src/objects/geyser.h =================================================================== --- trunk/src/objects/geyser.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/geyser.h 2005-09-08 10:09:00 UTC (rev 157) @@ -9,8 +9,9 @@ */ class Geyser : public Object { public: - Geyser(string imagename, Sint16 xpos=0, Sint16 ypos=0, Sint16 yAdd=0, string name="Geyser"); + Geyser(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Geyser(); + static ParameterMap default_parameters; virtual void idle(Uint16 dt); private: Sint16 aspeed; Modified: trunk/src/objects/heart.cpp =================================================================== --- trunk/src/objects/heart.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/heart.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -2,17 +2,24 @@ #include "weapons.h" #include "objects_common.h" //shouldn't be here... +#include "scenario.h" +#include "imgcache.h" #include "players_common.h" #include "heart.h" -Heart::Heart(string imagename, Sint16 xcord, Sint16 ycord, string iname): - Item(imagename,xcord,ycord,iname) { } +Heart::Heart(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Item(xcord,ycord,parameters) { + /* Parameters */ + if (!hasParam(parameters,"image")) anim_orig=loadAnimation(scenario->imgcache->loadImage(1,"heart.bmp")); + if (hasParam(parameters,"alife")) alife=atoi(parameters["alife"].c_str()); + else alife=1; +} Heart::~Heart() { } bool Heart::act(Object* obj) { if ((obj==NULL) || (obj!=owner)) return false; - Weapon tmpheal(1,W_HEAL,WS_HEAL); + Weapon tmpheal(alife,W_HEAL,WS_HEAL); owner->hit(DIR_ALL,tmpheal); owner->removeItem(); return true; Modified: trunk/src/objects/heart.h =================================================================== --- trunk/src/objects/heart.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/heart.h 2005-09-08 10:09:00 UTC (rev 157) @@ -7,7 +7,10 @@ */ class Heart : public Item { public: - Heart(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Heart"); + Heart(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Heart(); + static ParameterMap default_parameters; virtual bool act(Object* obj); + private: + Uint8 alife; }; Modified: trunk/src/objects/key.cpp =================================================================== --- trunk/src/objects/key.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/key.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -3,12 +3,19 @@ #include "objects_common.h" //this shouldn't be here #include "players_common.h" +#include "scenario.h" +#include "imgcache.h" +#include "sndcache.h" #include "key.h" -Key::Key(string imagename, Sint16 xcord, Sint16 ycord, string iname): - Item(imagename,xcord,ycord,iname), - au_key(NULL) { } +Key::Key(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Item(xcord,ycord,parameters) { + /* Parameters */ + if (!hasParam(parameters,"image")) anim_orig=loadAnimation(scenario->imgcache->loadImage(1,"key.bmp")); + if (hasParam(parameters,"audio_key")) au_key=scenario->sndcache->loadWAV(parameters["audio_key"]); + else au_key=NULL; +} Key::~Key() { } bool Key::act(Object* obj) { Modified: trunk/src/objects/key.h =================================================================== --- trunk/src/objects/key.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/key.h 2005-09-08 10:09:00 UTC (rev 157) @@ -7,8 +7,9 @@ */ class Key : public Item { public: - Key(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Key"); + Key(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Key(); + static ParameterMap default_parameters; virtual bool act(Object* obj); private: Mix_Chunk* au_key; Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/olaf.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -9,8 +9,8 @@ #include "olaf.h" -Olaf::Olaf(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Player(imagename,xcord,ycord,pname), +Olaf::Olaf(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Player(xcord,ycord,parameters), fart(V_FART) { anim_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); @@ -34,7 +34,7 @@ au_big=scenario->sndcache->loadWAV("unblob.wav"); au_fart=scenario->sndcache->loadWAV("fart1.wav"); au_hit=scenario->sndcache->loadWAV("fathit.wav"); - normal_size=anim_orig->getFrameDim(); + normal_size=pos; small_size=anim_small_right->getFrameDim(); } Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/olaf.h 2005-09-08 10:09:00 UTC (rev 157) @@ -16,8 +16,9 @@ */ class Olaf : public Player { public: - Olaf(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Olaf"); + Olaf(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Olaf(); + static ParameterMap default_parameters; /// Additionally checks if Olaf is small and how he wears his shield virtual void updateAnimState(); virtual void in_left(Uint16); Modified: trunk/src/objects/plant.cpp =================================================================== --- trunk/src/objects/plant.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/plant.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -7,15 +7,19 @@ #include "scenario.h" #include "plant.h" -Plant::Plant(string imagename, Sint16 xcord, Sint16 ycord, Uint16 trecover, string cname): - Monster(imagename,xcord,ycord,cname), - recover(trecover), - tcur(trecover) { - maxhealth=1; +Plant::Plant(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Monster(xcord,ycord,parameters) { + enemy_types|=(OTYPE_PLAYER); weapon=Weapon(-1,W_TOUCH); - au_hit=scenario->sndcache->loadWAV("creeper.wav"); - au_recover=au_hit; - enemy_types|=(OTYPE_PLAYER); + tcur=recover; + + /* Parameters */ + if (!hasParam(parameters,"health")) health=min(1,(int)maxhealth); + if (!hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV("creeper.wav"); + if (hasParam(parameters,"audio_recover")) au_recover=scenario->sndcache->loadWAV(parameters["audio_recover"]); + else au_recover=au_hit; + if (hasParam(parameters,"time_recover")) recover=atoi(parameters["recover"].c_str()); + else recover=3000; } Plant::~Plant() { } Modified: trunk/src/objects/plant.h =================================================================== --- trunk/src/objects/plant.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/plant.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,8 +5,9 @@ */ class Plant : public Monster { public: - Plant(string imagename, Sint16 xpos=0, Sint16 ypos=0, Uint16 dleft=3000, string name="Plant"); + Plant(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Plant(); + static ParameterMap default_parameters; virtual void touch(Object*); virtual void idle(Uint16); virtual Uint16 hit(Uint16 direction, Weapon& weap); Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/scorch.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -8,8 +8,8 @@ #include "scorch.h" -Scorch::Scorch(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Player(imagename,xcord,ycord,pname), +Scorch::Scorch(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Player(xcord,ycord,parameters), left_wings(SCORCH_MAX_WINGS), wing(V_FLY) { anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); Modified: trunk/src/objects/scorch.h =================================================================== --- trunk/src/objects/scorch.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/scorch.h 2005-09-08 10:09:00 UTC (rev 157) @@ -16,8 +16,9 @@ */ class Scorch : public Player { public: - Scorch(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Scorch"); + Scorch(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Scorch(); + static ParameterMap default_parameters; virtual void fall(Uint16); /// \brief Scorch uses his wings virtual void idle(Uint16); Modified: trunk/src/objects/spike.cpp =================================================================== --- trunk/src/objects/spike.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/spike.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -7,10 +7,13 @@ #include "scenario.h" #include "spike.h" -Spike::Spike(string imagename, Sint16 xcord, Sint16 ycord, Uint16 sdir, string oname): - Object(imagename,xcord,ycord,oname), - dir(sdir) { +Spike::Spike(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { weapon=Weapon(-10,W_TOUCH,WS_SPIKE); + + /* Parameters */ + if (hasParam(parameters,"direction")) dir=getDirFromString(parameters["direction"]); + else dir=DIR_UP; otype|=(DIR_ALL&(~dir)); } Spike::~Spike() { } Modified: trunk/src/objects/spike.h =================================================================== --- trunk/src/objects/spike.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/spike.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,8 +5,9 @@ */ class Spike : public Object { public: - Spike(string imagename, Sint16 xpos=0, Sint16 ypos=0, Uint16 dir=DIR_UP, string name="Spike"); + Spike(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Spike(); + static ParameterMap default_parameters; virtual void touch(Object*); private: Weapon weapon; Modified: trunk/src/objects/teleport.cpp =================================================================== --- trunk/src/objects/teleport.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/teleport.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -8,11 +8,15 @@ #include "teleport.h" -Teleporter::Teleporter(string imagename, Sint16 xcord, Sint16 ycord, Sint16 xExit, Sint16 yExit, string oname): - Object(imagename,xcord,ycord,oname), - au_tele(scenario->sndcache->loadWAV("teleprt.wav")) { - exit.x=xExit; - exit.y=yExit; +Teleporter::Teleporter(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { + /* Parameters */ + if (hasParam(parameters,"audio_teleport")) au_tele=scenario->sndcache->loadWAV(parameters["audio_teleport"]); + else au_tele=scenario->sndcache->loadWAV("teleprt.wav"); + if (hasParam(parameters,"exitx")) exit.x=atoi(parameters["exitx"].c_str()); + else exit.x=0; + if (hasParam(parameters,"exity")) exit.y=atoi(parameters["exity"].c_str()); + else exit.y=0; exit.w=exit.h=0; } Teleporter::~Teleporter() { } Modified: trunk/src/objects/teleport.h =================================================================== --- trunk/src/objects/teleport.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/teleport.h 2005-09-08 10:09:00 UTC (rev 157) @@ -12,8 +12,9 @@ /// \param xExit x coordinate of the exit position /// \param yExit y coordinate of the exit position /// \param name Name of this object - Teleporter(string imagename, Sint16 xpos=0, Sint16 ypos=0, Sint16 xExit=0, Sint16 yExit=0, string name="Teleporter"); + Teleporter(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Teleporter(); + static ParameterMap default_parameters; virtual bool act(Object* obj); private: /// \brief Exit position Modified: trunk/src/objects/trigger.cpp =================================================================== --- trunk/src/objects/trigger.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/trigger.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -2,13 +2,18 @@ #include "objectpools.h" #include "scenario.h" #include "objects_common.h" +#include "imgcache.h" #include "trigger.h" -Trigger::Trigger(string imagename, Sint16 xcord, Sint16 ycord, string targetname, string oname, string keyname): - Object(imagename,xcord,ycord,oname), - key(keyname) { - target=scenario->pool->getObject(targetname); +Trigger::Trigger(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { + /* Parameters */ + if (!hasParam(parameters,"image")) anim_orig=loadAnimation(scenario->imgcache->loadImage(1,"key.bmp")); + if (hasParam(parameters,"key")) key=parameters["key"]; + else key="Key"; + if (hasParam(parameters,"target")) target=scenario->pool->getObject(parameters["target"]); + else target=scenario->pool->getObject("Target"); } Trigger::~Trigger() { } Modified: trunk/src/objects/trigger.h =================================================================== --- trunk/src/objects/trigger.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/trigger.h 2005-09-08 10:09:00 UTC (rev 157) @@ -3,11 +3,13 @@ /** \brief Trigger + Always add triggers after their related objects! */ class Trigger : public Object { public: - Trigger(string imagename, Sint16 xcord=0, Sint16 ycord=0, string targetname="DefaultTarget", string oname="Trigger", string keyname=""); + Trigger(Sint16 xcord=0, Sint16 ycord=0, ParameterMap& parameters=ParameterMap()); virtual ~Trigger(); + static ParameterMap default_parameters; virtual bool act(Object* obj); private: Object* target; Modified: trunk/src/objects/triggered_bomb.cpp =================================================================== --- trunk/src/objects/triggered_bomb.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/triggered_bomb.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -6,12 +6,16 @@ #include "scenario.h" #include "triggered_bomb.h" -TriggeredBomb::TriggeredBomb(string imagename, Sint16 xcord, Sint16 ycord, Uint16 tleft, string cname): - Character(imagename,xcord,ycord,cname), - countdown(tleft), - au_bomb(scenario->sndcache->loadWAV("explsn.wav")) { +TriggeredBomb::TriggeredBomb(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Character(xcord,ycord,parameters) { weapon=Weapon(-1,W_EXPLOSION); enemy_types|=(OTYPE_PLAYER|OTYPE_MONSTER); + + /* Parameters */ + if (hasParam(parameters,"audio_bomb")) au_bomb=scenario->sndcache->loadWAV(parameters["audio_bomb"]); + else au_bomb=scenario->sndcache->loadWAV("explsn.wav"); + if (hasParam(parameters,"countdown")) countdown=atoi(parameters["countdown"].c_str()); + else countdown=3000; } TriggeredBomb::~TriggeredBomb() { } Modified: trunk/src/objects/triggered_bomb.h =================================================================== --- trunk/src/objects/triggered_bomb.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/triggered_bomb.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,8 +5,9 @@ */ class TriggeredBomb : public Character { public: - TriggeredBomb(string imagename, Sint16 xpos=0, Sint16 ypos=0, Uint16 dleft=3000, string name="TriggeredBomb"); + TriggeredBomb(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~TriggeredBomb(); + static ParameterMap default_parameters; virtual void idle(Uint16); private: Sint16 countdown; Modified: trunk/src/objects/wall.cpp =================================================================== --- trunk/src/objects/wall.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/wall.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -3,8 +3,8 @@ #include "wall.h" -Wall::Wall(string imagename, Sint16 xcord, Sint16 ycord, string oname): - Object(imagename,xcord,ycord,oname) { +Wall::Wall(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { otype=OTYPE_DENSE; } Wall::~Wall() { } Modified: trunk/src/objects/wall.h =================================================================== --- trunk/src/objects/wall.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/wall.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,6 +5,7 @@ */ class Wall : public Object { public: - Wall(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Wall"); + Wall(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Wall(); + static ParameterMap default_parameters; }; Modified: trunk/src/objects/water.cpp =================================================================== --- trunk/src/objects/water.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/water.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -9,10 +9,12 @@ #include "water.h" -Water::Water(string imagename, Sint16 xcord, Sint16 ycord, string oname): - Object(imagename,xcord,ycord,oname), - au_water(scenario->sndcache->loadWAV("splash2.wav")) { +Water::Water(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { weapon=Weapon(-1,W_WATER,WS_WATER); + /* Parameters */ + if (hasParam(parameters,"audio_water_land")) au_water=scenario->sndcache->loadWAV(parameters["audio_water_land"]); + else au_water=scenario->sndcache->loadWAV("splash2.wav"); } Water::~Water() { } Modified: trunk/src/objects/water.h =================================================================== --- trunk/src/objects/water.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/water.h 2005-09-08 10:09:00 UTC (rev 157) @@ -6,8 +6,9 @@ */ class Water : public Object { public: - Water(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Water"); + Water(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Water(); + static ParameterMap default_parameters; virtual void enter(Object* obj); virtual void leave(Object* obj); protected: Modified: trunk/src/objects/wind.cpp =================================================================== --- trunk/src/objects/wind.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/wind.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -4,9 +4,12 @@ #include "characters_common.h" #include "wind.h" -Wind::Wind(string imagename, Sint16 xcord, Sint16 ycord, Sint16 Accel, string oname): - Object(imagename,xcord,ycord,oname), - gravitymod(Accel) { } +Wind::Wind(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters) { + /* Parameters */ + if (hasParam(parameters,"accel")) gravitymod=atoi(parameters["accel"].c_str()); + else gravitymod=0; +} Wind::~Wind() { } void Wind::enter(Object *obj) { Modified: trunk/src/objects/wind.h =================================================================== --- trunk/src/objects/wind.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/wind.h 2005-09-08 10:09:00 UTC (rev 157) @@ -6,8 +6,9 @@ */ class Wind : public Object { public: - Wind(string imagename, Sint16 xpos=0, Sint16 ypos=0, Sint16 Accel=0, string name="Wind"); + Wind(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Wind(); + static ParameterMap default_parameters; virtual void enter(Object* obj); virtual void leave(Object* obj); private: Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/zombie.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -10,14 +10,17 @@ #include "zombie.h" -Zombie::Zombie(string imagename, Sint16 xcord, Sint16 ycord, string mname): - Monster(imagename,xcord,ycord,mname), - au_attack(scenario->sndcache->loadWAV("clang.wav")), +Zombie::Zombie(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Monster(xcord,ycord,parameters), T_Attack_Bite(1500) { - maxspeedx=80; anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); weapon=Weapon(-1,W_STRIKE); + + /* Parameters */ + if (!hasParam(parameters,"maxspeedx")) maxspeedx=80; + if (hasParam(parameters,"audio_attack")) au_attack=scenario->sndcache->loadWAV(parameters["audio_attack"]); + else au_attack=scenario->sndcache->loadWAV("clang.wav"); } Zombie::~Zombie() { } Modified: trunk/src/objects/zombie.h =================================================================== --- trunk/src/objects/zombie.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects/zombie.h 2005-09-08 10:09:00 UTC (rev 157) @@ -8,8 +8,9 @@ */ class Zombie : public Monster { public: - Zombie(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Zombie"); + Zombie(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Zombie(); + static ParameterMap default_parameters; virtual void idle(Uint16); private: virtual void runAI(Uint16); Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects_common.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -7,18 +7,26 @@ #include "scenario.h" -Object::Object(string imagename, Sint16 xcord, Sint16 ycord, string oname): +Object::Object(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): state(NOTHING), event(NULL), otype(NOTHING), - name(oname), - delete_flag(false), - anim_orig(loadAnimation(scenario->imgcache->loadImage(1,imagename))) { - animation=anim_orig; - pos=animation->getFrameDim(); + delete_flag(false) { + onum=++scenario->max_obj_num; + animation.reset(new EmptyAnimation(&anim_orig)); + + /* Parameters */ + anim_orig=loadAnimation(parameters); + if (hasParam(parameters,"name")) name=parameters["name"]; + else name="Object"; + if (hasParam(parameters,"w")) pos.w=atoi(parameters["w"].c_str()); + else if (anim_orig->isValid()) pos.w=anim_orig->getFrameDim().w; + else pos.w=(Uint16)(DATA_LVLPLAYER_W*sqrt(config.lvlscale>=0 ? config.lvlscale : -1/config.lvlscale)+0.5); + if (hasParam(parameters,"h")) pos.h=atoi(parameters["h"].c_str()); + else if (anim_orig->isValid()) pos.h=anim_orig->getFrameDim().h; + else pos.h=(Uint16)(DATA_LVLPLAYER_H*sqrt(config.lvlscale>=0 ? config.lvlscale : -1/config.lvlscale)+0.5); pos.x=xcord; pos.y=ycord; - onum=++scenario->max_obj_num; } Object::~Object() { @@ -30,7 +38,7 @@ else return false; } -bool Object::isIn(const SDL_Rect& rect, bool touch) { +bool Object::isIn(const SDL_Rect& rect, bool touch) const { if (touch) { if ((pos.x+pos.w) > rect.x && pos.x < (rect.x+rect.w) && (pos.y+pos.h) > rect.y && pos.y < (rect.y+rect.h)) return true; else return false; @@ -128,6 +136,11 @@ return anim; } +EmptyAnimationPtr Object::loadAnimation(ParameterMap& parameters) { + if (hasParam(parameters,"image")) return loadAnimation(scenario->imgcache->loadImage(1,parameters["image"])); + return EmptyAnimationPtr(new EmptyAnimation()); +} + SDL_Rect Object::getDrawPos() const { return animation->getDrawPos(); } @@ -197,15 +210,21 @@ } -Item::Item(string imagename, Sint16 xcord, Sint16 ycord, string iname): - Object(imagename,xcord,ycord,iname), owner(NULL) { +Item::Item(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Object(xcord,ycord,parameters), owner(NULL) { otype|=OTYPE_ITEM; } Item::~Item() { } -Background::Background(string imagename): - Object(imagename,0,0,"Background") { +Background::Background(ParameterMap& parameters): + Object(0,0,parameters) { otype=NOTHING; + name="Background"; + + /* Parameters */ + /* TODO: support surface creation and use it as a fallback if no image was specified */ + anim_orig=loadAnimation(parameters); + pos=anim_orig->getFrameDim(); } Background::~Background() { } Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/objects_common.h 2005-09-08 10:09:00 UTC (rev 157) @@ -36,15 +36,16 @@ */ class Object { public: - Object(string imagename, Sint16 xpos=0, Sint16 ypos=0, string name="Object"); + Object(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Object(); + static ParameterMap default_parameters; /// Sets the new position. If the coordinates are not in the map area /// they are corrected to fit into it. /// \return True if no correction was needed bool setPos(Sint16 xcord,Sint16 ycord); /// \brief Returns the center of an object /// \return Center position of the object with width=height=0 - SDL_Rect getCenter() { + SDL_Rect getCenter() const { SDL_Rect tmprect; tmprect.x=pos.x+Uint16(pos.w/2); tmprect.y=pos.y+Uint16(pos.h/2); @@ -57,7 +58,7 @@ /// \param touch If true an overlapping region is enough, if false /// the object center has to be inside the specified area. /// \return True if the object is inside - bool isIn(const SDL_Rect& rect, bool touch=false); + bool isIn(const SDL_Rect& rect, bool touch=false) const; SDL_Rect* getPos() { return &pos; } @@ -120,6 +121,8 @@ double afps=0, Uint16 astart_pos=0, AllignType aallign_type=AT_MD); + /// Load an animation based on a parameter map + EmptyAnimationPtr loadAnimation(ParameterMap& parameters=ParameterMap()); //Events (triggered animations/effects) //@{ /// Clears the event field (sets it to NULL). This should only be used by @@ -199,8 +202,9 @@ */ class Item : public Object { public: - Item(string img, Sint16 xpos=0, Sint16 ypos=0, string name="Item"); + Item(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Item(); + static ParameterMap default_parameters; virtual bool act(Object*) { return false; } /// Assigns the item a new (player) owner void setOwner(Player* plr) { @@ -215,8 +219,9 @@ */ class Background : public Object { public: - Background(string imagename); + Background(ParameterMap& parameters=ParameterMap()); virtual ~Background(); + static ParameterMap default_parameters; }; #endif Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/players_common.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -13,8 +13,8 @@ #include "players_common.h" -Player::Player(string imagename, Sint16 xcord, Sint16 ycord, string pname): - Character(imagename,xcord,ycord,pname), +Player::Player(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Character(xcord,ycord,parameters), currentitem(0), anim_left(new EmptyAnimation(&anim_right)), anim_right(new EmptyAnimation()), @@ -49,10 +49,6 @@ anim_fall_middle(new EmptyAnimation(&anim_fall_right)), anim_climb(new EmptyAnimation(&anim_right)), anim_bar(new EmptyAnimation(&anim_right)) { - health=3; - maxhealth=4; - maxspeedx=300; - maxspeedy=200; for (Uint8 i=0; isndcache->loadWAV("fireball.wav"); au_die=scenario->sndcache->loadWAV("bones.wav"); au_heal=scenario->sndcache->loadWAV("usefood1.wav"); + + /* Parameters */ + if (!hasParam(parameters,"maxhealth")) maxhealth=4; + if (!hasParam(parameters,"health")) health=min(3,(int)maxhealth); + if (!hasParam(parameters,"maxspeedx")) maxspeedx=300; + if (!hasParam(parameters,"maxspeedy")) maxspeedy=200; } Player::~Player() { @@ -309,7 +311,9 @@ if (newhealth==0) { die(); //should be !=NULL or sthg is wrong with the placement code... - Character* deadplr=scenario->pool->addCharacter(new DeadPlayer("dead_player.bmp",pos.x,pos.y)); + ParameterMap deadplr_parameters; + deadplr_parameters["image"]="dead_player.bmp"; + Character* deadplr=scenario->pool->addCharacter(new DeadPlayer(pos.x,pos.y,deadplr_parameters)); switch(weap.getSubType()) { case WS_FIRE: { if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? anim_die_burn_left : anim_die_burn_right)); @@ -390,6 +394,7 @@ return newhealth; } -DeadPlayer::DeadPlayer(string imagename, Sint16 xcord, Sint16 ycord, string name): - Character(imagename,xcord,ycord,name) { } +DeadPlayer::DeadPlayer(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): + Character(xcord,ycord,parameters) { +} DeadPlayer::~DeadPlayer() { } Modified: trunk/src/players_common.h =================================================================== --- trunk/src/players_common.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/players_common.h 2005-09-08 10:09:00 UTC (rev 157) @@ -17,8 +17,9 @@ */ class Player : public Character { public: - Player(string img, Sint16 xpos=0, Sint16 ypos=0, string name="Player"); + Player(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Player(); + static ParameterMap default_parameters; //@{ /// \brief Returns the icon of this Player /// \return Single icon frame of this player (used for the player bar) @@ -174,8 +175,9 @@ */ class DeadPlayer : public Character { public: - DeadPlayer(string imagename, Sint16 xcord=0, Sint16 ycord=0, string name="DeadPlayer"); + DeadPlayer(Sint16 xcord=0, Sint16 ycord=0, ParameterMap& parameters=ParameterMap()); virtual ~DeadPlayer(); + static ParameterMap default_parameters; }; #endif Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/scenario.cpp 2005-09-08 10:09:00 UTC (rev 157) @@ -60,9 +60,10 @@ failed=false; } -void Scenario::newMap(string bgimage) { +void Scenario::newMap(const ParameterMap& bg_parameters) { mapbuf.clear(); - mapbuf.push_back("Background "+bgimage); + mapbuf.push_back("Background "+putParameters(bg_parameters)); + mapbuf.push_back("#ENDHEADER"); } int Scenario::loadMapBuf(string mapn) { mapname=mapn; @@ -90,69 +91,55 @@ int Scenario::reloadMap() { reinitMap(); - string image; - string cname,arg1,arg2,arg3; + string cname; Uint16 x,y; - bool header=false; + ParameterMap parameters; + bool header=true; //check every line for (Uint16 linenum=0; linenum> cname >> arg1 >> arg2 >> arg3; + tmpstream >> cname; if (cname[0]=='#') { if (cname=="#ENDHEADER") header=false; continue; + } else { + string parameterlist((istreambuf_iterator(tmpstream)), istreambuf_iterator()); + parameters=getParameters(parameterlist); + if (cname=="Background" && (!background)) { + background=new Background(parameters); + if (background) { + area=background->getPos(); + bgimage=parameters["image"]; + } + } } - continue; - } - cname.erase(); - image.erase(); - x=0; - y=0; - arg1=arg2=arg3=""; - std::istringstream tmpstream(mapbuf[linenum]); - tmpstream >> cname >> image >> x >> y >> arg1 >> arg2 >> arg3; - - //Skip empty lines - if (cname.empty()) continue; - //Skip comments - if (cname[0]=='#') { - if (cname=="#HEADER") header=true; - continue; - } - - if (cname=="Background" && (!background)) { - background=new Background(image); - if (background) { - area=background->getPos(); - bgimage=image; - } - //Background has to be first! + // Background has to be loaded... } else if (background) { - pool->addObjectbyName(cname,image,x,y,arg1,arg2,arg3); + cname.erase(); + x=y=0; + std::istringstream tmpstream(mapbuf[linenum]); + tmpstream >> cname >> x >> y; + //Skip empty lines + if (cname.empty()) continue; + if (cname[0]=='#') continue; + + string parameterlist((istreambuf_iterator(tmpstream)), istreambuf_iterator()); + parameters=getParameters(parameterlist); + pool->addObjectbyName(cname,x,y,parameters); } else { - cout << "No background found yet, skipping " << cname << " ...\n"; + cout << "Map loading failed: No background found!" << endl; + return 1; } } sfxeng->playMusic((config.datadir + "01theme.wav").c_str()); - - //Has a background been found? - if (background) { - if (pool->playerspool.size()>0) player=*pool->playerspool.begin(); - else player=NULL; - if (player==NULL) cout << "No player found!\n"; - return 0; - } else { - cout << "Map loading failed: No background found!\n"; - return 1; - } + if (pool->playerspool.size()>0) player=*pool->playerspool.begin(); + else player=NULL; + if (player==NULL) cout << "No player found!\n"; + return 0; } int Scenario::loadMap(string mapn) { Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-06 20:16:53 UTC (rev 156) +++ trunk/src/scenario.h 2005-09-08 10:09:00 UTC (rev 157) @@ -5,18 +5,23 @@ Loads the corresponding map data (objects) and performs location checks. \remarks MAP FORMAT: - \remarks "Object class name" "Base image name" "x position" "y position" - "Arg1" "Arg2" "Arg3" - \remarks Each Object handels the arguments for itself, usually "Arg1" - specifies the object name (if the object has no further parameters) + \remarks HeaderOption "parameters" + \remarks Background "parameters" + \remarks #ENDHEADER + \remarks "Object class name" "x position" "y position" "parameters" + \remarks The parameters depend on the object: Each object checks it's + corresponding parameters. + \remarks The parameter format is like this: + \remarks option1=value1,option2=value2,... + \remakrs A value may be a parameterlist of suboptions: + \remarks option1=subopt1=subval1:subopt2=subval2:...,option2=value2 \remarks Defaults: \remarks x and y default to 0 \remarks Example: - \remarks Background background.bmp - \remarks Teleporter teleporter.bmp 0 0 20 100 teleporter1 - \todo Improve the map format (eg. support headers) + \remarks Background image=background.bmp + \remarks #ENDHEADER + \remarks Teleporter 0 0 image=teleporter.bmp,exitx=20,exity=100,name=teleporter1 \todo Move the Caches into the current map as well? - \todo Create a map class inside Scenario? */ class Scenario { public: @@ -64,7 +69,7 @@ /// Physic Handler PhysicHandler* physic; /// Create a new empty map with the specified background - void newMap(string bgname); + void newMap(const ParameterMap& bg_parameters); /// Used to load the map file into a buffer int loadMapBuf(string mapname); /// Reload the map file using the buffered map file From DONOTREPLY at icculus.org Thu Sep 8 06:12:39 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 06:12:39 -0400 Subject: r158 - trunk/src Message-ID: <20050908101239.3815.qmail@icculus.org> Author: jonas Date: 2005-09-08 06:12:39 -0400 (Thu, 08 Sep 2005) New Revision: 158 Modified: trunk/src/objectpools.cpp Log: 10l, forgot Geyser Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-08 10:09:00 UTC (rev 157) +++ trunk/src/objectpools.cpp 2005-09-08 10:12:39 UTC (rev 158) @@ -39,6 +39,7 @@ ParameterMap Wall::default_parameters; ParameterMap Water::default_parameters; ParameterMap Wind::default_parameters; +ParameterMap Geyser::default_parameters; ParameterMap Spike::default_parameters; ParameterMap Item::default_parameters; @@ -101,6 +102,8 @@ Trigger::default_parameters["image"]="key.bmp"; Trigger::default_parameters["key"]="Key"; Trigger::default_parameters["target"]="Target"; + Geyser::default_parameters=Object::default_parameters; + Geyser::default_parameters["aspeed"]="0"; Spike::default_parameters=Object::default_parameters; Spike::default_parameters["direction"]="up"; From DONOTREPLY at icculus.org Thu Sep 8 06:18:00 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 06:18:00 -0400 Subject: r159 - in trunk/src: . objects Message-ID: <20050908101800.4602.qmail@icculus.org> Author: jonas Date: 2005-09-08 06:18:00 -0400 (Thu, 08 Sep 2005) New Revision: 159 Modified: trunk/src/objects/teleport.h trunk/src/scenario.h Log: updated doxygen to report (almost) no errors Modified: trunk/src/objects/teleport.h =================================================================== --- trunk/src/objects/teleport.h 2005-09-08 10:12:39 UTC (rev 158) +++ trunk/src/objects/teleport.h 2005-09-08 10:18:00 UTC (rev 159) @@ -6,12 +6,6 @@ */ class Teleporter : public Object { public: - /// \param imagename Name of the image file used to display this object - /// \param xpos x coordinate of the object position - /// \param ypos y coordinate of the object position - /// \param xExit x coordinate of the exit position - /// \param yExit y coordinate of the exit position - /// \param name Name of this object Teleporter(Sint16 xpos=0, Sint16 ypos=0, ParameterMap& parameters=ParameterMap()); virtual ~Teleporter(); static ParameterMap default_parameters; Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-08 10:12:39 UTC (rev 158) +++ trunk/src/scenario.h 2005-09-08 10:18:00 UTC (rev 159) @@ -7,19 +7,19 @@ \remarks MAP FORMAT: \remarks HeaderOption "parameters" \remarks Background "parameters" - \remarks #ENDHEADER + \remarks \#ENDHEADER \remarks "Object class name" "x position" "y position" "parameters" \remarks The parameters depend on the object: Each object checks it's corresponding parameters. \remarks The parameter format is like this: \remarks option1=value1,option2=value2,... - \remakrs A value may be a parameterlist of suboptions: + \remarks A value may be a parameterlist of suboptions: \remarks option1=subopt1=subval1:subopt2=subval2:...,option2=value2 \remarks Defaults: \remarks x and y default to 0 \remarks Example: \remarks Background image=background.bmp - \remarks #ENDHEADER + \remarks \#ENDHEADER \remarks Teleporter 0 0 image=teleporter.bmp,exitx=20,exity=100,name=teleporter1 \todo Move the Caches into the current map as well? */ From DONOTREPLY at icculus.org Thu Sep 8 06:21:51 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 06:21:51 -0400 Subject: r160 - in trunk: . data Message-ID: <20050908102151.5183.qmail@icculus.org> Author: jonas Date: 2005-09-08 06:21:51 -0400 (Thu, 08 Sep 2005) New Revision: 160 Added: trunk/data/ trunk/data/README trunk/data/lv1.sce trunk/data/map1.cfg trunk/data/map2.cfg Log: added a basic data directory Added: trunk/data/README =================================================================== --- trunk/data/README 2005-09-08 10:18:00 UTC (rev 159) +++ trunk/data/README 2005-09-08 10:21:51 UTC (rev 160) @@ -0,0 +1,2 @@ +This is the data directory of lost_penguins. Extract all data into this +directoy: images, sounds, animation files, image descriptions, maps, scenarios \ No newline at end of file Added: trunk/data/lv1.sce =================================================================== --- trunk/data/lv1.sce 2005-09-08 10:18:00 UTC (rev 159) +++ trunk/data/lv1.sce 2005-09-08 10:21:51 UTC (rev 160) @@ -0,0 +1,5 @@ +#HEADER +#ENDHEADER + +map1 +map2 Added: trunk/data/map1.cfg =================================================================== --- trunk/data/map1.cfg 2005-09-08 10:18:00 UTC (rev 159) +++ trunk/data/map1.cfg 2005-09-08 10:21:51 UTC (rev 160) @@ -0,0 +1,23 @@ +Background image=background.jpg +#ENDHEADER + +Wall 0 200 image=viking1.bmp +Wall 100 200 image=viking1.bmp +Wall 450 400 image=viking1.bmp +Wall 750 500 image=viking1.bmp +Wall 100 620 image=viking1.bmp +#Water 624 668 image=water.bmp +Exit 500 648 image=exit.bmp +Teleporter 750 400 image=viking1.bmp, exitx=100, exity=0 +Heart 100 400 image=apple.bmp +Heart 500 200 image=heart.bmp +#Wind 624 668 image=water.bmp,accel=-3000 + +Zombie 300 550 +#Plant 100 0 time_recover=5000 + +Erik +#Baleog +Olaf 0 5 +Scorch 0 10 +Fang 30 10 Added: trunk/data/map2.cfg =================================================================== --- trunk/data/map2.cfg 2005-09-08 10:18:00 UTC (rev 159) +++ trunk/data/map2.cfg 2005-09-08 10:21:51 UTC (rev 160) @@ -0,0 +1,35 @@ +Background image=background.jpg +#ENDHEADER + +#Objects +Wall 0 0 image=viking1.bmp +Wall 96 0 image=viking1.bmp +Wall 192 0 image=viking1.bmp +Wall 0 200 image=viking1.bmp +Wall 96 200 image=viking1.bmp +Wall 250 200 image=viking1.bmp +Door 326 96 image=viking1.bmp,key=Lock,name=Door1 +Key 350 668 image=key.bmp,name=Key1 +Trigger 280 120 image=key.bmp,key=Key1,target=Door1,name=Lock +Heart 300 668 image=heart.bmp +Bomb 400 400 image=bomb_fire.bmp,image_bomb=bomb_fire.bmp,countdown=3000 +Spike 0 640 image=viking1.bmp,direction=upright + +Wall 450 400 image=viking1.bmp +Wall 750 500 image=viking1.bmp +#Water 624 668 image=water.png +#Wind 600 550 image=teleport_01.bmp,accel=-2000 +Exit 500 648 image=exit.bmp +Teleporter 736 306 image=viking1.bmp,exitx=900,exity=300 +Geyser 200 668 image=viking1.bmp,aspeed=-1200 + +#Vikings +Fang 0 116 +Erik 0 116 +Olaf 0 116 +#Scorch 0 116 +#Baleog 0 116 + +#Monsters +#Zombie 50 116 name=Zombie1 +Zombie 300 550 name=Zombie2 From DONOTREPLY at icculus.org Thu Sep 8 10:21:52 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 10:21:52 -0400 Subject: r161 - in trunk: data src Message-ID: <20050908142152.3861.qmail@icculus.org> Author: jonas Date: 2005-09-08 10:21:52 -0400 (Thu, 08 Sep 2005) New Revision: 161 Modified: trunk/data/README trunk/src/objectpools.cpp trunk/src/objects_common.cpp Log: improved loadAnimation support with parameters a lot Modified: trunk/data/README =================================================================== --- trunk/data/README 2005-09-08 10:21:51 UTC (rev 160) +++ trunk/data/README 2005-09-08 14:21:52 UTC (rev 161) @@ -1,2 +1,2 @@ This is the data directory of lost_penguins. Extract all data into this -directoy: images, sounds, animation files, image descriptions, maps, scenarios \ No newline at end of file +directoy: images, sounds, animation files, image descriptions, maps, scenarios Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-08 10:21:51 UTC (rev 160) +++ trunk/src/objectpools.cpp 2005-09-08 14:21:52 UTC (rev 161) @@ -80,6 +80,7 @@ Object::default_parameters["name"]=""; Object::default_parameters["w"]=""; Object::default_parameters["h"]=""; + Object::default_parameters["anim"]=""; Object::default_parameters["image"]=""; Background::default_parameters=Object::default_parameters; Exit::default_parameters=Object::default_parameters; Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-08 10:21:51 UTC (rev 160) +++ trunk/src/objects_common.cpp 2005-09-08 14:21:52 UTC (rev 161) @@ -16,7 +16,15 @@ animation.reset(new EmptyAnimation(&anim_orig)); /* Parameters */ - anim_orig=loadAnimation(parameters); + if (hasParam(parameters,"anim")) { + ParameterMap anim_param=getParameters(parameters["anim"],':'); + anim_orig=loadAnimation(anim_param); + } else if (hasParam(parameters,"image")) { + ParameterMap anim_param; + anim_param["image"]=parameters["image"]; + anim_param["image_hor_frames"]="1"; + anim_orig=loadAnimation(anim_param); + } else anim_orig=EmptyAnimationPtr(new EmptyAnimation()); if (hasParam(parameters,"name")) name=parameters["name"]; else name="Object"; if (hasParam(parameters,"w")) pos.w=atoi(parameters["w"].c_str()); @@ -137,8 +145,73 @@ } EmptyAnimationPtr Object::loadAnimation(ParameterMap& parameters) { - if (hasParam(parameters,"image")) return loadAnimation(scenario->imgcache->loadImage(1,parameters["image"])); + double scale_factor=1; + BasePointType bp_type=BP_MD; + Uint16 animation_type=ATYPE_LOOP; + double fps=0; + AllignType allign_type=AT_MD; + + if (hasParam(parameters,"scale")) scale_factor=atof(parameters["scale"].c_str()); + if (hasParam(parameters,"bp_type")) { +// TODO + } + if (hasParam(parameters,"type")) { +// TODO + } + if (hasParam(parameters,"fps")) fps=atof(parameters["fps"].c_str()); + if (hasParam(parameters,"allign_type")) { +// TODO + } + + /* Use animation name */ + if (hasParam(parameters,"name")) { + string anim_name=parameters["name"]; + return loadAnimation(anim_name,scale_factor,bp_type,animation_type,fps,allign_type); + + /* Use a base image */ + } else if (hasParam(parameters,"image")) { + string image_name=parameters["image"]; + Uint16 frames=1; + Uint16 start_pos=0; + if (hasParam(parameters,"frames")) frames=atoi(parameters["frames"].c_str()); + if (hasParam(parameters,"start_pos")) start_pos=atoi(parameters["start_pos"].c_str()); + + /* threat as horizontal animation (constant width, height) with frames */ + if (hasParam(parameters,"image_hor_frames")) { + Uint16 image_hor_frames=atoi(parameters["image_hor_frames"].c_str()); + return loadAnimation(scenario->imgcache->loadImage(image_hor_frames,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type); + + /* threat as horizontal animation (constant width, height) with width and an optional shift */ + } else if (hasParam(parameters,"image_hor_width")) { + Uint16 image_hor_width=atoi(parameters["image_hor_width"].c_str()); + Uint16 image_hor_shift=0; + if (hasParam(parameters,"image_hor_shift")) image_hor_shift=atoi(parameters["image_hor_shift"].c_str()); + return loadAnimation(scenario->imgcache->loadImage(image_hor_width,image_hor_shift,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type); + + /* threat as constant width/height animation based on a base rectangle */ + } else if (hasParam(parameters,"image_rect")) { + ParameterMap rect_param=getParameters(parameters["image_rect"],';'); + SDL_Rect rect; + rect.x=rect.y=0; + rect.w=rect.h=10; + if (hasParam(rect_param,"x")) rect.x=atoi(rect_param["x"].c_str()); + if (hasParam(rect_param,"y")) rect.y=atoi(rect_param["y"].c_str()); + if (hasParam(rect_param,"w")) rect.w=atoi(rect_param["w"].c_str()); + if (hasParam(rect_param,"h")) rect.h=atoi(rect_param["h"].c_str()); + return loadAnimation(scenario->imgcache->loadImage(rect,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type); + + /* get informations from an image description file */ + } else { + string image_desc=image_name+".dsc"; + if (hasParam(parameters,"image_desc")) image_desc=parameters["image_desc"]; + return loadAnimation(scenario->imgcache->loadImage(image_name,scale_factor,image_desc),frames,bp_type,animation_type,fps,start_pos,allign_type); + } + + /* no suitable animation found */ + } else { + cout << "Invalid animation parameters!" << endl; return EmptyAnimationPtr(new EmptyAnimation()); + } } SDL_Rect Object::getDrawPos() const { @@ -222,9 +295,6 @@ otype=NOTHING; name="Background"; - /* Parameters */ /* TODO: support surface creation and use it as a fallback if no image was specified */ - anim_orig=loadAnimation(parameters); - pos=anim_orig->getFrameDim(); } Background::~Background() { } From DONOTREPLY at icculus.org Thu Sep 8 11:12:53 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 11:12:53 -0400 Subject: r162 - trunk/src Message-ID: <20050908151253.8473.qmail@icculus.org> Author: jonas Date: 2005-09-08 11:12:53 -0400 (Thu, 08 Sep 2005) New Revision: 162 Modified: trunk/src/objects_common.cpp Log: finnished animation loading based on parameters Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-08 14:21:52 UTC (rev 161) +++ trunk/src/objects_common.cpp 2005-09-08 15:12:53 UTC (rev 162) @@ -153,14 +153,47 @@ if (hasParam(parameters,"scale")) scale_factor=atof(parameters["scale"].c_str()); if (hasParam(parameters,"bp_type")) { -// TODO + if (parameters["bp_type"].find("hleft") !=string::npos) { + if (parameters["bp_type"].find("vup") !=string::npos) bp_type=BP_LU; + else if (parameters["bp_type"].find("vmiddle") !=string::npos) bp_type=BP_LM; + else if (parameters["bp_type"].find("vdown") !=string::npos) bp_type=BP_LD; + } else if (parameters["bp_type"].find("hmiddle") !=string::npos) { + if (parameters["bp_type"].find("vup") !=string::npos) bp_type=BP_MU; + else if (parameters["bp_type"].find("vmiddle") !=string::npos) bp_type=BP_MM; + else if (parameters["bp_type"].find("vdown") !=string::npos) bp_type=BP_MD; + } else if (parameters["bp_type"].find("hright") !=string::npos) { + if (parameters["bp_type"].find("vup") !=string::npos) bp_type=BP_RU; + else if (parameters["bp_type"].find("vmiddle") !=string::npos) bp_type=BP_RM; + else if (parameters["bp_type"].find("vdown") !=string::npos) bp_type=BP_RD; + } } if (hasParam(parameters,"type")) { -// TODO + animation_type=NOTHING; + if (parameters["type"].find("once")) animation_type|=ATYPE_ONCE; + if (parameters["type"].find("loop")) animation_type|=ATYPE_LOOP; + if (parameters["type"].find("swing")) animation_type|=ATYPE_SWING; + if (parameters["type"].find("step")) animation_type|=ATYPE_STEP; + if (parameters["type"].find("reverse")) { + animation_type<<=1; + } + if (animation_type==NOTHING) animation_type=ATYPE_LOOP; + if (parameters["type"].find("switch")) animation_type|=ATYPE_ST_SWITCH; } if (hasParam(parameters,"fps")) fps=atof(parameters["fps"].c_str()); if (hasParam(parameters,"allign_type")) { -// TODO + if (parameters["allign_type"].find("hleft") !=string::npos) { + if (parameters["allign_type"].find("vup") !=string::npos) allign_type=AT_LU; + else if (parameters["allign_type"].find("vmiddle") !=string::npos) allign_type=AT_LM; + else if (parameters["allign_type"].find("vdown") !=string::npos) allign_type=AT_LD; + } else if (parameters["allign_type"].find("hmiddle") !=string::npos) { + if (parameters["allign_type"].find("vup") !=string::npos) allign_type=AT_MU; + else if (parameters["allign_type"].find("vmiddle") !=string::npos) allign_type=AT_MM; + else if (parameters["allign_type"].find("vdown") !=string::npos) allign_type=AT_MD; + } else if (parameters["allign_type"].find("hright") !=string::npos) { + if (parameters["allign_type"].find("vup") !=string::npos) allign_type=AT_RU; + else if (parameters["allign_type"].find("vmiddle") !=string::npos) allign_type=AT_RM; + else if (parameters["allign_type"].find("vdown") !=string::npos) allign_type=AT_RD; + } } /* Use animation name */ From DONOTREPLY at icculus.org Thu Sep 8 11:32:44 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 11:32:44 -0400 Subject: r163 - trunk/src/objects Message-ID: <20050908153244.9957.qmail@icculus.org> Author: jonas Date: 2005-09-08 11:32:44 -0400 (Thu, 08 Sep 2005) New Revision: 163 Modified: trunk/src/objects/fang.cpp Log: 10l Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-08 15:12:53 UTC (rev 162) +++ trunk/src/objects/fang.cpp 2005-09-08 15:32:44 UTC (rev 163) @@ -18,8 +18,8 @@ anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8); - anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8); + anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8,BP_MD,ATYPE_ONCE); + anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8,BP_MD,ATYPE_ONCE); au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav"); au_jump=scenario->sndcache->loadWAV("fangjump.wav"); From DONOTREPLY at icculus.org Thu Sep 8 18:04:27 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 8 Sep 2005 18:04:27 -0400 Subject: r164 - in trunk: . data src src/objects Message-ID: <20050908220427.12615.qmail@icculus.org> Author: jonas Date: 2005-09-08 18:04:26 -0400 (Thu, 08 Sep 2005) New Revision: 164 Added: trunk/data/erik.inf Modified: trunk/TODO trunk/data/lv1.sce trunk/data/map1.cfg trunk/data/map2.cfg trunk/src/common.cpp trunk/src/common.h trunk/src/editor.cpp trunk/src/monsters_common.cpp trunk/src/objectpools.cpp trunk/src/objects/baleog.cpp trunk/src/objects/baleog.h trunk/src/objects/erik.cpp trunk/src/objects/fang.cpp trunk/src/objects/fang.h trunk/src/objects/olaf.cpp trunk/src/objects/olaf.h trunk/src/objects/scorch.cpp trunk/src/objects/zombie.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/players_common.cpp Log: o Support for parameter loading from a file (file=): - The files are checked in getObjectbyName before loading the object - Added a new getFileParameters function - Erik's animation data is now completely file depending (added an erik.inf data file) o Added all animations and audio files as parameters (animations not under default_parameters though...) o Renamed some player animation names to include the name of the owner o loadAnimation now takes a const ParameterMap& o Fixed a few default options o Editor Boxes are now placed such that they are inside the screen Modified: trunk/TODO =================================================================== --- trunk/TODO 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/TODO 2005-09-08 22:04:26 UTC (rev 164) @@ -13,6 +13,7 @@ o Create a better class hierarchy so we don't have a class playground... o Better handle the different game states and replace the current conditional model o IDEA: create dynamical plugins for all objects (or compile all in) + o map is not time ordered => leads to unwanted behaviour in editor and filelists o Move/crash/collisions: o move should be a property of a common object Added: trunk/data/erik.inf =================================================================== --- trunk/data/erik.inf 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/data/erik.inf 2005-09-08 22:04:26 UTC (rev 164) @@ -0,0 +1,51 @@ +#ERIK +anim_left= name=erik_idle_left: scale=2: bp_type=rightdown +anim_right= name=erik_idle_right: scale=2: bp_type=leftdown +anim_rock_left= name=erik_rock_left: scale=2: bp_type=rightdown +anim_rock_right= name=erik_rock_right: scale=2: bp_type=leftdown +anim_walk_left= name=erik_walk_left: scale=2: bp_type=rightdown +anim_walk_right= name=erik_walk_right: scale=2: bp_type=leftdown +anim_push_left= name=erik_push_left: scale=2: bp_type=rightdown +anim_push_right= name=erik_push_right: scale=2: bp_type=leftdown +anim_fall_middle= name=erik_fall_middle: scale=2 +anim_fall_left= name=erik_fall_left: scale=2: bp_type=rightdown +anim_fall_right= name=erik_fall_right: scale=2: bp_type=leftdown +anim_fall_fast_left= name=erik_fall_fast_left: scale=2: bp_type=rightdown +anim_fall_fast_right= name=erik_fall_fast_right: scale=2: bp_type=leftdown +anim_crash_left= name=erik_crash_left: scale=2: bp_type=rightdown: type=once +anim_crash_right= name=erik_crash_right: scale=2: bp_type=leftdown: type=once +anim_rope_left= name=erik_rope_left: scale=2: bp_type=rightdown +anim_rope_right= name=erik_rope_right: scale=2: bp_type=leftdown +anim_teleport_left= name=erik_teleport_left: scale=2: bp_type=rightdown: type=once +anim_teleport_right= name=erik_teleport_right: scale=2: bp_type=leftdown: type=once +anim_die_crash_left= name=erik_die_crash_left: scale=2: bp_type=rightdown: type=once +anim_die_crash_right= name=erik_die_crash_right: scale=2: bp_type=leftdown: type=once +anim_die_burn_left= name=erik_die_burn_left: scale=2: bp_type=rightdown: type=once +anim_die_burn_right= name=erik_die_burn_right: scale=2: bp_type=leftdown: type=once +anim_die_bones_left= name=erik_die_bones_left: scale=2: bp_type=rightdown: type=once +anim_die_bones_right= name=erik_die_bones_right: scale=2: bp_type=leftdown: type=once +anim_die_elec_left= name=erik_die_elec_left: scale=2: bp_type=rightdown: type=once +anim_die_elec_right= name=erik_die_elec_right: scale=2: bp_type=leftdown: type=once +anim_die_spike_left= name=erik_die_spike_left: scale=2: bp_type=rightdown: type=once +anim_die_spike_right= name=erik_die_spike_right: scale=2: bp_type=leftdown: type=once +anim_bar= name=bar_erik: scale=2: type=once +#anim_die_water and anim_climb not specified + +anim_erik_jump_left= name=erik_jump_left: scale=2: bp_type=rightdown: type=once +anim_erik_jump_right= name=erik_jump_right: scale=2: bp_type=leftdown: type=once +anim_erik_jump2_left= name=erik_jump2_left: scale=2: bp_type=rightdown: type=once +anim_erik_jump2_right= name=erik_jump2_right: scale=2: bp_type=leftdown: type=once +anim_erik_start_run_left= name=erik_start_run_left: scale=2: bp_type=rightdown: type=once +anim_erik_start_run_right= name=erik_start_run_right: scale=2: bp_type=leftdown: type=once +anim_erik_run_left= name=erik_run_left: scale=2: bp_type=rightdown: type=once +anim_erik_run_right= name=erik_run_right: scale=2: bp_type=leftdown: type=once +anim_erik_swim_left= name=erik_swim_left: scale=2: bp_type=rightdown: type=once +anim_erik_swim_right= name=erik_swim_right: scale=2: bp_type=leftdown: type=once +anim_erik_swim_up_left= name=erik_swim_up_left: scale=2: bp_type=rightdown: type=once +anim_erik_swim_up_right= name=erik_swim_up_right: scale=2: bp_type=leftdown: type=once +anim_erik_hit_water_left= name=erik_hit_water_left: scale=2: bp_type=rightdown: type=once +anim_erik_hit_water_right= name=erik_hit_water_right: scale=2: bp_type=leftdown: type=once + +au_hit= erikhit.wav +au_jump= rboots.wav +#au_run not specified Modified: trunk/data/lv1.sce =================================================================== --- trunk/data/lv1.sce 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/data/lv1.sce 2005-09-08 22:04:26 UTC (rev 164) @@ -1,4 +1,3 @@ -#HEADER #ENDHEADER map1 Modified: trunk/data/map1.cfg =================================================================== --- trunk/data/map1.cfg 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/data/map1.cfg 2005-09-08 22:04:26 UTC (rev 164) @@ -16,7 +16,7 @@ Zombie 300 550 #Plant 100 0 time_recover=5000 -Erik +Erik file=erik.inf #Baleog Olaf 0 5 Scorch 0 10 Modified: trunk/data/map2.cfg =================================================================== --- trunk/data/map2.cfg 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/data/map2.cfg 2005-09-08 22:04:26 UTC (rev 164) @@ -25,7 +25,7 @@ #Vikings Fang 0 116 -Erik 0 116 +Erik 0 116 file=erik.inf Olaf 0 116 #Scorch 0 116 #Baleog 0 116 Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/common.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -34,6 +34,32 @@ return s.str(); } +ParameterMap getFileParameters(const string& filelist) { + istringstream filelist_s(filelist); + ifstream file; + string filename,parameterlist; + ParameterMap file_parameters, line_parameters; + ParameterMap::iterator it; + + while (std::getline(filelist_s,filename,':')) { + file.open((config.datadir+filename).c_str()); + if (!file) continue; + while (getline(file,parameterlist)) { + if (parameterlist.empty()) continue; + if (parameterlist[0]=='#') continue; + line_parameters=getParameters(parameterlist); + it=line_parameters.begin(); + while (it!=line_parameters.end()) { + file_parameters[(*it).first]=(*it).second; + ++it; + } + } + file.close(); + file.clear(); + } + return file_parameters; +} + ParameterMap getParameters(const string& parameterlist, char delim, char delimsub) { ParameterMap parameters; istringstream parameterlist_s(parameterlist); @@ -79,7 +105,7 @@ return parameterlist; } -bool hasParam(ParameterMap& parameters, const string& str) { +bool hasParam(const ParameterMap& parameters, const string& str) { if (parameters.find(str)!=parameters.end()) return true; else return false; } Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/common.h 2005-09-08 22:04:26 UTC (rev 164) @@ -210,12 +210,14 @@ /// \return 1 if the file was found, 0 otherwise /// \todo Create a better config format int readConfig(const string& filename); +/// Set parameters from files +ParameterMap getFileParameters(const string& filelist); /// Parse a string parameter list and return it as a map ParameterMap getParameters(const string& parameterlist, char delim=',', char delimsub='='); /// Convert the parameter map to a string string putParameters(const ParameterMap& parameters, char delim=',', char delimsub='='); /// Returns true if the parameter was found -bool hasParam(ParameterMap& parameters, const string& str); +bool hasParam(const ParameterMap& parameters, const string& str); /// Returns the direction from the given string: simply include one or a /// combination of "up", "down", "left", "right" in the string Uint16 getDirFromString(const string& str); Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/editor.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -117,6 +117,11 @@ } area.w=maxwidth+2*WFONT; area.h=entries.size()*(DFONT+font->getHeight())+2*WFONT+font_title->getHeight(); + + area.x+=min(0,(int)(scenario->area->w-area.x-area.w)); + area.y+=min(0,(int)(scenario->area->h-area.y-area.h)); + if (area.x<0) area.x=0; + if (area.y<0) area.y=0; return area; } Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/monsters_common.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -13,15 +13,17 @@ Monster::Monster(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): Character(xcord,ycord,parameters), Dai(0), - Dattack(0), - anim_left(new EmptyAnimation(&anim_right)), - anim_right(new EmptyAnimation()) { + Dattack(0) { state=STATE_FALL; otype|=OTYPE_MONSTER; enemy_types|=OTYPE_PLAYER; dense_types|=OTYPE_PLAYER; /* Parameters */ + if (hasParam(parameters,"anim_left")) anim_left=loadAnimation(getParameters(parameters["anim_left"],':')); + else anim_left.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_right")) anim_right=loadAnimation(getParameters(parameters["anim_right"],':')); + else anim_right.reset(new EmptyAnimation(&anim_orig)); if (!hasParam(parameters,"maxhealth")) maxhealth=1; if (!hasParam(parameters,"health")) health=min(1,(int)maxhealth); if (!hasParam(parameters,"maxspeedx")) maxspeedx=50; Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objectpools.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -77,6 +77,7 @@ while (i!=objectspool.end()) i=removeObject(i); } void ObjectsPool::setDefaultObjParam() { + Object::default_parameters["file"]=""; Object::default_parameters["name"]=""; Object::default_parameters["w"]=""; Object::default_parameters["h"]=""; @@ -122,7 +123,7 @@ Bomb::default_parameters["audio_bomb"]="explsn.wav"; Character::default_parameters=Object::default_parameters; - Character::default_parameters["maxhealth"]=1; + Character::default_parameters["maxhealth"]="1"; Character::default_parameters["health"]="1"; Character::default_parameters["maxspeedx"]="300"; Character::default_parameters["maxspeedy"]="0"; @@ -133,7 +134,9 @@ TriggeredBomb::default_parameters["audio_bomb"]="explsn.wav"; Monster::default_parameters=Character::default_parameters; - Monster::default_parameters["maxhealth"]=1; + Monster::default_parameters["anim_left"]=""; + Monster::default_parameters["anim_right"]=""; + Monster::default_parameters["maxhealth"]="1"; Monster::default_parameters["health"]="1"; Monster::default_parameters["maxspeedx"]="50"; Monster::default_parameters["maxspeedy"]="0"; @@ -151,11 +154,32 @@ Player::default_parameters["health"]="3"; Player::default_parameters["maxspeedx"]="300"; Player::default_parameters["maxspeedy"]="200"; + Player::default_parameters["audio_land"]="dizzy.wav"; + Player::default_parameters["audio_act"]="button.wav"; + Player::default_parameters["audio_useerror"]="useerror.wav"; + Player::default_parameters["audio_newitem"]="pickup.wav"; + Player::default_parameters["audio_hit"]="vikhit.wav"; + Player::default_parameters["audio_elec"]="elecdth.wav"; + Player::default_parameters["audio_drown"]="drown.wav"; + Player::default_parameters["audio_fire"]="fireball.wav"; + Player::default_parameters["audio_die"]="bones.wav"; + Player::default_parameters["audio_heal"]="usefood1.wav"; + Erik::default_parameters=Player::default_parameters; + Erik::default_parameters["audio_jump"]="rboots.wav"; + Erik::default_parameters["audio_run"]=""; Olaf::default_parameters=Player::default_parameters; + Olaf::default_parameters["audio_small"]="blob.wav"; + Olaf::default_parameters["audio_big"]="unblob.wav"; + Olaf::default_parameters["audio_fart"]="fart1.wav"; Scorch::default_parameters=Player::default_parameters; + Scorch::default_parameters["audio_swing"]="flapwngs.wav"; + Scorch::default_parameters["audio_tired"]="flwings.wav"; Fang::default_parameters=Player::default_parameters; + Fang::default_parameters["audio_jump"]="fangjump.wav"; + Fang::default_parameters["audio_claw"]="wolfjmp1.wav"; Baleog::default_parameters=Player::default_parameters; + Baleog::default_parameters["audio_sword"]="swrdsw2.wav"; } const ParameterMap& ObjectsPool::getDefaultObjParambyName(const string& obj) { @@ -190,7 +214,18 @@ else return empty_parameter; } -Object* ObjectsPool::addObjectbyName(const string& obj, Sint16 x, Sint16 y, ParameterMap& parameters) { +Object* ObjectsPool::addObjectbyName(const string& obj, Sint16 x, Sint16 y, ParameterMap& objparam) { + ParameterMap parameters; + if (hasParam(objparam,"file")) { + parameters=getFileParameters(objparam["file"]); + ParameterMap::iterator it=objparam.begin(); + while (it!=objparam.end()) { + if ((*it).first!="file") parameters[(*it).first]=(*it).second; + ++it; + } + } else { + parameters=objparam; + } //Set names... if (!hasParam(parameters,"name")) parameters["name"]=getNextObjectName(obj); @@ -207,6 +242,7 @@ else if (obj=="Key") return (addObject(new Key(x,y,parameters))); else if (obj=="Bomb") return (addObject(new Bomb(x,y,parameters))); else if (obj=="TriggeredBomb") return (addCharacter(new TriggeredBomb(x,y,parameters))); + else if (obj=="DeadPlayer") return (addCharacter(new DeadPlayer(x,y,parameters))); else if (obj=="Erik") return (addPlayer(new Erik(x,y,parameters))); else if (obj=="Olaf") return (addPlayer(new Olaf(x,y,parameters))); else if (obj=="Baleog") return (addPlayer(new Baleog(x,y,parameters))); Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/baleog.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -10,21 +10,28 @@ Baleog::Baleog(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): Player(xcord,ycord,parameters) { - anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); - anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); weapon=Weapon(-1,W_STRIKE); - anim_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE); - anim_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE); - au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); + + /* Parameters */ + if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + if (!hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); + if (!hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); + if (!hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); + if (!hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); + + if (hasParam(parameters,"anim_baleog_sword_left")) anim_baleog_sword_left=loadAnimation(getParameters(parameters["anim_baleog_sword_left"],':')); + else anim_baleog_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE); + if (hasParam(parameters,"anim_baleog_sword_right")) anim_baleog_sword_left=loadAnimation(getParameters(parameters["anim_baleog_sword_right"],':')); + else anim_baleog_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE); + + if (hasParam(parameters,"audio_sword")) au_sword=scenario->sndcache->loadWAV(parameters["audio_sword"]); + else au_sword=scenario->sndcache->loadWAV("swrdsw2.wav"); } Baleog::~Baleog() { } //Baleog1: Sword attack void Baleog::in_sp1() { - setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_sword_left : anim_sword_right)); + setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_sword,(state&STATE_LEFT) ? anim_baleog_sword_left : anim_baleog_sword_right)); } Modified: trunk/src/objects/baleog.h =================================================================== --- trunk/src/objects/baleog.h 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/baleog.h 2005-09-08 22:04:26 UTC (rev 164) @@ -12,6 +12,6 @@ virtual void in_sp1(); private: Mix_Chunk* au_sword; - EmptyAnimationPtr anim_sword_left; - EmptyAnimationPtr anim_sword_right; + EmptyAnimationPtr anim_baleog_sword_left; + EmptyAnimationPtr anim_baleog_sword_right; }; Modified: trunk/src/objects/erik.cpp =================================================================== --- trunk/src/objects/erik.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/erik.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -15,64 +15,29 @@ jump(V_JUMP), jump2(V_JUMP2) { weapon=Weapon(-1,W_PRESSURE,WS_PRESSURE); -/* - anim_left=loadAnimation(scenario->imgcache->loadImage("erik1_left.bmp")); - anim_right=loadAnimation(scenario->imgcache->loadImage(1,"erik1_right.bmp")); - anim_land_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_land_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); -*/ - anim_left=loadAnimation("erik_idle_left",config.lvlscale,BP_RD); - anim_right=loadAnimation("erik_idle_right",config.lvlscale,BP_LD); - anim_rock_left=loadAnimation("erik_rock_left",config.lvlscale,BP_RD); - anim_rock_right=loadAnimation("erik_rock_right",config.lvlscale,BP_LD); - anim_walk_left=loadAnimation("erik_walk_left",config.lvlscale,BP_RD); - anim_walk_right=loadAnimation("erik_walk_right",config.lvlscale,BP_LD); - anim_push_left=loadAnimation("erik_push_left",config.lvlscale,BP_RD); - anim_push_right=loadAnimation("erik_push_right",config.lvlscale,BP_LD); - anim_fall_middle=loadAnimation("erik_fall_middle",config.lvlscale); - anim_fall_left=loadAnimation("erik_fall_left",config.lvlscale,BP_RD); - anim_fall_right=loadAnimation("erik_fall_right",config.lvlscale,BP_LD); - anim_fall_fast_left=loadAnimation("erik_fall_fast_left",config.lvlscale,BP_RD); - anim_fall_fast_right=loadAnimation("erik_fall_fast_right",config.lvlscale,BP_LD); - anim_crash_left=loadAnimation("erik_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_crash_right=loadAnimation("erik_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_rope_left=loadAnimation("erik_rope_left",config.lvlscale,BP_RD); - anim_rope_right=loadAnimation("erik_rope_right",config.lvlscale,BP_LD); - anim_teleport_left=loadAnimation("erik_teleport_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_teleport_right=loadAnimation("erik_teleport_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_die_crash_left=loadAnimation("erik_die_crash_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_die_crash_right=loadAnimation("erik_die_crash_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_die_burn_left=loadAnimation("erik_die_burn_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_die_burn_right=loadAnimation("erik_die_burn_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_die_bones_left=loadAnimation("erik_die_bones_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_die_bones_right=loadAnimation("erik_die_bones_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_die_elec_left=loadAnimation("erik_die_elec_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_die_elec_right=loadAnimation("erik_die_elec_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_die_spike_left=loadAnimation("erik_die_spike_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_die_spike_right=loadAnimation("erik_die_spike_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_bar=loadAnimation("bar_erik",config.lvlscale,BP_MD,ATYPE_ONCE); - /* anim_die_water is missing as eric doesn't die under water, anim_climb is missing as well */ - anim_erik_jump_left=loadAnimation("erik_jump_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_jump_right=loadAnimation("erik_jump_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_erik_jump2_left=loadAnimation("erik_jump2_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_jump2_right=loadAnimation("erik_jump2_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_erik_start_run_left=loadAnimation("erik_start_run_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_start_run_right=loadAnimation("erik_start_run_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_erik_run_left=loadAnimation("erik_run_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_run_right=loadAnimation("erik_run_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_erik_swim_left=loadAnimation("erik_swim_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_swim_right=loadAnimation("erik_swim_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_erik_swim_up_left=loadAnimation("erik_swim_up_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_swim_up_right=loadAnimation("erik_swim_up_right",config.lvlscale,BP_LD,ATYPE_ONCE); - anim_erik_hit_water_left=loadAnimation("erik_hit_water_left",config.lvlscale,BP_RD,ATYPE_ONCE); - anim_erik_hit_water_right=loadAnimation("erik_hit_water_right",config.lvlscale,BP_LD,ATYPE_ONCE); + /* Parameters */ + if (hasParam(parameters,"anim_erik_jump_left")) anim_erik_jump_left=loadAnimation(getParameters(parameters["anim_erik_jump_left"],':')); + if (hasParam(parameters,"anim_erik_jump_right")) anim_erik_jump_right=loadAnimation(getParameters(parameters["anim_erik_jump_right"],':')); + if (hasParam(parameters,"anim_erik_jump2_left")) anim_erik_jump2_left=loadAnimation(getParameters(parameters["anim_erik_jump2_left"],':')); + if (hasParam(parameters,"anim_erik_jump2_right")) anim_erik_jump2_right=loadAnimation(getParameters(parameters["anim_erik_jump2_right"],':')); + if (hasParam(parameters,"anim_erik_start_run_left")) anim_erik_start_run_left=loadAnimation(getParameters(parameters["anim_erik_start_run_left"],':')); + if (hasParam(parameters,"anim_erik_start_run_right")) anim_erik_start_run_right=loadAnimation(getParameters(parameters["anim_erik_start_run_right"],':')); + if (hasParam(parameters,"anim_erik_run_left")) anim_erik_run_left=loadAnimation(getParameters(parameters["anim_erik_run_left"],':')); + if (hasParam(parameters,"anim_erik_run_right")) anim_erik_run_right=loadAnimation(getParameters(parameters["anim_erik_run_right"],':')); + if (hasParam(parameters,"anim_erik_swim_left")) anim_erik_swim_left=loadAnimation(getParameters(parameters["anim_erik_swim_left"],':')); + if (hasParam(parameters,"anim_erik_swim_right")) anim_erik_swim_right=loadAnimation(getParameters(parameters["anim_erik_swim_right"],':')); + if (hasParam(parameters,"anim_erik_swim_up_left")) anim_erik_swim_up_left=loadAnimation(getParameters(parameters["anim_erik_swim_up_left"],':')); + if (hasParam(parameters,"anim_erik_swim_up_right")) anim_erik_swim_up_right=loadAnimation(getParameters(parameters["anim_erik_swim_up_right"],':')); + if (hasParam(parameters,"anim_erik_hit_water_left")) anim_erik_hit_water_left=loadAnimation(getParameters(parameters["anim_erik_hit_water_left"],':')); + if (hasParam(parameters,"anim_erik_hit_water_right")) anim_erik_hit_water_right=loadAnimation(getParameters(parameters["anim_erik_hit_water_right"],':')); - au_jump=scenario->sndcache->loadWAV("rboots.wav"); - au_hit=scenario->sndcache->loadWAV("erikhit.wav"); - au_run=NULL; + if (!hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV("erikhit.wav"); + + if (hasParam(parameters,"audio_jump")) au_jump=scenario->sndcache->loadWAV(parameters["audio_jump"]); + else au_jump=scenario->sndcache->loadWAV("rboots.wav"); + if (hasParam(parameters,"audio_run")) au_jump=scenario->sndcache->loadWAV(parameters["audio_run"]); + else au_run=NULL; } Erik::~Erik() { } Modified: trunk/src/objects/fang.cpp =================================================================== --- trunk/src/objects/fang.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/fang.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -12,17 +12,26 @@ Player(xcord,ycord,parameters), jump(V_JUMP) { weapon=Weapon(-1,W_STRIKE); - anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); - anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); - anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); - anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8,BP_MD,ATYPE_ONCE); - anim_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8,BP_MD,ATYPE_ONCE); - au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); - au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav"); - au_jump=scenario->sndcache->loadWAV("fangjump.wav"); + + /* Parameters */ + if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_left.png"),4); + if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(4,"Fang_Breath_right.png"),4); + if (!hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_left.png"),8); + if (!hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_walk_right.png"),8); + if (!hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + if (!hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + + if (hasParam(parameters,"anim_fang_claw_left")) anim_fang_claw_left=loadAnimation(getParameters(parameters["anim_fang_claw_left"],':')); + else anim_fang_claw_left=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_left.png"),8,BP_MD,ATYPE_ONCE); + if (hasParam(parameters,"anim_fang_claw_right")) anim_fang_claw_right=loadAnimation(getParameters(parameters["anim_fang_claw_right"],':')); + else anim_fang_claw_right=loadAnimation(scenario->imgcache->loadImage(8,"Fang_Clawslash_right.png"),8,BP_MD,ATYPE_ONCE); + + if (!hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV("wolfhit.wav"); + + if (hasParam(parameters,"audio_claw")) au_claw=scenario->sndcache->loadWAV(parameters["audio_claw"]); + else au_claw=scenario->sndcache->loadWAV("wolfjmp1.wav"); + if (hasParam(parameters,"audio_jump")) au_jump=scenario->sndcache->loadWAV(parameters["audio_jump"]); + else au_jump=scenario->sndcache->loadWAV("fangjump.wav"); } Fang::~Fang() { } @@ -82,7 +91,7 @@ } void Fang::in_sp2() { - setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? anim_claw_left : anim_claw_right)); + setEvent(new EAttack(this,10,&weapon,(state&STATE_LEFT) ? DIR_LEFT : DIR_RIGHT,10,enemy_types,0,0,au_claw,(state&STATE_LEFT) ? anim_fang_claw_left : anim_fang_claw_right)); } void Fang::crash(Uint16 dir) { Modified: trunk/src/objects/fang.h =================================================================== --- trunk/src/objects/fang.h 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/fang.h 2005-09-08 22:04:26 UTC (rev 164) @@ -35,8 +35,8 @@ virtual void clearStates(bool reset=false); private: virtual void crash(Uint16 dir=DIR_DOWN); - EmptyAnimationPtr anim_claw_left; - EmptyAnimationPtr anim_claw_right; + EmptyAnimationPtr anim_fang_claw_left; + EmptyAnimationPtr anim_fang_claw_right; Mix_Chunk* au_jump; Mix_Chunk* au_claw; Sint16 jump; Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/olaf.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -12,30 +12,47 @@ Olaf::Olaf(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): Player(xcord,ycord,parameters), fart(V_FART) { - anim_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); - anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); - anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8); - anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE,25); + /* Parameters */ + if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); + if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); + if (!hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8); + if (!hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8); + if (!hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + if (!hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + if (!hasParam(parameters,"anim_die_bones_left")) anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE,25); - anim_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1); - anim_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),1); - anim_walk_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),7,BP_MD,ATYPE_LOOP,3.5); - anim_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,BP_MD,ATYPE_LOOP,3.5); - anim_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); - anim_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); - anim_walk_shield_left.reset(new EmptyAnimation(&anim_shield_left)); - anim_walk_shield_right.reset(new EmptyAnimation(&anim_shield_right)); - anim_fall_shield_left.reset(new EmptyAnimation(&anim_shield_left)); - anim_fall_shield_right.reset(new EmptyAnimation(&anim_shield_right)); - au_small=scenario->sndcache->loadWAV("blob.wav"); - au_big=scenario->sndcache->loadWAV("unblob.wav"); - au_fart=scenario->sndcache->loadWAV("fart1.wav"); - au_hit=scenario->sndcache->loadWAV("fathit.wav"); + if (hasParam(parameters,"anim_olaf_small_left")) anim_olaf_small_left=loadAnimation(getParameters(parameters["anim_olaf_small_left"],':')); + else anim_olaf_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1); + if (hasParam(parameters,"anim_olaf_small_right")) anim_olaf_small_right=loadAnimation(getParameters(parameters["anim_olaf_small_right"],':')); + else anim_olaf_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),1); + if (hasParam(parameters,"anim_olaf_walk_small_left")) anim_olaf_walk_small_left=loadAnimation(getParameters(parameters["anim_olaf_walk_small_left"],':')); + else anim_olaf_walk_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),7,BP_MD,ATYPE_LOOP,3.5); + if (hasParam(parameters,"anim_olaf_walk_small_right")) anim_olaf_walk_small_right=loadAnimation(getParameters(parameters["anim_olaf_walk_small_right"],':')); + else anim_olaf_walk_small_right=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_right.png"),7,BP_MD,ATYPE_LOOP,3.5); + if (hasParam(parameters,"anim_olaf_shield_left")) anim_olaf_shield_left=loadAnimation(getParameters(parameters["anim_olaf_shield_left"],':')); + else anim_olaf_shield_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_left.bmp")); + if (hasParam(parameters,"anim_olaf_shield_right")) anim_olaf_shield_right=loadAnimation(getParameters(parameters["anim_olaf_shield_right"],':')); + else anim_olaf_shield_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_fall_shield_right.bmp")); + if (hasParam(parameters,"anim_olaf_walk_shield_left")) anim_olaf_walk_shield_left=loadAnimation(getParameters(parameters["anim_olaf_walk_shield_left"],':')); + else anim_olaf_walk_shield_left.reset(new EmptyAnimation(&anim_olaf_shield_left)); + if (hasParam(parameters,"anim_olaf_walk_shield_right")) anim_olaf_walk_shield_right=loadAnimation(getParameters(parameters["anim_olaf_walk_shield_right"],':')); + else anim_olaf_walk_shield_right.reset(new EmptyAnimation(&anim_olaf_shield_right)); + if (hasParam(parameters,"anim_olaf_fall_shield_left")) anim_olaf_fall_shield_left=loadAnimation(getParameters(parameters["anim_olaf_fall_shield_left"],':')); + else anim_olaf_fall_shield_left.reset(new EmptyAnimation(&anim_olaf_shield_left)); + if (hasParam(parameters,"anim_olaf_fall_shield_right")) anim_olaf_fall_shield_right=loadAnimation(getParameters(parameters["anim_olaf_fall_shield_right"],':')); + else anim_olaf_fall_shield_right.reset(new EmptyAnimation(&anim_olaf_shield_right)); + + if (!hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV("fathit.wav"); + + if (hasParam(parameters,"audio_small")) au_small=scenario->sndcache->loadWAV(parameters["audio_small"]); + else au_small=scenario->sndcache->loadWAV("blob.wav"); + if (hasParam(parameters,"audio_big")) au_big=scenario->sndcache->loadWAV(parameters["audio_big"]); + else au_big=scenario->sndcache->loadWAV("unblob.wav"); + if (hasParam(parameters,"audio_fart")) au_fart=scenario->sndcache->loadWAV(parameters["audio_fart"]); + else au_fart=scenario->sndcache->loadWAV("fart1.wav"); + normal_size=pos; - small_size=anim_small_right->getFrameDim(); + small_size=anim_olaf_small_right->getFrameDim(); } Olaf::~Olaf() { } @@ -43,42 +60,42 @@ void Olaf::updateAnimState() { if (state&STATE_SMALL) { if (state&STATE_LEFT) { - anim_small_left->setFallBack(&anim_walk_left); - setAnim(anim_walk_small_left); - anim_small_left->setFallBack(&anim_left); + anim_olaf_small_left->setFallBack(&anim_walk_left); + setAnim(anim_olaf_walk_small_left); + anim_olaf_small_left->setFallBack(&anim_left); } else { - anim_small_right->setFallBack(&anim_walk_right); - setAnim(anim_walk_small_right); - anim_small_right->setFallBack(&anim_right); + anim_olaf_small_right->setFallBack(&anim_walk_right); + setAnim(anim_olaf_walk_small_right); + anim_olaf_small_right->setFallBack(&anim_right); } } else if (state&STATE_SHIELD) { otype|=OTYPE_DENSE_D; if (state&STATE_LEFT) { if (state&STATE_FALL) { - anim_shield_left->setFallBack(&anim_fall_left); - setAnim(anim_fall_shield_left); - anim_shield_left->setFallBack(&anim_left); + anim_olaf_shield_left->setFallBack(&anim_fall_left); + setAnim(anim_olaf_fall_shield_left); + anim_olaf_shield_left->setFallBack(&anim_left); } else { if (state&STATE_MLEFT) { - anim_shield_left->setFallBack(&anim_walk_left); - setAnim(anim_walk_shield_left); - anim_shield_left->setFallBack(&anim_left); + anim_olaf_shield_left->setFallBack(&anim_walk_left); + setAnim(anim_olaf_walk_shield_left); + anim_olaf_shield_left->setFallBack(&anim_left); } else { - setAnim(anim_shield_left); + setAnim(anim_olaf_shield_left); } } } else { if (state&STATE_FALL) { - anim_shield_right->setFallBack(&anim_fall_right); - setAnim(anim_fall_shield_right); - anim_shield_right->setFallBack(&anim_right); + anim_olaf_shield_right->setFallBack(&anim_fall_right); + setAnim(anim_olaf_fall_shield_right); + anim_olaf_shield_right->setFallBack(&anim_right); } else { if (state&STATE_MRIGHT) { - anim_shield_right->setFallBack(&anim_walk_right); - setAnim(anim_walk_shield_right); - anim_shield_right->setFallBack(&anim_right); + anim_olaf_shield_right->setFallBack(&anim_walk_right); + setAnim(anim_olaf_walk_shield_right); + anim_olaf_shield_right->setFallBack(&anim_right); } else { - setAnim(anim_shield_right); + setAnim(anim_olaf_shield_right); } } } Modified: trunk/src/objects/olaf.h =================================================================== --- trunk/src/objects/olaf.h 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/olaf.h 2005-09-08 22:04:26 UTC (rev 164) @@ -42,16 +42,16 @@ /// \return True if successfull inline bool trySmall(bool small); //@{ - EmptyAnimationPtr anim_small_left; - EmptyAnimationPtr anim_small_right; - EmptyAnimationPtr anim_walk_small_left; - EmptyAnimationPtr anim_walk_small_right; - EmptyAnimationPtr anim_shield_left; - EmptyAnimationPtr anim_shield_right; - EmptyAnimationPtr anim_walk_shield_left; - EmptyAnimationPtr anim_walk_shield_right; - EmptyAnimationPtr anim_fall_shield_left; - EmptyAnimationPtr anim_fall_shield_right; + EmptyAnimationPtr anim_olaf_small_left; + EmptyAnimationPtr anim_olaf_small_right; + EmptyAnimationPtr anim_olaf_walk_small_left; + EmptyAnimationPtr anim_olaf_walk_small_right; + EmptyAnimationPtr anim_olaf_shield_left; + EmptyAnimationPtr anim_olaf_shield_right; + EmptyAnimationPtr anim_olaf_walk_shield_left; + EmptyAnimationPtr anim_olaf_walk_shield_right; + EmptyAnimationPtr anim_olaf_fall_shield_left; + EmptyAnimationPtr anim_olaf_fall_shield_right; //@} //@{ Mix_Chunk* au_small; Modified: trunk/src/objects/scorch.cpp =================================================================== --- trunk/src/objects/scorch.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/scorch.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -12,15 +12,21 @@ Player(xcord,ycord,parameters), left_wings(SCORCH_MAX_WINGS), wing(V_FLY) { - anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); - anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); - au_tired=scenario->sndcache->loadWAV("flwings.wav"); - au_hit=scenario->sndcache->loadWAV("draghit.wav"); + + /* Parameters */ + if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); + if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); + if (!hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_left.png"),8); + if (!hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); + if (!hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + if (!hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); + + if (!hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV("draghit.wav"); + + if (hasParam(parameters,"audio_swing")) au_swing=scenario->sndcache->loadWAV(parameters["audio_swing"]); + else au_swing=scenario->sndcache->loadWAV("flapwngs.wav"); + if (hasParam(parameters,"audio_tired")) au_swing=scenario->sndcache->loadWAV(parameters["audio_tired"]); + else au_tired=scenario->sndcache->loadWAV("flwings.wav"); } Scorch::~Scorch() { } Modified: trunk/src/objects/zombie.cpp =================================================================== --- trunk/src/objects/zombie.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects/zombie.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -13,11 +13,12 @@ Zombie::Zombie(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): Monster(xcord,ycord,parameters), T_Attack_Bite(1500) { - anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); - anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); weapon=Weapon(-1,W_STRIKE); /* Parameters */ + if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_left.bmp"),2,BP_MD,ATYPE_LOOP,2); + if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(2,"olaf1_right.bmp"),2,BP_MD,ATYPE_LOOP,2); + if (!hasParam(parameters,"maxspeedx")) maxspeedx=80; if (hasParam(parameters,"audio_attack")) au_attack=scenario->sndcache->loadWAV(parameters["audio_attack"]); else au_attack=scenario->sndcache->loadWAV("clang.wav"); Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects_common.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -13,7 +13,6 @@ otype(NOTHING), delete_flag(false) { onum=++scenario->max_obj_num; - animation.reset(new EmptyAnimation(&anim_orig)); /* Parameters */ if (hasParam(parameters,"anim")) { @@ -35,6 +34,7 @@ else pos.h=(Uint16)(DATA_LVLPLAYER_H*sqrt(config.lvlscale>=0 ? config.lvlscale : -1/config.lvlscale)+0.5); pos.x=xcord; pos.y=ycord; + animation=anim_orig; } Object::~Object() { @@ -144,99 +144,99 @@ return anim; } -EmptyAnimationPtr Object::loadAnimation(ParameterMap& parameters) { +EmptyAnimationPtr Object::loadAnimation(const ParameterMap& parameters) { double scale_factor=1; BasePointType bp_type=BP_MD; Uint16 animation_type=ATYPE_LOOP; double fps=0; AllignType allign_type=AT_MD; - if (hasParam(parameters,"scale")) scale_factor=atof(parameters["scale"].c_str()); + if (hasParam(parameters,"scale")) scale_factor=atof(parameters.find("scale")->second.c_str()); if (hasParam(parameters,"bp_type")) { - if (parameters["bp_type"].find("hleft") !=string::npos) { - if (parameters["bp_type"].find("vup") !=string::npos) bp_type=BP_LU; - else if (parameters["bp_type"].find("vmiddle") !=string::npos) bp_type=BP_LM; - else if (parameters["bp_type"].find("vdown") !=string::npos) bp_type=BP_LD; - } else if (parameters["bp_type"].find("hmiddle") !=string::npos) { - if (parameters["bp_type"].find("vup") !=string::npos) bp_type=BP_MU; - else if (parameters["bp_type"].find("vmiddle") !=string::npos) bp_type=BP_MM; - else if (parameters["bp_type"].find("vdown") !=string::npos) bp_type=BP_MD; - } else if (parameters["bp_type"].find("hright") !=string::npos) { - if (parameters["bp_type"].find("vup") !=string::npos) bp_type=BP_RU; - else if (parameters["bp_type"].find("vmiddle") !=string::npos) bp_type=BP_RM; - else if (parameters["bp_type"].find("vdown") !=string::npos) bp_type=BP_RD; + if (parameters.find("bp_type")->second.find("hleft") !=string::npos) { + if (parameters.find("bp_type")->second.find("vup") !=string::npos) bp_type=BP_LU; + else if (parameters.find("bp_type")->second.find("vmiddle") !=string::npos) bp_type=BP_LM; + else if (parameters.find("bp_type")->second.find("vdown") !=string::npos) bp_type=BP_LD; + } else if (parameters.find("bp_type")->second.find("hmiddle") !=string::npos) { + if (parameters.find("bp_type")->second.find("vup") !=string::npos) bp_type=BP_MU; + else if (parameters.find("bp_type")->second.find("vmiddle") !=string::npos) bp_type=BP_MM; + else if (parameters.find("bp_type")->second.find("vdown") !=string::npos) bp_type=BP_MD; + } else if (parameters.find("bp_type")->second.find("hright") !=string::npos) { + if (parameters.find("bp_type")->second.find("vup") !=string::npos) bp_type=BP_RU; + else if (parameters.find("bp_type")->second.find("vmiddle") !=string::npos) bp_type=BP_RM; + else if (parameters.find("bp_type")->second.find("vdown") !=string::npos) bp_type=BP_RD; } } if (hasParam(parameters,"type")) { animation_type=NOTHING; - if (parameters["type"].find("once")) animation_type|=ATYPE_ONCE; - if (parameters["type"].find("loop")) animation_type|=ATYPE_LOOP; - if (parameters["type"].find("swing")) animation_type|=ATYPE_SWING; - if (parameters["type"].find("step")) animation_type|=ATYPE_STEP; - if (parameters["type"].find("reverse")) { + if (parameters.find("type")->second.find("once")) animation_type|=ATYPE_ONCE; + if (parameters.find("type")->second.find("loop")) animation_type|=ATYPE_LOOP; + if (parameters.find("type")->second.find("swing")) animation_type|=ATYPE_SWING; + if (parameters.find("type")->second.find("step")) animation_type|=ATYPE_STEP; + if (parameters.find("type")->second.find("reverse")) { animation_type<<=1; } if (animation_type==NOTHING) animation_type=ATYPE_LOOP; - if (parameters["type"].find("switch")) animation_type|=ATYPE_ST_SWITCH; + if (parameters.find("type")->second.find("switch")) animation_type|=ATYPE_ST_SWITCH; } - if (hasParam(parameters,"fps")) fps=atof(parameters["fps"].c_str()); + if (hasParam(parameters,"fps")) fps=atof(parameters.find("fps")->second.c_str()); if (hasParam(parameters,"allign_type")) { - if (parameters["allign_type"].find("hleft") !=string::npos) { - if (parameters["allign_type"].find("vup") !=string::npos) allign_type=AT_LU; - else if (parameters["allign_type"].find("vmiddle") !=string::npos) allign_type=AT_LM; - else if (parameters["allign_type"].find("vdown") !=string::npos) allign_type=AT_LD; - } else if (parameters["allign_type"].find("hmiddle") !=string::npos) { - if (parameters["allign_type"].find("vup") !=string::npos) allign_type=AT_MU; - else if (parameters["allign_type"].find("vmiddle") !=string::npos) allign_type=AT_MM; - else if (parameters["allign_type"].find("vdown") !=string::npos) allign_type=AT_MD; - } else if (parameters["allign_type"].find("hright") !=string::npos) { - if (parameters["allign_type"].find("vup") !=string::npos) allign_type=AT_RU; - else if (parameters["allign_type"].find("vmiddle") !=string::npos) allign_type=AT_RM; - else if (parameters["allign_type"].find("vdown") !=string::npos) allign_type=AT_RD; + if (parameters.find("allign_type")->second.find("hleft") !=string::npos) { + if (parameters.find("allign_type")->second.find("vup") !=string::npos) allign_type=AT_LU; + else if (parameters.find("allign_type")->second.find("vmiddle") !=string::npos) allign_type=AT_LM; + else if (parameters.find("allign_type")->second.find("vdown") !=string::npos) allign_type=AT_LD; + } else if (parameters.find("allign_type")->second.find("hmiddle") !=string::npos) { + if (parameters.find("allign_type")->second.find("vup") !=string::npos) allign_type=AT_MU; + else if (parameters.find("allign_type")->second.find("vmiddle") !=string::npos) allign_type=AT_MM; + else if (parameters.find("allign_type")->second.find("vdown") !=string::npos) allign_type=AT_MD; + } else if (parameters.find("allign_type")->second.find("hright") !=string::npos) { + if (parameters.find("allign_type")->second.find("vup") !=string::npos) allign_type=AT_RU; + else if (parameters.find("allign_type")->second.find("vmiddle") !=string::npos) allign_type=AT_RM; + else if (parameters.find("allign_type")->second.find("vdown") !=string::npos) allign_type=AT_RD; } } /* Use animation name */ if (hasParam(parameters,"name")) { - string anim_name=parameters["name"]; + string anim_name=parameters.find("name")->second; return loadAnimation(anim_name,scale_factor,bp_type,animation_type,fps,allign_type); /* Use a base image */ } else if (hasParam(parameters,"image")) { - string image_name=parameters["image"]; + string image_name=parameters.find("image")->second; Uint16 frames=1; Uint16 start_pos=0; - if (hasParam(parameters,"frames")) frames=atoi(parameters["frames"].c_str()); - if (hasParam(parameters,"start_pos")) start_pos=atoi(parameters["start_pos"].c_str()); + if (hasParam(parameters,"frames")) frames=atoi(parameters.find("frames")->second.c_str()); + if (hasParam(parameters,"start_pos")) start_pos=atoi(parameters.find("start_pos")->second.c_str()); /* threat as horizontal animation (constant width, height) with frames */ if (hasParam(parameters,"image_hor_frames")) { - Uint16 image_hor_frames=atoi(parameters["image_hor_frames"].c_str()); + Uint16 image_hor_frames=atoi(parameters.find("image_hor_frames")->second.c_str()); return loadAnimation(scenario->imgcache->loadImage(image_hor_frames,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type); /* threat as horizontal animation (constant width, height) with width and an optional shift */ } else if (hasParam(parameters,"image_hor_width")) { - Uint16 image_hor_width=atoi(parameters["image_hor_width"].c_str()); + Uint16 image_hor_width=atoi(parameters.find("image_hor_width")->second.c_str()); Uint16 image_hor_shift=0; - if (hasParam(parameters,"image_hor_shift")) image_hor_shift=atoi(parameters["image_hor_shift"].c_str()); + if (hasParam(parameters,"image_hor_shift")) image_hor_shift=atoi(parameters.find("image_hor_shift")->second.c_str()); return loadAnimation(scenario->imgcache->loadImage(image_hor_width,image_hor_shift,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type); /* threat as constant width/height animation based on a base rectangle */ } else if (hasParam(parameters,"image_rect")) { - ParameterMap rect_param=getParameters(parameters["image_rect"],';'); + ParameterMap rect_param=getParameters(parameters.find("image_rect")->second,';'); SDL_Rect rect; rect.x=rect.y=0; rect.w=rect.h=10; - if (hasParam(rect_param,"x")) rect.x=atoi(rect_param["x"].c_str()); - if (hasParam(rect_param,"y")) rect.y=atoi(rect_param["y"].c_str()); - if (hasParam(rect_param,"w")) rect.w=atoi(rect_param["w"].c_str()); - if (hasParam(rect_param,"h")) rect.h=atoi(rect_param["h"].c_str()); + if (hasParam(rect_param,"x")) rect.x=atoi(rect_param.find("x")->second.c_str()); + if (hasParam(rect_param,"y")) rect.y=atoi(rect_param.find("y")->second.c_str()); + if (hasParam(rect_param,"w")) rect.w=atoi(rect_param.find("w")->second.c_str()); + if (hasParam(rect_param,"h")) rect.h=atoi(rect_param.find("h")->second.c_str()); return loadAnimation(scenario->imgcache->loadImage(rect,image_name,scale_factor),frames,bp_type,animation_type,fps,start_pos,allign_type); /* get informations from an image description file */ } else { string image_desc=image_name+".dsc"; - if (hasParam(parameters,"image_desc")) image_desc=parameters["image_desc"]; + if (hasParam(parameters,"image_desc")) image_desc=parameters.find("image_desc")->second; return loadAnimation(scenario->imgcache->loadImage(image_name,scale_factor,image_desc),frames,bp_type,animation_type,fps,start_pos,allign_type); } Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/objects_common.h 2005-09-08 22:04:26 UTC (rev 164) @@ -122,7 +122,7 @@ Uint16 astart_pos=0, AllignType aallign_type=AT_MD); /// Load an animation based on a parameter map - EmptyAnimationPtr loadAnimation(ParameterMap& parameters=ParameterMap()); + EmptyAnimationPtr loadAnimation(const ParameterMap& parameters=ParameterMap()); //Events (triggered animations/effects) //@{ /// Clears the event field (sets it to NULL). This should only be used by Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-08 15:32:44 UTC (rev 163) +++ trunk/src/players_common.cpp 2005-09-08 22:04:26 UTC (rev 164) @@ -15,58 +15,103 @@ Player::Player(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): Character(xcord,ycord,parameters), - currentitem(0), - anim_left(new EmptyAnimation(&anim_right)), - anim_right(new EmptyAnimation()), - anim_rock_left(new EmptyAnimation(&anim_left)), - anim_rock_right(new EmptyAnimation(&anim_right)), - anim_walk_left(new EmptyAnimation(&anim_left)), - anim_walk_right(new EmptyAnimation(&anim_right)), - anim_push_left(new EmptyAnimation(&anim_left)), - anim_push_right(new EmptyAnimation(&anim_right)), - anim_fall_left(new EmptyAnimation(&anim_left)), - anim_fall_right(new EmptyAnimation(&anim_right)), - anim_fall_fast_left(new EmptyAnimation(&anim_fall_left)), - anim_fall_fast_right(new EmptyAnimation(&anim_fall_right)), - anim_crash_left(new EmptyAnimation()), - anim_crash_right(new EmptyAnimation()), - anim_rope_left(new EmptyAnimation(&anim_left)), - anim_rope_right(new EmptyAnimation(&anim_right)), - anim_teleport_left(new EmptyAnimation()), - anim_teleport_right(new EmptyAnimation()), - anim_die_crash_left(new EmptyAnimation(&anim_die_bones_left)), - anim_die_crash_right(new EmptyAnimation(&anim_die_bones_right)), - anim_die_burn_left(new EmptyAnimation(&anim_die_bones_left)), - anim_die_burn_right(new EmptyAnimation(&anim_die_bones_right)), - anim_die_bones_left(new EmptyAnimation(&anim_die_bones_right)), - anim_die_bones_right(new EmptyAnimation()), - anim_die_elec_left(new EmptyAnimation(&anim_die_bones_left)), - anim_die_elec_right(new EmptyAnimation(&anim_die_bones_right)), - anim_die_spike_left(new EmptyAnimation(&anim_die_bones_left)), - anim_die_spike_right(new EmptyAnimation(&anim_die_bones_right)), - anim_die_water_left(new EmptyAnimation(&anim_die_bones_left)), - anim_die_water_right(new EmptyAnimation(&anim_die_bones_right)), - anim_fall_middle(new EmptyAnimation(&anim_fall_right)), - anim_climb(new EmptyAnimation(&anim_right)), - anim_bar(new EmptyAnimation(&anim_right)) { + currentitem(0) { for (Uint8 i=0; isndcache->loadWAV("dizzy.wav"); - au_act=scenario->sndcache->loadWAV("button.wav"); - au_useerror=scenario->sndcache->loadWAV("useerror.wav"); - au_newitem=scenario->sndcache->loadWAV("pickup.wav"); - au_hit=scenario->sndcache->loadWAV("vikhit.wav"); - au_elec=scenario->sndcache->loadWAV("elecdth.wav"); - au_drown=scenario->sndcache->loadWAV("drown.wav"); - au_fire=scenario->sndcache->loadWAV("fireball.wav"); - au_die=scenario->sndcache->loadWAV("bones.wav"); - au_heal=scenario->sndcache->loadWAV("usefood1.wav"); /* Parameters */ + if (hasParam(parameters,"anim_left")) anim_left=loadAnimation(getParameters(parameters["anim_left"],':')); + else anim_left.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_right")) anim_right=loadAnimation(getParameters(parameters["anim_right"],':')); + else anim_right.reset(new EmptyAnimation(&anim_orig)); + if (hasParam(parameters,"anim_rock_left")) anim_rock_left=loadAnimation(getParameters(parameters["anim_rock_left"],':')); + else anim_rock_left.reset(new EmptyAnimation(&anim_left)); + if (hasParam(parameters,"anim_rock_right")) anim_rock_right=loadAnimation(getParameters(parameters["anim_rock_right"],':')); + else anim_rock_right.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(getParameters(parameters["anim_walk_left"],':')); + else anim_walk_left.reset(new EmptyAnimation(&anim_left)); + if (hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(getParameters(parameters["anim_walk_right"],':')); + else anim_walk_right.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_push_left")) anim_push_left=loadAnimation(getParameters(parameters["anim_push_left"],':')); + else anim_push_left.reset(new EmptyAnimation(&anim_left)); + if (hasParam(parameters,"anim_push_right")) anim_push_right=loadAnimation(getParameters(parameters["anim_push_right"],':')); + else anim_push_right.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_fall_left")) anim_fall_left=loadAnimation(getParameters(parameters["anim_fall_left"],':')); + else anim_fall_left.reset(new EmptyAnimation(&anim_left)); + if (hasParam(parameters,"anim_fall_right")) anim_fall_right=loadAnimation(getParameters(parameters["anim_fall_right"],':')); + else anim_fall_right.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_fall_fast_left")) anim_fall_fast_left=loadAnimation(getParameters(parameters["anim_fall_fast_left"],':')); + else anim_fall_fast_left.reset(new EmptyAnimation(&anim_fall_left)); + if (hasParam(parameters,"anim_fall_fast_right")) anim_fall_fast_right=loadAnimation(getParameters(parameters["anim_fall_fast_right"],':')); + else anim_fall_fast_right.reset(new EmptyAnimation(&anim_fall_right)); + if (hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(getParameters(parameters["anim_crash_left"],':')); + else anim_crash_left.reset(new EmptyAnimation()); + if (hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(getParameters(parameters["anim_crash_right"],':')); + else anim_crash_right.reset(new EmptyAnimation()); + if (hasParam(parameters,"anim_rope_left")) anim_rope_left=loadAnimation(getParameters(parameters["anim_rope_left"],':')); + else anim_rope_left.reset(new EmptyAnimation(&anim_left)); + if (hasParam(parameters,"anim_rope_right")) anim_rope_right=loadAnimation(getParameters(parameters["anim_rope_right"],':')); + else anim_rope_right.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_teleport_left")) anim_teleport_left=loadAnimation(getParameters(parameters["anim_teleport_left"],':')); + else anim_teleport_left.reset(new EmptyAnimation()); + if (hasParam(parameters,"anim_teleport_left")) anim_teleport_left=loadAnimation(getParameters(parameters["anim_teleport_left"],':')); + else anim_teleport_left.reset(new EmptyAnimation()); + if (hasParam(parameters,"anim_die_crash_left")) anim_die_crash_left=loadAnimation(getParameters(parameters["anim_die_crash_left"],':')); + else anim_die_crash_left.reset(new EmptyAnimation(&anim_die_bones_left)); + if (hasParam(parameters,"anim_die_crash_left")) anim_die_crash_left=loadAnimation(getParameters(parameters["anim_die_crash_left"],':')); + else anim_die_crash_left.reset(new EmptyAnimation(&anim_die_bones_right)); + if (hasParam(parameters,"anim_die_burn_left")) anim_die_burn_left=loadAnimation(getParameters(parameters["anim_die_burn_left"],':')); + else anim_die_burn_left.reset(new EmptyAnimation(&anim_die_bones_right)); + if (hasParam(parameters,"anim_die_burn_left")) anim_die_burn_left=loadAnimation(getParameters(parameters["anim_die_burn_left"],':')); + else anim_die_burn_left.reset(new EmptyAnimation(&anim_die_bones_right)); + if (hasParam(parameters,"anim_die_bones_left")) anim_die_bones_left=loadAnimation(getParameters(parameters["anim_die_bones_left"],':')); + else anim_die_bones_left.reset(new EmptyAnimation()); + if (hasParam(parameters,"anim_die_bones_left")) anim_die_bones_left=loadAnimation(getParameters(parameters["anim_die_bones_left"],':')); + else anim_die_bones_left.reset(new EmptyAnimation()); + if (hasParam(parameters,"anim_die_elec_left")) anim_die_elec_left=loadAnimation(getParameters(parameters["anim_die_elec_left"],':')); + else anim_die_elec_left.reset(new EmptyAnimation(&anim_die_bones_left)); + if (hasParam(parameters,"anim_die_elec_right")) anim_die_elec_right=loadAnimation(getParameters(parameters["anim_die_elec_right"],':')); + else anim_die_elec_right.reset(new EmptyAnimation(&anim_die_bones_right)); + if (hasParam(parameters,"anim_die_spike_left")) anim_die_spike_left=loadAnimation(getParameters(parameters["anim_die_spike_left"],':')); + else anim_die_spike_left.reset(new EmptyAnimation(&anim_die_bones_left)); + if (hasParam(parameters,"anim_die_spike_right")) anim_die_spike_right=loadAnimation(getParameters(parameters["anim_die_spike_right"],':')); + else anim_die_spike_right.reset(new EmptyAnimation(&anim_die_bones_right)); + if (hasParam(parameters,"anim_die_water_left")) anim_die_water_left=loadAnimation(getParameters(parameters["anim_die_water_left"],':')); + else anim_die_water_left.reset(new EmptyAnimation(&anim_die_bones_left)); + if (hasParam(parameters,"anim_die_water_right")) anim_die_water_right=loadAnimation(getParameters(parameters["anim_die_water_right"],':')); + else anim_die_water_right.reset(new EmptyAnimation(&anim_die_bones_right)); + if (hasParam(parameters,"anim_fall_middle")) anim_fall_middle=loadAnimation(getParameters(parameters["anim_fall_middle"],':')); + else anim_fall_middle.reset(new EmptyAnimation(&anim_fall_right)); + if (hasParam(parameters,"anim_climb")) anim_climb=loadAnimation(getParameters(parameters["anim_climb"],':')); + else anim_climb.reset(new EmptyAnimation(&anim_right)); + if (hasParam(parameters,"anim_bar")) anim_bar=loadAnimation(getParameters(parameters["anim_bar"],':')); + else anim_bar.reset(new EmptyAnimation(&anim_right)); + + if (hasParam(parameters,"audio_land")) au_land=scenario->sndcache->loadWAV(parameters["audio_land"]); + else au_land=scenario->sndcache->loadWAV("dizzy.wav"); + if (hasParam(parameters,"audio_act")) au_land=scenario->sndcache->loadWAV(parameters["audio_act"]); + else au_act=scenario->sndcache->loadWAV("button.wav"); + if (hasParam(parameters,"audio_useerror")) au_land=scenario->sndcache->loadWAV(parameters["audio_useerror"]); + else au_useerror=scenario->sndcache->loadWAV("useerror.wav"); + if (hasParam(parameters,"audio_newitem")) au_land=scenario->sndcache->loadWAV(parameters["audio_newitem"]); + else au_newitem=scenario->sndcache->loadWAV("pickup.wav"); + if (hasParam(parameters,"audio_hit")) au_land=scenario->sndcache->loadWAV(parameters["audio_hit"]); + else au_hit=scenario->sndcache->loadWAV("vikhit.wav"); + if (hasParam(parameters,"audio_elec")) au_land=scenario->sndcache->loadWAV(parameters["audio_elec"]); + else au_elec=scenario->sndcache->loadWAV("elecdth.wav"); + if (hasParam(parameters,"audio_drown")) au_land=scenario->sndcache->loadWAV(parameters["audio_drown"]); + else au_drown=scenario->sndcache->loadWAV("drown.wav"); + if (hasParam(parameters,"audio_fire")) au_land=scenario->sndcache->loadWAV(parameters["audio_fire"]); + else au_fire=scenario->sndcache->loadWAV("fireball.wav"); + if (hasParam(parameters,"audio_die")) au_land=scenario->sndcache->loadWAV(parameters["audio_die"]); + else au_die=scenario->sndcache->loadWAV("bones.wav"); + if (hasParam(parameters,"audio_heal")) au_land=scenario->sndcache->loadWAV(parameters["audio_heal"]); + else au_heal=scenario->sndcache->loadWAV("usefood1.wav"); + if (!hasParam(parameters,"maxhealth")) maxhealth=4; if (!hasParam(parameters,"health")) health=min(3,(int)maxhealth); if (!hasParam(parameters,"maxspeedx")) maxspeedx=300; @@ -313,7 +358,9 @@ //should be !=NULL or sthg is wrong with the placement code... ParameterMap deadplr_parameters; deadplr_parameters["image"]="dead_player.bmp"; - Character* deadplr=scenario->pool->addCharacter(new DeadPlayer(pos.x,pos.y,deadplr_parameters)); + deadplr_parameters["w"]=10; + deadplr_parameters["h"]=10; + Character* deadplr=dynamic_cast(scenario->pool->addObjectbyName("DeadPlayer",pos.x,pos.y,deadplr_parameters)); switch(weap.getSubType()) { case WS_FIRE: { if (deadplr) deadplr->setEvent(new CAnimEvent(deadplr,10,0,ESTATE_BUSY,au_fire,(state&STATE_LEFT) ? anim_die_burn_left : anim_die_burn_right)); From DONOTREPLY at icculus.org Fri Sep 9 11:49:26 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 9 Sep 2005 11:49:26 -0400 Subject: r165 - trunk/src Message-ID: <20050909154926.23631.qmail@icculus.org> Author: jonas Date: 2005-09-09 11:49:26 -0400 (Fri, 09 Sep 2005) New Revision: 165 Modified: trunk/src/common.h trunk/src/editor.cpp trunk/src/editor.h trunk/src/objectpools.cpp trunk/src/scenario.cpp trunk/src/scenario.h Log: o Added a Object* getObjectAt(Sint16 x, Sint16 y, Uint16 mask=ALL) function that returns the first (top most) object at the specified position; o Added a remove object action to the editor o Changed the file reading (to buffer) function to check for the parameter name and add it if it isn't found: This is used to find a map buffer entry corresponding to an object in play over obj->getName()... Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-08 22:04:26 UTC (rev 164) +++ trunk/src/common.h 2005-09-09 15:49:26 UTC (rev 165) @@ -49,6 +49,8 @@ typedef std::set::iterator character_iterator; typedef std::set::iterator player_iterator; typedef std::set::iterator monster_iterator; +typedef std::set::reverse_iterator object_riterator; +typedef std::set::reverse_iterator character_riterator; typedef boost::shared_ptr EmptyAnimationPtr; typedef std::map ParameterMap; Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-08 22:04:26 UTC (rev 164) +++ trunk/src/editor.cpp 2005-09-09 15:49:26 UTC (rev 165) @@ -4,6 +4,7 @@ #include "menu.h" #include "font.h" #include "gfxeng.h" +#include "objects_common.h" #include "editor.h" @@ -36,6 +37,13 @@ setBox(new EditBox(x,y)); } else if (action&EDIT_ACT_BOX) { if (box) box->act(box->getCurrentEntry(x,y)); + } else if (action&EDIT_REMOVE_OBJECT) { + Object* obj=scenario->getObjectAt(xs,ys); + if (obj) { + if (removefromBuf(obj->getName()).empty()) { + cout << "Unable to remove object " << obj->getName() << ": Name identifier not found!" << endl; + } else scenario->reloadMap(); + } } else if (action&EDIT_PLACE_OBJECT) { scenario->reloadMap(); if (scenario->pool->addObjectbyName(place_name,xs,ys,place_parameters)) { @@ -228,6 +236,7 @@ } else if (entries[curentry]=="Place Object") { editor->setBox(new PlaceBox(area.x,area.y)); } else if (entries[curentry]=="Remove Object") { + editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_REMOVE_OBJECT; editor->closeBox(); } else if (entries[curentry]=="Move Object") { editor->closeBox(); Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-08 22:04:26 UTC (rev 164) +++ trunk/src/editor.h 2005-09-09 15:49:26 UTC (rev 165) @@ -5,6 +5,7 @@ #define EDIT_BOX 0x00000004 #define EDIT_ACT_BOX 0x00000008 #define EDIT_PLACE_OBJECT 0x00000010 +#define EDIT_REMOVE_OBJECT 0x00000020 /** \brief abstract Box base class Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-08 22:04:26 UTC (rev 164) +++ trunk/src/objectpools.cpp 2005-09-09 15:49:26 UTC (rev 165) @@ -166,6 +166,7 @@ Player::default_parameters["audio_heal"]="usefood1.wav"; Erik::default_parameters=Player::default_parameters; + Erik::default_parameters["file"]="erik.inf"; Erik::default_parameters["audio_jump"]="rboots.wav"; Erik::default_parameters["audio_run"]=""; Olaf::default_parameters=Player::default_parameters; Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-08 22:04:26 UTC (rev 164) +++ trunk/src/scenario.cpp 2005-09-09 15:49:26 UTC (rev 165) @@ -30,7 +30,7 @@ } Scenario::~Scenario() { - cout << endl << "Closing map...\n"; + cout << "Closing map...\n"; delete pool; cout << "Map: Deleted Pools...\n"; if (background) delete background; @@ -80,8 +80,45 @@ } mapbuf.clear(); + + /* We parse the parameters to add a name if it was missing + This whole file reading looks much more complicated because + of this (otherwise there would only be mapbuf.push_back(tmpline) */ + string cname; + Uint16 x,y; + ParameterMap parameters; + bool header=true; + std::map namecount; while (getline(mapfile,tmpline)) { - mapbuf.push_back(tmpline); + if (header) { + mapbuf.push_back(tmpline); + std::istringstream tmpstream(tmpline); + tmpstream >> cname; + if (cname[0]=='#') { + if (cname=="#ENDHEADER") header=false; + continue; + } + } else { + cname.erase(); + x=y=0; + std::istringstream tmpstream(tmpline); + tmpstream >> cname >> x >> y; + + if (cname.empty() || cname[0]=='#') { + mapbuf.push_back(tmpline); + continue; + } else { + namecount[cname]++; + } + + string parameterlist((istreambuf_iterator(tmpstream)), istreambuf_iterator()); + parameters=getParameters(parameterlist); + if (!hasParam(parameters,"name")) { + if (parameters.empty()) tmpline+=" name="+cname+itos(namecount[cname]); + else tmpline+=", name="+cname+itos(namecount[cname]); + } + mapbuf.push_back(tmpline); + } } mapfile.close(); @@ -295,3 +332,16 @@ } return tmpset; } + +Object* Scenario::getObjectAt(Sint16 x, Sint16 y, Uint16 mask) const { + SDL_Rect tmprect; + tmprect.x=x; + tmprect.y=y; + tmprect.w=tmprect.h=1; + object_riterator obit=pool->objectspool.rbegin(); + while (obit != pool->objectspool.rend()) { + if ((((*obit)->getType())&mask) && ((*obit)->isIn(tmprect,true))) return (*obit); + ++obit; + } + return NULL; +} Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-08 22:04:26 UTC (rev 164) +++ trunk/src/scenario.h 2005-09-09 15:49:26 UTC (rev 165) @@ -46,6 +46,8 @@ /// \return A set of characters that are inside the enlarged source rectangle /// and that match the specified mask. std::set getCharactersIn(Uint16 mask, const SDL_Rect& rect, bool touch=false, Uint16 radius=0, Uint16 dir=DIR_ALL) const; + /// Returns the first found object at the given position + Object* getObjectAt(Sint16 x, Sint16 y, Uint16 mask=ALL) const; /// Returns the directions from the source rectangle to the destination rectangle /// \remark This may include an enlargment (eg. Olaf) /// \param src Source rectangle From DONOTREPLY at icculus.org Sun Sep 11 07:22:43 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 11 Sep 2005 07:22:43 -0400 Subject: r166 - trunk/src Message-ID: <20050911112243.12949.qmail@icculus.org> Author: jonas Date: 2005-09-11 07:22:42 -0400 (Sun, 11 Sep 2005) New Revision: 166 Modified: trunk/src/common.h trunk/src/editor.cpp trunk/src/editor.h trunk/src/gfxeng.cpp trunk/src/input.cpp trunk/src/lost_penguins.cpp trunk/src/objects_common.cpp trunk/src/objects_common.h trunk/src/scenario.cpp trunk/src/scenario.h Log: added editor selection support Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/common.h 2005-09-11 11:22:42 UTC (rev 166) @@ -124,7 +124,10 @@ KEY_FULL, KEY_QUIT, KEY_NOANIM, - KEY_DEBUG + KEY_DEBUG, + KEY_ADD_SEL, + KEY_RM_SEL, + KEY_DEL }; enum BasePointType { Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/editor.cpp 2005-09-11 11:22:42 UTC (rev 166) @@ -4,6 +4,7 @@ #include "menu.h" #include "font.h" #include "gfxeng.h" +#include "input.h" #include "objects_common.h" #include "editor.h" @@ -19,37 +20,98 @@ closeBox(); } +void Editor::updateSelection(Sint16 x, Sint16 y) { + if (!select_start) return; + select_rect.w=abs(x-select_start_x); + select_rect.h=abs(y-select_start_y); + if (x>select_start_x) select_rect.x=select_start_x; + else select_rect.x=x; + if (y>select_start_y) select_rect.y=select_start_y; + else select_rect.y=y; +} + void Editor::run_action(Uint32 action, Uint16 x, Uint16 y) { SDL_Rect shift=gfxeng->getShift(); Sint16 xs=x-shift.x; Sint16 ys=y-shift.y; gfxeng->update(UPDATE_ALL); - if (action&EDIT_RESET_ACTIONS) { + if (action&EDIT_MOUSE_MOTION) { + updateSelection(xs,ys); + } else if (action&EDIT_RESET_ACTIONS) { for (Uint8 i=0; i<6; i++) { action_mouse_pressed[i]=NOTHING; action_mouse_released[i]=NOTHING; } - action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_ACT_BOX; + action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_SEL_ACT_BOX; + action_mouse_released[SDL_BUTTON_LEFT]=EDIT_SELECT_END; action_mouse_pressed[SDL_BUTTON_RIGHT]=EDIT_BOX; action_mouse_released[SDL_BUTTON_RIGHT]=EDIT_ACT_BOX; + select_start=false; } else if (action&EDIT_BOX) { setBox(new EditBox(x,y)); + } else if (action&EDIT_SEL_ACT_BOX) { + if (box) { + Sint8 tmp=box->getCurrentEntry(x,y); + if (tmp==-1) run_action(EDIT_SELECT_START,x,y); + else box->act(tmp); + } else { + run_action(EDIT_SELECT_START,x,y); + } } else if (action&EDIT_ACT_BOX) { - if (box) box->act(box->getCurrentEntry(x,y)); - } else if (action&EDIT_REMOVE_OBJECT) { - Object* obj=scenario->getObjectAt(xs,ys); - if (obj) { - if (removefromBuf(obj->getName()).empty()) { - cout << "Unable to remove object " << obj->getName() << ": Name identifier not found!" << endl; - } else scenario->reloadMap(); + Sint8 tmp=box->getCurrentEntry(x,y); + if (box) box->act(tmp); + } else if (action&EDIT_REMOVE_OBJECTS) { + std::set::iterator sit=selection.begin(); + while (sit!=selection.end()) { + if (removefromBuf(*sit).empty()) { + cout << "Unable to remove object " << (*sit) << endl; + } + ++sit; } + scenario->reloadMap(); } else if (action&EDIT_PLACE_OBJECT) { scenario->reloadMap(); if (scenario->pool->addObjectbyName(place_name,xs,ys,place_parameters)) { appendtoBuf(place_name+" "+itos(xs)+" "+itos(ys)+" "+putParameters(place_parameters)); } place_parameters["name"]=scenario->pool->getNextObjectName(place_name); + } else if (action&EDIT_SELECT_START) { + select_start=true; + select_start_x=xs; + select_start_y=ys; + select_rect.x=select_start_x; + select_rect.y=select_start_y; + select_rect.w=select_rect.h=0; + } else if (action&EDIT_SELECT_END) { + updateSelection(xs,ys); + select_start=false; + std::set objects_sel; + Object* obj=NULL; + if (select_rect.w==0 && select_rect.h==0) { + if ((obj=scenario->getObjectAt(xs,ys))!=NULL) objects_sel.insert(obj); + } else { + objects_sel=scenario->getObjectsIn(ALL,select_rect); + } + object_iterator obit=objects_sel.begin(); + + if (input->keyState(KEY_ADD_SEL)) { + while (obit!=objects_sel.end()) { + selection.insert((*obit)->getName()); + ++obit; + } + } else if (input->keyState(KEY_RM_SEL)) { + while (obit!=objects_sel.end()) { + selection.erase((*obit)->getName()); + ++obit; + } + } else { + selection.clear(); + while (obit!=objects_sel.end()) { + selection.insert((*obit)->getName()); + ++obit; + } + } } else { } } @@ -144,7 +206,7 @@ } Sint16 tmp=y-area.y-WFONT-font_title->getHeight()-(int)(DFONT/2); Uint16 entrysize=DFONT+font->getHeight(); - Uint8 currententry=0; + Sint8 currententry=0; while (tmp>entrysize) { tmp-=entrysize; ++currententry; @@ -205,10 +267,8 @@ entries.push_back("Run"); entries.push_back("Quit"); entries.push_back(""); - entries.push_back("Place Object"); - entries.push_back("Remove Object"); - entries.push_back("Move Object"); - entries.push_back("Configure Object"); + entries.push_back("Place Objects"); + entries.push_back("Select Objects"); update(); } @@ -233,15 +293,12 @@ setGameMode(GAME_PLAY); scenario->reloadMap(); editor->closeBox(); - } else if (entries[curentry]=="Place Object") { + } else if (entries[curentry]=="Place Objects") { editor->setBox(new PlaceBox(area.x,area.y)); - } else if (entries[curentry]=="Remove Object") { - editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_REMOVE_OBJECT; + } else if (entries[curentry]=="Select Objects") { + editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_SELECT_START; + editor->action_mouse_released[SDL_BUTTON_LEFT]=EDIT_SELECT_END; editor->closeBox(); - } else if (entries[curentry]=="Move Object") { - editor->closeBox(); - } else if (entries[curentry]=="Configure Object") { - editor->closeBox(); } else if (entries[curentry]=="Quit") { quitGame(0); } else { Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/editor.h 2005-09-11 11:22:42 UTC (rev 166) @@ -2,10 +2,14 @@ #define DEF_EDITOR_H 1 #define EDIT_RESET_ACTIONS 0x00000001 +#define EDIT_MOUSE_MOTION 0x00000002 #define EDIT_BOX 0x00000004 #define EDIT_ACT_BOX 0x00000008 -#define EDIT_PLACE_OBJECT 0x00000010 -#define EDIT_REMOVE_OBJECT 0x00000020 +#define EDIT_SEL_ACT_BOX 0x00000010 +#define EDIT_PLACE_OBJECT 0x00000020 +#define EDIT_REMOVE_OBJECTS 0x00000040 +#define EDIT_SELECT_START 0x00000080 +#define EDIT_SELECT_END 0x00000100 /** \brief abstract Box base class @@ -164,6 +168,13 @@ Uint32 action_mouse_pressed[6]; /// Action type for the mouse buttons when releasing the button Uint32 action_mouse_released[6]; + std::set selection; + bool select_start; + SDL_Rect select_rect; + Sint16 select_start_x; + Sint16 select_start_y; + private: + void updateSelection(Sint16 x, Sint16 y); }; #endif Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/gfxeng.cpp 2005-09-11 11:22:42 UTC (rev 166) @@ -165,9 +165,21 @@ debugrect=*(*obit)->getPos(); drawRectangle(debugrect,1,SDL_MapRGB(screen->format,100,20,0)); } + // TODO: fix this gfxeng mess + if (editor && game_mode&GAME_EDIT) { + if (editor->selection.find((*obit)->getName())!=editor->selection.end()) { + debugrect=*(*obit)->getPos(); + drawRectangle(debugrect,3,SDL_MapRGB(screen->format,100,100,0)); + } + } SDL_BlitSurface((*obit)->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); ++obit; } + // TODO: fix this gfxeng mess + if (editor->select_start) { + debugrect=editor->select_rect; + drawRectangle(debugrect,1,SDL_MapRGB(screen->format,50,50,50)); + } if (game_mode&GAME_PLAY && scenario->player!=NULL) { tmprect=(scenario->player->getDrawPos()); Modified: trunk/src/input.cpp =================================================================== --- trunk/src/input.cpp 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/input.cpp 2005-09-11 11:22:42 UTC (rev 166) @@ -194,6 +194,10 @@ case SDL_QUIT: { quitGame(0); } + case SDL_MOUSEMOTION: { + editor->run_action(EDIT_MOUSE_MOTION,event.motion.x,event.motion.y); + break; + } case SDL_MOUSEBUTTONUP: { editor->run_action(editor->getActionMReleased(event.button.button),event.button.x,event.button.y); break; @@ -215,6 +219,8 @@ sfxeng->pauseMusic(); setMenu(new EditMenu()); gfxeng->update(UPDATE_ALL); + } else if (key==config.keybind[KEY_DEL]) { + editor->run_action(EDIT_REMOVE_OBJECTS); } else if (key==config.keybind[KEY_QUIT]) { quitGame(0); } else if (key==config.keybind[KEY_NOANIM]) { Modified: trunk/src/lost_penguins.cpp =================================================================== --- trunk/src/lost_penguins.cpp 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/lost_penguins.cpp 2005-09-11 11:22:42 UTC (rev 166) @@ -130,6 +130,9 @@ config.keybind[KEY_BAR] = SDLK_F1; config.keybind[KEY_FULL] = SDLK_f; config.keybind[KEY_QUIT] = SDLK_q; + config.keybind[KEY_ADD_SEL] = SDLK_LSHIFT; + config.keybind[KEY_RM_SEL] = SDLK_LCTRL; + config.keybind[KEY_DEL] = SDLK_DELETE; configfile.open(filename.c_str()); if (!configfile) return 0; Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/objects_common.cpp 2005-09-11 11:22:42 UTC (rev 166) @@ -10,7 +10,7 @@ Object::Object(Sint16 xcord, Sint16 ycord, ParameterMap& parameters): state(NOTHING), event(NULL), - otype(NOTHING), + otype(OTYPE_COMMON), delete_flag(false) { onum=++scenario->max_obj_num; Modified: trunk/src/objects_common.h =================================================================== --- trunk/src/objects_common.h 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/objects_common.h 2005-09-11 11:22:42 UTC (rev 166) @@ -8,6 +8,7 @@ #define OTYPE_DENSE_U 0x00000004 #define OTYPE_DENSE_D 0x00000008 #define OTYPE_DENSE 0x0000000F +#define OTYPE_COMMON 0x00000010 #define OTYPE_TOUCH 0x00000020 #define OTYPE_ENTER 0x00000040 #define OTYPE_CHARACTER 0x00000080 Modified: trunk/src/scenario.cpp =================================================================== --- trunk/src/scenario.cpp 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/scenario.cpp 2005-09-11 11:22:42 UTC (rev 166) @@ -333,6 +333,33 @@ return tmpset; } +std::set Scenario::getObjectsIn(Uint16 mask, const SDL_Rect& rect, bool touch, Uint16 distance, Uint16 dir) const { + SDL_Rect tmprect=rect; + if (dir&DIR_LEFT) { + tmprect.x-=distance; + tmprect.w+=distance; + } + if (dir&DIR_RIGHT) { + tmprect.x+=distance; + tmprect.w+=distance; + } + if (dir&DIR_UP) { + tmprect.y-=distance; + tmprect.h+=distance; + } + if (dir&DIR_DOWN) { + tmprect.y+=distance; + tmprect.h+=distance; + } + std::set tmpset; + object_iterator obit=pool->objectspool.begin(); + while (obit != pool->objectspool.end()) { + if ((((*obit)->getType())&mask) && ((*obit)->isIn(tmprect,touch))) tmpset.insert(*obit); + ++obit; + } + return tmpset; +} + Object* Scenario::getObjectAt(Sint16 x, Sint16 y, Uint16 mask) const { SDL_Rect tmprect; tmprect.x=x; Modified: trunk/src/scenario.h =================================================================== --- trunk/src/scenario.h 2005-09-09 15:49:26 UTC (rev 165) +++ trunk/src/scenario.h 2005-09-11 11:22:42 UTC (rev 166) @@ -46,6 +46,7 @@ /// \return A set of characters that are inside the enlarged source rectangle /// and that match the specified mask. std::set getCharactersIn(Uint16 mask, const SDL_Rect& rect, bool touch=false, Uint16 radius=0, Uint16 dir=DIR_ALL) const; + std::set getObjectsIn(Uint16 mask, const SDL_Rect& rect, bool touch=false, Uint16 radius=0, Uint16 dir=DIR_ALL) const; /// Returns the first found object at the given position Object* getObjectAt(Sint16 x, Sint16 y, Uint16 mask=ALL) const; /// Returns the directions from the source rectangle to the destination rectangle From DONOTREPLY at icculus.org Sun Sep 11 11:54:08 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 11 Sep 2005 11:54:08 -0400 Subject: r167 - trunk/src Message-ID: <20050911155408.30971.qmail@icculus.org> Author: jonas Date: 2005-09-11 11:54:08 -0400 (Sun, 11 Sep 2005) New Revision: 167 Modified: trunk/src/common.cpp trunk/src/common.h trunk/src/editor.cpp trunk/src/editor.h trunk/src/gfxeng.cpp trunk/src/gfxeng.h Log: move mask and vflags global variables to gfxeng again, added create*Surface functions in gfxeng, added support for a highlight mask surface Modified: trunk/src/common.cpp =================================================================== --- trunk/src/common.cpp 2005-09-11 11:22:42 UTC (rev 166) +++ trunk/src/common.cpp 2005-09-11 15:54:08 UTC (rev 167) @@ -15,18 +15,6 @@ Menu* menu=NULL; Box* box=NULL; Editor* editor=NULL; -#if SDL_BYTEORDER == SDL_BIG_ENDIAN -const Uint32 rmask=0xff000000; -const Uint32 gmask=0x00ff0000; -const Uint32 bmask=0x0000ff00; -const Uint32 amask=0x000000ff; -#else -const Uint32 rmask=0x000000ff; -const Uint32 gmask=0x0000ff00; -const Uint32 bmask=0x00ff0000; -const Uint32 amask=0xff000000; -#endif -Uint32 vflags=SDL_HWSURFACE|SDL_RESIZABLE|SDL_DOUBLEBUF|SDL_HWACCEL; string itos(int i) { std::stringstream s; Modified: trunk/src/common.h =================================================================== --- trunk/src/common.h 2005-09-11 11:22:42 UTC (rev 166) +++ trunk/src/common.h 2005-09-11 15:54:08 UTC (rev 167) @@ -255,12 +255,6 @@ //global variables //@{ -/// masks -extern const Uint32 rmask; -extern const Uint32 gmask; -extern const Uint32 bmask; -extern const Uint32 amask; -extern Uint32 vflags; /// Game configuration extern Config config; /// Image Cache Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-11 11:22:42 UTC (rev 166) +++ trunk/src/editor.cpp 2005-09-11 15:54:08 UTC (rev 167) @@ -14,12 +14,21 @@ string place_name=""; save_name="newmap.cfg"; box=NULL; + mask_surface=NULL; + reinit(); } Editor::~Editor() { closeBox(); } +void Editor::reinit() { + if (mask_surface) SDL_FreeSurface(mask_surface); + mask_surface=gfxeng->createRGBAScreenSurface(); + SDL_FillRect(mask_surface,0,SDL_MapRGBA(mask_surface->format,100,0,0,100)); + if (box) box->update(); +} + void Editor::updateSelection(Sint16 x, Sint16 y) { if (!select_start) return; select_rect.w=abs(x-select_start_x); @@ -219,9 +228,7 @@ getArea(); if (surface!=NULL) SDL_FreeSurface(surface); - SDL_Surface* tmp=SDL_CreateRGBSurface(vflags, area.w, area.h, 32, rmask, gmask, bmask, amask); - surface=SDL_DisplayFormatAlpha(tmp); - SDL_FreeSurface(tmp); + surface=gfxeng->createRGBASurface(area.w, area.h); SDL_FillRect(surface,0,SDL_MapRGBA(surface->format,200,200,200,180)); /* create a border */ Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-11 11:22:42 UTC (rev 166) +++ trunk/src/editor.h 2005-09-11 15:54:08 UTC (rev 167) @@ -133,6 +133,7 @@ public: Editor(); ~Editor(); + void reinit(); void run_action(Uint32 action, Uint16 x=0, Uint16 y=0); Uint32 getActionMPressed(Uint8 button) { if (button>=1 && button <6) return action_mouse_pressed[button]; @@ -173,6 +174,7 @@ SDL_Rect select_rect; Sint16 select_start_x; Sint16 select_start_y; + SDL_Surface* mask_surface; private: void updateSelection(Sint16 x, Sint16 y); }; Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-11 11:22:42 UTC (rev 166) +++ trunk/src/gfxeng.cpp 2005-09-11 15:54:08 UTC (rev 167) @@ -14,12 +14,24 @@ GraphicsEngine::GraphicsEngine(): +#if SDL_BYTEORDER == SDL_BIG_ENDIAN + rmask(0xff000000), + gmask(0x00ff0000), + bmask(0x0000ff00), + amask(0x000000ff), +#else + rmask(0x000000ff), + gmask(0x0000ff00), + bmask(0x00ff0000), + amask(0xff000000), +#endif screen(NULL), menubg(NULL), show_bar(true), show_fps(true), show_debug(false), fullscreen(config.full) { + vflags=SDL_HWSURFACE|SDL_RESIZABLE|SDL_DOUBLEBUF|SDL_HWACCEL; updatetype=UPDATE_ALL; shift.x=0; shift.y=0; @@ -106,6 +118,7 @@ vis_map.w=screen->w; vis_map.h=screen->h-bar.h; update(UPDATE_ALL); + if (editor && game_mode&GAME_EDIT) editor->reinit(); } inline SDL_Rect GraphicsEngine::clipToBG(SDL_Rect dest) const { @@ -161,6 +174,7 @@ while (obit!=scenario->pool->objectspool.end()) { tmprect=((*obit)->getDrawPos()); srcpos=(*obit)->getFrame().pos; + SDL_BlitSurface((*obit)->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); if (show_debug) { debugrect=*(*obit)->getPos(); drawRectangle(debugrect,1,SDL_MapRGB(screen->format,100,20,0)); @@ -168,11 +182,17 @@ // TODO: fix this gfxeng mess if (editor && game_mode&GAME_EDIT) { if (editor->selection.find((*obit)->getName())!=editor->selection.end()) { - debugrect=*(*obit)->getPos(); - drawRectangle(debugrect,3,SDL_MapRGB(screen->format,100,100,0)); + if (editor->mask_surface) { + debugrect=*(*obit)->getPos(); + SDL_Rect area=debugrect; + area.x=area.y=0; + SDL_BlitSurface(editor->mask_surface,&area,screen,shiftMapArea(debugrect,shift)); + } else { + debugrect=*(*obit)->getPos(); + drawRectangle(debugrect,3,SDL_MapRGB(screen->format,100,100,0)); + } } } - SDL_BlitSurface((*obit)->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); ++obit; } // TODO: fix this gfxeng mess @@ -461,3 +481,21 @@ /* vertical right */ SDL_FillRect(screen,&rect,color); } + +SDL_Surface* GraphicsEngine::createRGBSurface(Uint16 width, Uint16 height) { + SDL_Surface* tmp_surface=SDL_CreateRGBSurface(vflags, width, height, 32, rmask, gmask, bmask, 0); + SDL_Surface* return_surface=SDL_DisplayFormat(tmp_surface); + SDL_FreeSurface(tmp_surface); + return return_surface; +} + +SDL_Surface* GraphicsEngine::createRGBASurface(Uint16 width, Uint16 height) { + SDL_Surface* tmp_surface=SDL_CreateRGBSurface(vflags, width, height, 32, rmask, gmask, bmask, amask); + SDL_Surface* return_surface=SDL_DisplayFormatAlpha(tmp_surface); + SDL_FreeSurface(tmp_surface); + return return_surface; +} + +SDL_Surface* GraphicsEngine::createRGBAScreenSurface() { + return createRGBASurface(screen->w, screen->h); +} Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-11 11:22:42 UTC (rev 166) +++ trunk/src/gfxeng.h 2005-09-11 15:54:08 UTC (rev 167) @@ -42,7 +42,17 @@ shift.x=shift.y=0; } void drawRectangle(SDL_Rect rect, Uint8 border=1, Uint32 color=0); + SDL_Surface* createRGBSurface(Uint16 width, Uint16 height); + SDL_Surface* createRGBASurface(Uint16 width, Uint16 height); + SDL_Surface* createRGBAScreenSurface(); protected: + /// masks + const Uint32 rmask; + const Uint32 gmask; + const Uint32 bmask; + const Uint32 amask; + /// Video flags + Uint32 vflags; /// main screen SDL_Surface* screen; /// currently visible part of the map area From DONOTREPLY at icculus.org Mon Sep 12 07:31:58 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 12 Sep 2005 07:31:58 -0400 Subject: r168 - trunk/src Message-ID: <20050912113158.12789.qmail@icculus.org> Author: jonas Date: 2005-09-12 07:31:58 -0400 (Mon, 12 Sep 2005) New Revision: 168 Modified: trunk/src/players_common.cpp Log: 10l, added a default animation anim_right in the player constructor... Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-11 15:54:08 UTC (rev 167) +++ trunk/src/players_common.cpp 2005-09-12 11:31:58 UTC (rev 168) @@ -27,7 +27,7 @@ if (hasParam(parameters,"anim_left")) anim_left=loadAnimation(getParameters(parameters["anim_left"],':')); else anim_left.reset(new EmptyAnimation(&anim_right)); if (hasParam(parameters,"anim_right")) anim_right=loadAnimation(getParameters(parameters["anim_right"],':')); - else anim_right.reset(new EmptyAnimation(&anim_orig)); + else anim_right.reset(new EmptyAnimation()); if (hasParam(parameters,"anim_rock_left")) anim_rock_left=loadAnimation(getParameters(parameters["anim_rock_left"],':')); else anim_rock_left.reset(new EmptyAnimation(&anim_left)); if (hasParam(parameters,"anim_rock_right")) anim_rock_right=loadAnimation(getParameters(parameters["anim_rock_right"],':')); @@ -93,29 +93,31 @@ if (hasParam(parameters,"audio_land")) au_land=scenario->sndcache->loadWAV(parameters["audio_land"]); else au_land=scenario->sndcache->loadWAV("dizzy.wav"); - if (hasParam(parameters,"audio_act")) au_land=scenario->sndcache->loadWAV(parameters["audio_act"]); + if (hasParam(parameters,"audio_act")) au_act=scenario->sndcache->loadWAV(parameters["audio_act"]); else au_act=scenario->sndcache->loadWAV("button.wav"); - if (hasParam(parameters,"audio_useerror")) au_land=scenario->sndcache->loadWAV(parameters["audio_useerror"]); + if (hasParam(parameters,"audio_useerror")) au_useerror=scenario->sndcache->loadWAV(parameters["audio_useerror"]); else au_useerror=scenario->sndcache->loadWAV("useerror.wav"); - if (hasParam(parameters,"audio_newitem")) au_land=scenario->sndcache->loadWAV(parameters["audio_newitem"]); + if (hasParam(parameters,"audio_newitem")) au_newitem=scenario->sndcache->loadWAV(parameters["audio_newitem"]); else au_newitem=scenario->sndcache->loadWAV("pickup.wav"); - if (hasParam(parameters,"audio_hit")) au_land=scenario->sndcache->loadWAV(parameters["audio_hit"]); + if (hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV(parameters["audio_hit"]); else au_hit=scenario->sndcache->loadWAV("vikhit.wav"); - if (hasParam(parameters,"audio_elec")) au_land=scenario->sndcache->loadWAV(parameters["audio_elec"]); + if (hasParam(parameters,"audio_elec")) au_elec=scenario->sndcache->loadWAV(parameters["audio_elec"]); else au_elec=scenario->sndcache->loadWAV("elecdth.wav"); - if (hasParam(parameters,"audio_drown")) au_land=scenario->sndcache->loadWAV(parameters["audio_drown"]); + if (hasParam(parameters,"audio_drown")) au_drown=scenario->sndcache->loadWAV(parameters["audio_drown"]); else au_drown=scenario->sndcache->loadWAV("drown.wav"); - if (hasParam(parameters,"audio_fire")) au_land=scenario->sndcache->loadWAV(parameters["audio_fire"]); + if (hasParam(parameters,"audio_fire")) au_fire=scenario->sndcache->loadWAV(parameters["audio_fire"]); else au_fire=scenario->sndcache->loadWAV("fireball.wav"); - if (hasParam(parameters,"audio_die")) au_land=scenario->sndcache->loadWAV(parameters["audio_die"]); + if (hasParam(parameters,"audio_die")) au_die=scenario->sndcache->loadWAV(parameters["audio_die"]); else au_die=scenario->sndcache->loadWAV("bones.wav"); - if (hasParam(parameters,"audio_heal")) au_land=scenario->sndcache->loadWAV(parameters["audio_heal"]); + if (hasParam(parameters,"audio_heal")) au_heal=scenario->sndcache->loadWAV(parameters["audio_heal"]); else au_heal=scenario->sndcache->loadWAV("usefood1.wav"); if (!hasParam(parameters,"maxhealth")) maxhealth=4; if (!hasParam(parameters,"health")) health=min(3,(int)maxhealth); if (!hasParam(parameters,"maxspeedx")) maxspeedx=300; if (!hasParam(parameters,"maxspeedy")) maxspeedy=200; + + animation.reset(new EmptyAnimation((state&STATE_LEFT) ? &anim_left : &anim_right)); } Player::~Player() { From DONOTREPLY at icculus.org Mon Sep 12 12:09:22 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 12 Sep 2005 12:09:22 -0400 Subject: r169 - trunk/src Message-ID: <20050912160922.3920.qmail@icculus.org> Author: jonas Date: 2005-09-12 12:09:21 -0400 (Mon, 12 Sep 2005) New Revision: 169 Modified: trunk/src/editor.cpp trunk/src/editor.h trunk/src/gfxeng.cpp trunk/src/gfxeng.h trunk/src/input.cpp trunk/src/monsters_common.cpp trunk/src/objectpools.cpp trunk/src/objectpools.h trunk/src/physics.cpp trunk/src/players_common.cpp Log: Improvements of the Editor and related changes: o Support object selections with a visible rectangle during the selection o Support object movements o Support object previews when moving and placing o Introduced more buffer handling functions for changing/getting lines o ObjectsPool can now be used to add an object outside of the pools o ObjectsPool's addObject now handles all object addings, removed addCharacter, addPlayer, addMonster o GraphicsEngine has a better structured draw() function o GraphicsEngine's drawScene() is divided into drawGameScene() and drawEditScene() o PhysicHandler updates the editor's move_object animation o Monster and Players have a better default animation (anim_right/left) o Changed alpha values to 128 if possible to increase speed Modified: trunk/src/editor.cpp =================================================================== --- trunk/src/editor.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/editor.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -10,27 +10,29 @@ Editor::Editor() { - run_action(EDIT_RESET_ACTIONS); string place_name=""; save_name="newmap.cfg"; box=NULL; mask_surface=NULL; + move_object=NULL; reinit(); + run_action(EDIT_RESET_ACTIONS); } Editor::~Editor() { + if (move_object) delete move_object; closeBox(); } void Editor::reinit() { if (mask_surface) SDL_FreeSurface(mask_surface); mask_surface=gfxeng->createRGBAScreenSurface(); - SDL_FillRect(mask_surface,0,SDL_MapRGBA(mask_surface->format,100,0,0,100)); + //128 is a special case for an alpha value => faster + SDL_FillRect(mask_surface,0,SDL_MapRGBA(mask_surface->format,100,0,0,128)); if (box) box->update(); } void Editor::updateSelection(Sint16 x, Sint16 y) { - if (!select_start) return; select_rect.w=abs(x-select_start_x); select_rect.h=abs(y-select_start_y); if (x>select_start_x) select_rect.x=select_start_x; @@ -39,6 +41,11 @@ else select_rect.y=y; } +bool Editor::updateMove(Sint16 x, Sint16 y) { + if (move_object) return move_object->setPos(x,y); + else return false; +} + void Editor::run_action(Uint32 action, Uint16 x, Uint16 y) { SDL_Rect shift=gfxeng->getShift(); Sint16 xs=x-shift.x; @@ -46,7 +53,14 @@ gfxeng->update(UPDATE_ALL); if (action&EDIT_MOUSE_MOTION) { - updateSelection(xs,ys); + if (select_start) { + updateSelection(xs,ys); + gfxeng->update(UPDATE_ALL); + } + if (move_start) { + updateMove(xs,ys); + gfxeng->update(UPDATE_ALL); + } } else if (action&EDIT_RESET_ACTIONS) { for (Uint8 i=0; i<6; i++) { action_mouse_pressed[i]=NOTHING; @@ -57,6 +71,10 @@ action_mouse_pressed[SDL_BUTTON_RIGHT]=EDIT_BOX; action_mouse_released[SDL_BUTTON_RIGHT]=EDIT_ACT_BOX; select_start=false; + move_start=false; + // HACK + if (move_object) delete move_object; + move_object=NULL; } else if (action&EDIT_BOX) { setBox(new EditBox(x,y)); } else if (action&EDIT_SEL_ACT_BOX) { @@ -80,11 +98,14 @@ } scenario->reloadMap(); } else if (action&EDIT_PLACE_OBJECT) { - scenario->reloadMap(); - if (scenario->pool->addObjectbyName(place_name,xs,ys,place_parameters)) { + updateMove(xs,ys); + if (scenario->pool->addObject(move_object)) { appendtoBuf(place_name+" "+itos(xs)+" "+itos(ys)+" "+putParameters(place_parameters)); } place_parameters["name"]=scenario->pool->getNextObjectName(place_name); + editor->move_object=scenario->pool->addObjectbyName(place_name,-1000,-1000,place_parameters,true); + if (editor->move_object) editor->move_start=true; + else editor->move_start=false; } else if (action&EDIT_SELECT_START) { select_start=true; select_start_x=xs; @@ -121,12 +142,64 @@ ++obit; } } + } else if (action&EDIT_MOVE_START) { + move_start_x=xs; + move_start_y=ys; + // HACK + if (move_object) delete move_object; + if ((move_object=scenario->pool->moveObject(scenario->getObjectAt(xs,ys)))) move_start=true; + else move_start=false; + } else if (action&EDIT_MOVE_END) { + if (move_object==NULL) { + move_start=false; + return; + } + updateMove(xs,ys); + if (scenario->pool->addObject(move_object)) { + istringstream tmpstream(getBufLine(move_object->getName())); + string name, x, y; + tmpstream >> name >> x >> y; + string nss((istreambuf_iterator(tmpstream)), istreambuf_iterator()); + string newline=name+" "+itos(move_object->getPos()->x)+" "+itos(move_object->getPos()->y)+" "+nss; + changeBuf(newline,move_object->getName()); + } else { + move_object->setPos(move_start_x,move_start_y); + if (!scenario->pool->addObject(move_object)) { + delete move_object; + move_object=NULL; + move_start=false; + scenario->reloadMap(); + } + } + move_object=NULL; + move_start=false; } else { } } void Editor::appendtoBuf(string line) { scenario->mapbuf.push_back(line); } +Sint16 Editor::getBufLineNr(string match) { + for (Uint16 linenum=0; linenummapbuf.size(); linenum++) { + if (scenario->mapbuf[linenum].find(match)!=string::npos) return linenum; + } + return -1; +} +string Editor::getBufLine(string match) { + for (Uint16 linenum=0; linenummapbuf.size(); linenum++) { + if (scenario->mapbuf[linenum].find(match)!=string::npos) { + return scenario->mapbuf[linenum]; + } + } + return ""; +} +bool Editor::changeBuf(string newline, string match) { + Sint16 linenum=getBufLineNr(match); + if (linenum<0) return false; + if (linenum>=(int)scenario->mapbuf.size()) return false; + scenario->mapbuf[linenum]=newline; + return true; +} string Editor::removefromBuf(string match) { for (Uint16 linenum=0; linenummapbuf.size(); linenum++) { @@ -230,7 +303,7 @@ if (surface!=NULL) SDL_FreeSurface(surface); surface=gfxeng->createRGBASurface(area.w, area.h); - SDL_FillRect(surface,0,SDL_MapRGBA(surface->format,200,200,200,180)); + SDL_FillRect(surface,0,SDL_MapRGBA(surface->format,200,200,200,128)); /* create a border */ Sint16 tmph=0; SDL_Rect line; @@ -238,21 +311,21 @@ line.y=0; line.w=BORDERSIZE; line.h=area.h; - SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255)); + SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,SDL_ALPHA_OPAQUE)); line.x=area.w-BORDERSIZE; - SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255)); + SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,SDL_ALPHA_OPAQUE)); line.x=0; line.y=0; line.w=area.w; line.h=BORDERSIZE; - SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255)); + SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,SDL_ALPHA_OPAQUE)); line.y=area.h-BORDERSIZE; - SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255)); + SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,SDL_ALPHA_OPAQUE)); /* write title */ font_title->writeCenter(surface,title,WFONT); line.y=font_title->getHeight()+(int)((DFONT-line.h)/2); - SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,255)); + SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,SDL_ALPHA_OPAQUE)); line.h=LINESIZE; /* write entries */ @@ -261,12 +334,13 @@ if (centered) font->writeCenter(surface,entries[i],tmph); else font->write(surface,entries[i],WFONT,tmph); line.y=tmph+font->getHeight()+(int)((DFONT-line.h)/2); - SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,180)); + SDL_FillRect(surface,&line,SDL_MapRGBA(surface->format,100,100,100,128)); } } EditBox::EditBox(Sint16 x, Sint16 y): Box(x,y) { title="EDIT MAP"; + entries.push_back("Reload"); entries.push_back("New"); entries.push_back("Save As..."); entries.push_back("Save"); @@ -276,6 +350,7 @@ entries.push_back(""); entries.push_back("Place Objects"); entries.push_back("Select Objects"); + entries.push_back("Move Object"); update(); } @@ -283,6 +358,9 @@ gfxeng->update(UPDATE_ALL); if (curentry==-1 || curentry >= (Sint8)entries.size()) { editor->closeBox(); + } else if (entries[curentry]=="Reload") { + scenario->reloadMap(); + editor->closeBox(); } else if (entries[curentry]=="New") { editor->setBox(new NewMapBox(area.x,area.y)); } else if (entries[curentry]=="Save As...") { @@ -306,6 +384,10 @@ editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_SELECT_START; editor->action_mouse_released[SDL_BUTTON_LEFT]=EDIT_SELECT_END; editor->closeBox(); + } else if (entries[curentry]=="Move Object") { + editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_MOVE_START; + editor->action_mouse_released[SDL_BUTTON_LEFT]=EDIT_MOVE_END; + editor->closeBox(); } else if (entries[curentry]=="Quit") { quitGame(0); } else { @@ -483,6 +565,14 @@ for (Uint8 i=0; iplace_parameters[etitles[i]]=einput[i]; } - editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT; - editor->closeBox(); + if (editor->move_object) { + delete editor->move_object; + editor->move_start=false; + } + editor->move_object=scenario->pool->addObjectbyName(editor->place_name,-1000,-1000,editor->place_parameters,true); + if (editor->move_object) { + editor->move_start=true; + editor->action_mouse_pressed[SDL_BUTTON_LEFT]=EDIT_PLACE_OBJECT; + editor->closeBox(); + } } Modified: trunk/src/editor.h =================================================================== --- trunk/src/editor.h 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/editor.h 2005-09-12 16:09:21 UTC (rev 169) @@ -10,6 +10,8 @@ #define EDIT_REMOVE_OBJECTS 0x00000040 #define EDIT_SELECT_START 0x00000080 #define EDIT_SELECT_END 0x00000100 +#define EDIT_MOVE_START 0x00000200 +#define EDIT_MOVE_END 0x00000400 /** \brief abstract Box base class @@ -160,6 +162,9 @@ ParameterMap place_parameters; /// Append a command to the buffered map file void appendtoBuf(string); + string getBufLine(string match); + /// Change the specified line in the buffered map file + bool changeBuf(string,string); /* TODO: add header modifiers */ /// Remove the first line in the buffered map file matching the specified string string removefromBuf(string); @@ -174,9 +179,15 @@ SDL_Rect select_rect; Sint16 select_start_x; Sint16 select_start_y; + bool move_start; + Sint16 move_start_x; + Sint16 move_start_y; SDL_Surface* mask_surface; + Object* move_object; private: + Sint16 getBufLineNr(string); void updateSelection(Sint16 x, Sint16 y); + bool updateMove(Sint16 x, Sint16 y); }; #endif Modified: trunk/src/gfxeng.cpp =================================================================== --- trunk/src/gfxeng.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/gfxeng.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -49,49 +49,62 @@ } void GraphicsEngine::draw() { - //Menu - if (game_mode&GAME_MENU) { - //Assure we have a (correct) menu background - if (!menubg) { - if (game_mode&(GAME_PLAY|GAME_EDIT)) { + if (game_mode&GAME_PLAY) { + if (game_mode&GAME_MENU) { + //Assure we have a (correct) menu background + if (!menubg || updatetype==UPDATE_ALL) setGameMenuBG(); + if (updatetype==UPDATE_ALL) { setGameMenuBG(); - } else { - setMenuBG(); + drawMenu(); + } else if (updatetype==UPDATE_MENU) { + drawMenu(); } - } - if (updatetype==UPDATE_ALL) { - if (game_mode&(GAME_PLAY|GAME_EDIT)) { - setGameMenuBG(); - } else { - setMenuBG(); + } else if (game_mode&GAME_PAUSED) { + if (updatetype==UPDATE_ALL) { + drawGameScene(); + drawPlayerBar(); + } else if (updatetype==UPDATE_BAR) { + drawPlayerBar(); } - drawMenu(); - } else if (updatetype==UPDATE_MENU) { - drawMenu(); - } - //Paused game - } else if (game_mode&GAME_PAUSED) { - if (updatetype==UPDATE_ALL) { - drawScene(); + } else { + drawGameScene(); drawPlayerBar(); - } else if (updatetype==UPDATE_BAR) { - drawPlayerBar(); + drawFPS(); + updatetype=UPDATE_ALL; } - //Not paused running game - } else if (game_mode&GAME_PLAY) { - drawScene(); - drawPlayerBar(); - drawFPS(); - updatetype=UPDATE_ALL; } else if (game_mode&GAME_EDIT) { - if (show_fps) toggleFPS(); - if (show_bar) togglePlayerBar(); - if (!(game_mode&GAME_EDIT_NOANIM) || updatetype==UPDATE_ALL) { - drawScene(); + if (game_mode&GAME_MENU) { + //Assure we have a (correct) menu background + if (!menubg || updatetype==UPDATE_ALL) setGameMenuBG(); + if (updatetype==UPDATE_ALL) { + setGameMenuBG(); + drawMenu(); + } else if (updatetype==UPDATE_MENU) { + drawMenu(); + } + } else if (game_mode&GAME_EDIT_NOANIM) { + if (updatetype==UPDATE_ALL) { + drawEditScene(); + drawBox(); + } + } else { + drawEditScene(); drawBox(); updatetype=UPDATE_ALL; } - } else return; + } else { + if (game_mode&GAME_MENU) { + //Assure we have a (correct) menu background + if (!menubg) setMenuBG(); + if (updatetype==UPDATE_ALL) { + setMenuBG(); + drawMenu(); + } else if (updatetype==UPDATE_MENU) { + drawMenu(); + } + } else return; + } + //This is the most time consuming operation if (updatetype!=UPDATE_NOTHING) SDL_Flip(screen); updatetype=UPDATE_NOTHING; @@ -152,20 +165,44 @@ return shift; } -void GraphicsEngine::drawScene() { +void GraphicsEngine::drawGameScene() { + assert(game_mode&GAME_PLAY); //We don't want to change pos! SDL_Rect tmprect,srcpos,debugrect; - if (game_mode&GAME_PLAY) { - if (scenario->player!=NULL) { - shift=setShift(scenario->player->getCenter()); - } else { - shift.x=0; - shift.y=0; + if (scenario->player!=NULL) { + shift=setShift(scenario->player->getCenter()); + } else { + shift.x=0; + shift.y=0; + } + + tmprect=*scenario->area; + srcpos=scenario->background->getFrame().pos; + SDL_BlitSurface(scenario->background->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); + + object_iterator obit=scenario->pool->objectspool.begin(); + while (obit!=scenario->pool->objectspool.end()) { + tmprect=((*obit)->getDrawPos()); + srcpos=(*obit)->getFrame().pos; + SDL_BlitSurface((*obit)->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); + if (show_debug) { + debugrect=*(*obit)->getPos(); + drawRectangle(debugrect,1,SDL_MapRGB(screen->format,100,20,0)); } - } else if (game_mode&GAME_EDIT) { - SDL_FillRect(screen,NULL,0); + ++obit; } + if (scenario->player!=NULL) { + tmprect=(scenario->player->getDrawPos()); + srcpos=scenario->player->getFrame().pos; + SDL_BlitSurface(scenario->player->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); + } +} +void GraphicsEngine::drawEditScene() { + assert(editor && game_mode&GAME_EDIT); + SDL_Rect tmprect,srcpos,debugrect; + + SDL_FillRect(screen,NULL,0); tmprect=*scenario->area; srcpos=scenario->background->getFrame().pos; SDL_BlitSurface(scenario->background->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); @@ -179,37 +216,44 @@ debugrect=*(*obit)->getPos(); drawRectangle(debugrect,1,SDL_MapRGB(screen->format,100,20,0)); } - // TODO: fix this gfxeng mess - if (editor && game_mode&GAME_EDIT) { - if (editor->selection.find((*obit)->getName())!=editor->selection.end()) { - if (editor->mask_surface) { - debugrect=*(*obit)->getPos(); - SDL_Rect area=debugrect; - area.x=area.y=0; - SDL_BlitSurface(editor->mask_surface,&area,screen,shiftMapArea(debugrect,shift)); - } else { - debugrect=*(*obit)->getPos(); - drawRectangle(debugrect,3,SDL_MapRGB(screen->format,100,100,0)); - } + if (editor->selection.find((*obit)->getName())!=editor->selection.end()) { + if (editor->mask_surface) { + debugrect=*(*obit)->getPos(); + SDL_Rect area=debugrect; + area.x=area.y=0; + SDL_BlitSurface(editor->mask_surface,&area,screen,shiftMapArea(debugrect,shift)); + } else { + debugrect=*(*obit)->getPos(); + drawRectangle(debugrect,3,SDL_MapRGB(screen->format,100,100,0)); } } ++obit; } - // TODO: fix this gfxeng mess + + if (editor->move_object) { + tmprect=editor->move_object->getDrawPos(); + srcpos=editor->move_object->getFrame().pos; + SDL_BlitSurface(editor->move_object->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); + + if (editor->mask_surface) { + debugrect=*(editor->move_object->getPos()); + SDL_Rect area=debugrect; + area.x=area.y=0; + SDL_BlitSurface(editor->mask_surface,&area,screen,shiftMapArea(debugrect,shift)); + } else { + debugrect=*(editor->move_object->getPos()); + drawRectangle(debugrect,3,SDL_MapRGB(screen->format,100,100,0)); + } + } if (editor->select_start) { debugrect=editor->select_rect; drawRectangle(debugrect,1,SDL_MapRGB(screen->format,50,50,50)); } - - if (game_mode&GAME_PLAY && scenario->player!=NULL) { - tmprect=(scenario->player->getDrawPos()); - srcpos=scenario->player->getFrame().pos; - SDL_BlitSurface(scenario->player->getFrame().image,&srcpos,screen,shiftMapArea(tmprect,shift)); - } } //TODO don't draw the whole screen, just till bar, just upgrade certain regions of the bar void GraphicsEngine::drawPlayerBar() { + assert(game_mode&GAME_PLAY); if (!show_bar) return; //#players Uint8 pnum=scenario->pool->playerspool.size(); @@ -384,9 +428,9 @@ inline void GraphicsEngine::setGameMenuBG() { if (menubg) SDL_FreeSurface(menubg); if (game_mode&GAME_PLAY) { - drawScene(); + drawGameScene(); drawPlayerBar(); - } else if (game_mode&GAME_EDIT) drawScene(); + } else if (game_mode&GAME_EDIT) drawEditScene(); SDL_Flip(screen); SDL_Surface* tmp = SDL_CreateRGBSurface ( @@ -420,14 +464,8 @@ if (menu_background) { menubg=menu_background; } else { - SDL_Surface* tmp = SDL_CreateRGBSurface ( - SDL_HWSURFACE, - screen->w, - screen->h, - 32, - rmask,gmask,bmask,0); - SDL_FillRect(tmp,NULL,SDL_MapRGB(screen->format,0,0,0)); - menubg=SDL_DisplayFormat(tmp); + menubg=createRGBScreenSurface(); + SDL_FillRect(menubg,NULL,SDL_MapRGB(menubg->format,0,0,0)); } } @@ -490,12 +528,24 @@ } SDL_Surface* GraphicsEngine::createRGBASurface(Uint16 width, Uint16 height) { +#ifdef ALPHA SDL_Surface* tmp_surface=SDL_CreateRGBSurface(vflags, width, height, 32, rmask, gmask, bmask, amask); SDL_Surface* return_surface=SDL_DisplayFormatAlpha(tmp_surface); SDL_FreeSurface(tmp_surface); return return_surface; +#else + return createRGBSurface(width,height); +#endif } +SDL_Surface* GraphicsEngine::createRGBScreenSurface() { + return createRGBASurface(screen->w, screen->h); +} + SDL_Surface* GraphicsEngine::createRGBAScreenSurface() { +#ifdef ALPHA return createRGBASurface(screen->w, screen->h); +#else + return createRGBScreenSurface(); +#endif } Modified: trunk/src/gfxeng.h =================================================================== --- trunk/src/gfxeng.h 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/gfxeng.h 2005-09-12 16:09:21 UTC (rev 169) @@ -44,6 +44,7 @@ void drawRectangle(SDL_Rect rect, Uint8 border=1, Uint32 color=0); SDL_Surface* createRGBSurface(Uint16 width, Uint16 height); SDL_Surface* createRGBASurface(Uint16 width, Uint16 height); + SDL_Surface* createRGBScreenSurface(); SDL_Surface* createRGBAScreenSurface(); protected: /// masks @@ -75,7 +76,10 @@ protected: /// Draw the background and all objects in the pool. This is a very time /// consuming function... - inline void drawScene(); + ///@{ + inline void drawGameScene(); + inline void drawEditScene(); + ///@} /// Draw player bar inline void drawPlayerBar(); /// Draw the frames per second Modified: trunk/src/input.cpp =================================================================== --- trunk/src/input.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/input.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -221,6 +221,8 @@ gfxeng->update(UPDATE_ALL); } else if (key==config.keybind[KEY_DEL]) { editor->run_action(EDIT_REMOVE_OBJECTS); + } else if (key==config.keybind[KEY_DEBUG]) { + gfxeng->toggleShowDebug(); } else if (key==config.keybind[KEY_QUIT]) { quitGame(0); } else if (key==config.keybind[KEY_NOANIM]) { Modified: trunk/src/monsters_common.cpp =================================================================== --- trunk/src/monsters_common.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/monsters_common.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -30,6 +30,8 @@ if (!hasParam(parameters,"maxspeedy")) maxspeedy=0; if (hasParam(parameters,"audio_hit")) au_hit=scenario->sndcache->loadWAV(parameters["audio_hit"]); else au_hit=scenario->sndcache->loadWAV("monhit.wav"); + + animation.reset(new EmptyAnimation((state&STATE_LEFT) ? &anim_left : &anim_right)); } Monster::~Monster() { Modified: trunk/src/objectpools.cpp =================================================================== --- trunk/src/objectpools.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/objectpools.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -215,7 +215,7 @@ else return empty_parameter; } -Object* ObjectsPool::addObjectbyName(const string& obj, Sint16 x, Sint16 y, ParameterMap& objparam) { +Object* ObjectsPool::addObjectbyName(const string& obj, Sint16 x, Sint16 y, ParameterMap& objparam, bool outside) { ParameterMap parameters; if (hasParam(objparam,"file")) { parameters=getFileParameters(objparam["file"]); @@ -230,27 +230,27 @@ //Set names... if (!hasParam(parameters,"name")) parameters["name"]=getNextObjectName(obj); - if (obj=="Wall") return (addObject(new Wall(x,y,parameters))); - else if (obj=="Exit") return (addObject(new Exit(x,y,parameters))); - else if (obj=="Water") return (addObject(new Water(x,y,parameters))); - else if (obj=="Teleporter") return (addObject(new Teleporter(x,y,parameters))); - else if (obj=="Wind") return (addObject(new Wind(x,y,parameters))); - else if (obj=="Geyser") return (addObject(new Geyser(x,y,parameters))); - else if (obj=="Trigger") return (addObject(new Trigger(x,y,parameters))); - else if (obj=="Door") return (addObject(new Door(x,y,parameters))); - else if (obj=="Spike") return (addObject(new Spike(x,y,parameters))); - else if (obj=="Heart") return (addObject(new Heart(x,y,parameters))); - else if (obj=="Key") return (addObject(new Key(x,y,parameters))); - else if (obj=="Bomb") return (addObject(new Bomb(x,y,parameters))); - else if (obj=="TriggeredBomb") return (addCharacter(new TriggeredBomb(x,y,parameters))); - else if (obj=="DeadPlayer") return (addCharacter(new DeadPlayer(x,y,parameters))); - else if (obj=="Erik") return (addPlayer(new Erik(x,y,parameters))); - else if (obj=="Olaf") return (addPlayer(new Olaf(x,y,parameters))); - else if (obj=="Baleog") return (addPlayer(new Baleog(x,y,parameters))); - else if (obj=="Fang") return (addPlayer(new Fang(x,y,parameters))); - else if (obj=="Scorch") return (addPlayer(new Scorch(x,y,parameters))); - else if (obj=="Plant") return (addMonster(new Plant(x,y,parameters))); - else if (obj=="Zombie") return (addMonster(new Zombie(x,y,parameters))); + if (obj=="Wall") return (addObject(new Wall(x,y,parameters), outside)); + else if (obj=="Exit") return (addObject(new Exit(x,y,parameters), outside)); + else if (obj=="Water") return (addObject(new Water(x,y,parameters), outside)); + else if (obj=="Teleporter") return (addObject(new Teleporter(x,y,parameters), outside)); + else if (obj=="Wind") return (addObject(new Wind(x,y,parameters), outside)); + else if (obj=="Geyser") return (addObject(new Geyser(x,y,parameters), outside)); + else if (obj=="Trigger") return (addObject(new Trigger(x,y,parameters), outside)); + else if (obj=="Door") return (addObject(new Door(x,y,parameters), outside)); + else if (obj=="Spike") return (addObject(new Spike(x,y,parameters), outside)); + else if (obj=="Heart") return (addObject(new Heart(x,y,parameters), outside)); + else if (obj=="Key") return (addObject(new Key(x,y,parameters), outside)); + else if (obj=="Bomb") return (addObject(new Bomb(x,y,parameters), outside)); + else if (obj=="TriggeredBomb") return (addObject(new TriggeredBomb(x,y,parameters), outside)); + else if (obj=="DeadPlayer") return (addObject(new DeadPlayer(x,y,parameters), outside)); + else if (obj=="Erik") return (addObject(new Erik(x,y,parameters), outside)); + else if (obj=="Olaf") return (addObject(new Olaf(x,y,parameters), outside)); + else if (obj=="Baleog") return (addObject(new Baleog(x,y,parameters), outside)); + else if (obj=="Fang") return (addObject(new Fang(x,y,parameters), outside)); + else if (obj=="Scorch") return (addObject(new Scorch(x,y,parameters), outside)); + else if (obj=="Plant") return (addObject(new Plant(x,y,parameters), outside)); + else if (obj=="Zombie") return (addObject(new Zombie(x,y,parameters), outside)); else { cout << "Object " << obj << " unknown, skipping...\n"; return NULL; @@ -266,9 +266,22 @@ return NULL; } -Object* ObjectsPool::addObject(Object* object) { - if ( (object!=NULL) && (scenario->area==NULL || (scenario->checkPlace(*(object->getPos()),*scenario->area).enter==NOTHING)) ) { +Object* ObjectsPool::addObject(Object* object, bool outside) { + if (outside) return object; + else if ( (object!=NULL) && (scenario->area==NULL || (scenario->checkPlace(*(object->getPos()),*scenario->area).enter==NOTHING)) ) { objectspool.insert(object); + if (Character* ptrc = dynamic_cast(object)) { + characterspool.insert(ptrc); + if (Player* ptrv = dynamic_cast(object)) { + playerspool.insert(ptrv); + if (playerspool.size()==1) { + currentplayer=playerspool.begin(); + scenario->player=*currentplayer; + } + } else if (Monster* ptrm = dynamic_cast(object)) { + monsterspool.insert(ptrm); + } + } return object; } else { cout << "Couldn't place object!\n"; @@ -314,6 +327,7 @@ } Object* ObjectsPool::moveObject(Object* object) { + if (object==NULL) return NULL; objectspool.erase(object); if (Character* ptrc = dynamic_cast(object)) { characterspool.erase(ptrc); @@ -330,30 +344,6 @@ return object; } - -Character* ObjectsPool::addCharacter(Character* newcharacter) { - if ( (newcharacter!=NULL) && (scenario->checkPlace(*(newcharacter->getPos()),*scenario->area).enter==NOTHING) ) { - characterspool.insert(newcharacter); - scenario->pool->addObject(newcharacter); - return newcharacter; - } else { - cout << "Couldn't place character!\n"; - return NULL; - } -} - -Player* ObjectsPool::addPlayer(Player* newplayer) { - if ( (newplayer!=NULL) && (scenario->checkPlace(*(newplayer->getPos()),*scenario->area).enter==NOTHING) ) { - playerspool.insert(newplayer); - currentplayer=playerspool.begin(); - scenario->pool->addCharacter(newplayer); - return newplayer; - } else { - cout << "Couldn't place player!\n"; - return NULL; - } -} - Player* ObjectsPool::switchPlayer() { if (currentplayer != playerspool.end()) { sfxeng->playWAV(au_switch); @@ -368,18 +358,6 @@ } else return (scenario->player=NULL); } - -Monster* ObjectsPool::addMonster(Monster* newmonster) { - if ( (newmonster!=NULL) && (scenario->checkPlace(*(newmonster->getPos()),*scenario->area).enter==NOTHING) ) { - monsterspool.insert(newmonster); - scenario->pool->addCharacter(newmonster); - return newmonster; - } else { - cout << "Couldn't place monster!\n"; - return NULL; - } -} - bool ObjectsPool::empty() { if (scenario->pool->objectspool.empty()) return true; else return false; Modified: trunk/src/objectpools.h =================================================================== --- trunk/src/objectpools.h 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/objectpools.h 2005-09-12 16:09:21 UTC (rev 169) @@ -33,39 +33,29 @@ /// \param x x coordinate /// \param y y coordinate /// \param parameters A map of all parameters + /// \param outside True if the object shouldn't be added to the pools /// \return Pointer to the new entry in the objectspool or NULL if /// the object was not recognized - Object* addObjectbyName(const string& obj, Sint16 x=0, Sint16 y=0, ParameterMap& parameters=ParameterMap()); - //@{ - /// Add an Object to the objectspool + Object* addObjectbyName(const string& obj, Sint16 x=0, Sint16 y=0, ParameterMap& parameters=ParameterMap(), bool outside=false); + /// Add an Object to all corresponding pools /// \return Pointer to the new entry in the objectspool or NULL if it failed - Object* addObject(Object* object); - /// Add a Character to the characterspool (and objectspool) - /// \return Pointer to the new entry in the characterspool or NULL if it failed - Character* addCharacter(Character* newcharacter); - /// Add a Player to the playerspool (and objects/characterspool) - /// \return Pointer to the new entry in the playerspool or NULL if it failed - Player* addPlayer(Player* newplayer); - /// Add a Monster to the monsterspool - /// \return Pointer to the new entry in the monsterspool or NULL if it failed - Monster* addMonster(Monster* newmonster); - //@} + Object* addObject(Object* object, bool outside=false); /// Gets an object by it's name /// \pre The name must be unique (otherwise it's basically random) /// \return Pointer to the Object or NULL if it wasn't found - Object* getObject(const string& oname); + Object* getObject(const string& oname); /// Helper function to return the next available object name corresponding to the given base name - string getNextObjectName(const string& basename); + string getNextObjectName(const string& basename); //@{ /// Remove an Object (using an object_iterator) from all pools it belongs to /// \return object_iterator to the next entry in the pool or the end() - object_iterator removeObject(object_iterator it); + object_iterator removeObject(object_iterator it); /// Remove an Object (using a pointer to it) /// \return object_iterator to the next entry in the pool or the end() - object_iterator removeObject(Object* object); + object_iterator removeObject(Object* object); /// Detaches an Object from the objectspool /// \return Pointer to the detached Object - Object* moveObject(Object* object); + Object* moveObject(Object* object); //@} /// Selects a new current player (circular from left to right) if possible Player* switchPlayer(); Modified: trunk/src/physics.cpp =================================================================== --- trunk/src/physics.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/physics.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -5,6 +5,7 @@ #include "players_common.h" #include "scenario.h" #include "physics.h" +#include "editor.h" PhysicHandler::PhysicHandler(): @@ -126,6 +127,7 @@ } inline void PhysicHandler::updateEdit() { + assert(editor); object_iterator obit=scenario->pool->objectspool.begin(); while (obit!=scenario->pool->objectspool.end()) { //remove marked objects @@ -155,6 +157,9 @@ } else if ((*obit)->isRunning()) (*obit)->updateAnim(dt); ++obit; } + if (editor->move_object) { + if (editor->move_object->isRunning()) editor->move_object->updateAnim(dt); + } } inline void PhysicHandler::updatePaused() { Modified: trunk/src/players_common.cpp =================================================================== --- trunk/src/players_common.cpp 2005-09-12 11:31:58 UTC (rev 168) +++ trunk/src/players_common.cpp 2005-09-12 16:09:21 UTC (rev 169) @@ -27,7 +27,7 @@ if (hasParam(parameters,"anim_left")) anim_left=loadAnimation(getParameters(parameters["anim_left"],':')); else anim_left.reset(new EmptyAnimation(&anim_right)); if (hasParam(parameters,"anim_right")) anim_right=loadAnimation(getParameters(parameters["anim_right"],':')); - else anim_right.reset(new EmptyAnimation()); + else anim_right.reset(new EmptyAnimation(&anim_orig)); if (hasParam(parameters,"anim_rock_left")) anim_rock_left=loadAnimation(getParameters(parameters["anim_rock_left"],':')); else anim_rock_left.reset(new EmptyAnimation(&anim_left)); if (hasParam(parameters,"anim_rock_right")) anim_rock_right=loadAnimation(getParameters(parameters["anim_rock_right"],':')); From DONOTREPLY at icculus.org Mon Sep 12 16:46:25 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 12 Sep 2005 16:46:25 -0400 Subject: r170 - in trunk: data src/objects Message-ID: <20050912204625.1266.qmail@icculus.org> Author: jonas Date: 2005-09-12 16:46:25 -0400 (Mon, 12 Sep 2005) New Revision: 170 Added: trunk/data/baleog.inf trunk/data/olaf.inf Modified: trunk/data/map1.cfg trunk/src/objects/baleog.cpp trunk/src/objects/olaf.cpp Log: added new player description files, corrected a bug in baleogs animation names Added: trunk/data/baleog.inf =================================================================== --- trunk/data/baleog.inf 2005-09-12 16:09:21 UTC (rev 169) +++ trunk/data/baleog.inf 2005-09-12 20:46:25 UTC (rev 170) @@ -0,0 +1,34 @@ +#BALEOG +anim_left= name=baleog_idle_left: scale=2: bp_type=rightdown +anim_right= name=baleog_idle_right: scale=2: bp_type=leftdown +anim_rock_left= name=baleog_rock_left: scale=2: bp_type=rightdown +anim_rock_right= name=baleog_rock_right: scale=2: bp_type=leftdown +anim_walk_left= name=baleog_walk_left: scale=2: bp_type=rightdown +anim_walk_right= name=baleog_walk_right: scale=2: bp_type=leftdown +anim_push_left= name=baleog_push_left: scale=2: bp_type=rightdown +anim_push_right= name=baleog_push_right: scale=2: bp_type=leftdown +#anim_fall_middle= name=baleog_fall_middle: scale=2 +anim_fall_left= name=baleog_fall_left: scale=2: bp_type=rightdown +anim_fall_right= name=baleog_fall_right: scale=2: bp_type=leftdown +anim_fall_fast_left= name=baleog_fall_fast_left: scale=2: bp_type=rightdown +anim_fall_fast_right= name=baleog_fall_fast_right: scale=2: bp_type=leftdown +anim_crash_left= name=baleog_crash_left: scale=2: bp_type=rightdown: type=once +anim_crash_right= name=baleog_crash_right: scale=2: bp_type=leftdown: type=once +anim_rope_left= name=baleog_rope_left: scale=2: bp_type=rightdown +anim_rope_right= name=baleog_rope_right: scale=2: bp_type=leftdown +#anim_teleport_left= name=baleog_teleport_left: scale=2: bp_type=rightdown: type=once +#anim_teleport_right= name=baleog_teleport_right: scale=2: bp_type=leftdown: type=once +anim_die_crash_left= name=baleog_die_crash_left: scale=2: bp_type=rightdown: type=once +anim_die_crash_right= name=baleog_die_crash_right: scale=2: bp_type=leftdown: type=once +#anim_die_burn_left= name=baleog_die_burn_left: scale=2: bp_type=rightdown: type=once +#anim_die_burn_right= name=baleog_die_burn_right: scale=2: bp_type=leftdown: type=once +anim_die_bones_left= name=baleog_die_bones_left: scale=2: bp_type=rightdown: type=once +anim_die_bones_right= name=baleog_die_bones_right: scale=2: bp_type=leftdown: type=once +anim_die_elec_left= name=baleog_die_elec_left: scale=2: bp_type=rightdown: type=once +anim_die_elec_right= name=baleog_die_elec_right: scale=2: bp_type=leftdown: type=once +#anim_die_spike_left= name=baleog_die_spike_left: scale=2: bp_type=rightdown: type=once +#anim_die_spike_right= name=baleog_die_spike_right: scale=2: bp_type=leftdown: type=once +anim_bar= name=bar_baleog: scale=2: type=once + +anim_baleog_sword_left= name=baleog_sword_left: scale=2: bp_type=rightdown: type=once +anim_baleog_sword_right= name=baleog_sword_right: scale=2: bp_type=leftdown: type=once Modified: trunk/data/map1.cfg =================================================================== --- trunk/data/map1.cfg 2005-09-12 16:09:21 UTC (rev 169) +++ trunk/data/map1.cfg 2005-09-12 20:46:25 UTC (rev 170) @@ -1,23 +1,23 @@ -Background image=background.jpg +Background image=background.jpg #ENDHEADER -Wall 0 200 image=viking1.bmp -Wall 100 200 image=viking1.bmp -Wall 450 400 image=viking1.bmp -Wall 750 500 image=viking1.bmp -Wall 100 620 image=viking1.bmp -#Water 624 668 image=water.bmp -Exit 500 648 image=exit.bmp -Teleporter 750 400 image=viking1.bmp, exitx=100, exity=0 -Heart 100 400 image=apple.bmp -Heart 500 200 image=heart.bmp -#Wind 624 668 image=water.bmp,accel=-3000 +Wall 0 200 image=viking1.bmp +Wall 100 200 image=viking1.bmp +Wall 450 400 image=viking1.bmp +Wall 750 500 image=viking1.bmp +Wall 100 620 image=viking1.bmp +#Water 624 668 image=water.bmp +Exit 500 648 image=exit.bmp +Teleporter 750 400 image=viking1.bmp, exitx=100, exity=0 +Heart 100 400 image=apple.bmp +Heart 500 200 image=heart.bmp +#Wind 624 668 image=water.bmp,accel=-3000 Zombie 300 550 -#Plant 100 0 time_recover=5000 +#Plant 100 0 time_recover=5000 -Erik file=erik.inf -#Baleog -Olaf 0 5 -Scorch 0 10 -Fang 30 10 +Erik file=erik.inf +Baleog file=baleog.inf +Olaf 0 5 file=olaf.inf +#Scorch 0 10 +#Fang 30 10 Added: trunk/data/olaf.inf =================================================================== --- trunk/data/olaf.inf 2005-09-12 16:09:21 UTC (rev 169) +++ trunk/data/olaf.inf 2005-09-12 20:46:25 UTC (rev 170) @@ -0,0 +1,37 @@ +#OLAF +anim_left= name=olaf_idle_left: scale=2: bp_type=rightdown +anim_right= name=olaf_idle_right: scale=2: bp_type=leftdown +anim_rock_left= name=olaf_rock_left: scale=2: bp_type=rightdown +anim_rock_right= name=olaf_rock_right: scale=2: bp_type=leftdown +anim_walk_left= name=olaf_walk_left: scale=2: bp_type=rightdown +anim_walk_right= name=olaf_walk_right: scale=2: bp_type=leftdown +anim_push_left= name=olaf_push_left: scale=2: bp_type=rightdown +anim_push_right= name=olaf_push_right: scale=2: bp_type=leftdown +anim_fall_left= name=olaf_fall_left: scale=2: bp_type=rightdown +anim_fall_right= name=olaf_fall_right: scale=2: bp_type=leftdown +anim_fall_fast_left= name=olaf_fall_fast_left: scale=2: bp_type=rightdown +anim_fall_fast_right= name=olaf_fall_fast_right: scale=2: bp_type=leftdown +anim_crash_left= name=olaf_crash_left: scale=2: bp_type=rightdown: type=once +anim_crash_right= name=olaf_crash_right: scale=2: bp_type=leftdown: type=once +anim_rope_left= name=olaf_rope_left: scale=2: bp_type=rightdown +anim_rope_right= name=olaf_rope_right: scale=2: bp_type=leftdown +anim_teleport_left= name=olaf_teleport_left: scale=2: bp_type=rightdown: type=once +anim_teleport_right= name=olaf_teleport_right: scale=2: bp_type=leftdown: type=once +anim_die_bones_left= name=olaf_die_bones_left: scale=2: bp_type=rightdown: type=once +anim_die_bones_right= name=olaf_die_bones_right: scale=2: bp_type=leftdown: type=once +anim_die_elec_left= name=olaf_die_elec_left: scale=2: bp_type=rightdown: type=once +anim_die_elec_right= name=olaf_die_elec_right: scale=2: bp_type=leftdown: type=once +anim_die_spike_left= name=olaf_die_spike_left: scale=2: bp_type=rightdown: type=once +anim_die_spike_right= name=olaf_die_spike_right: scale=2: bp_type=leftdown: type=once +anim_bar= name=bar_olaf: scale=2: type=once + +anim_olaf_small_left= name=olaf_idle_small_left: scale=2: bp_type=rightdown +anim_olaf_small_right= name=olaf_idle_small_right: scale=2: bp_type=leftdown +anim_olaf_walk_small_left= name=olaf_walk_small_left: scale=2: bp_type=rightdown +anim_olaf_walk_small_right= name=olaf_walk_small_right: scale=2: bp_type=leftdown +anim_olaf_shield_left= name=olaf_idle_shield_left: scale=2: bp_type=rightdown +anim_olaf_shield_right= name=olaf_idle_shield_right: scale=2: bp_type=leftdown +anim_olaf_fall_shield_left= name=olaf_fall_shield_left: scale=2: bp_type=rightdown +anim_olaf_fall_shield_right= name=olaf_fall_shield_right: scale=2: bp_type=leftdown +anim_olaf_walk_shield_left= name=olaf_walk_shield_left: scale=2: bp_type=rightdown +anim_olaf_walk_shield_right= name=olaf_walk_shield_right: scale=2: bp_type=leftdown Modified: trunk/src/objects/baleog.cpp =================================================================== --- trunk/src/objects/baleog.cpp 2005-09-12 16:09:21 UTC (rev 169) +++ trunk/src/objects/baleog.cpp 2005-09-12 20:46:25 UTC (rev 170) @@ -13,16 +13,9 @@ weapon=Weapon(-1,W_STRIKE); /* Parameters */ - if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_left.bmp")); - if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(1,"baleog1_right.bmp")); - if (!hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(scenario->imgcache->loadImage("baleog1-run_left.png"),8); - if (!hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"baleog1-run_right.png"),8); - if (!hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_LD,ATYPE_ONCE,calcFPS(1,T_IRR)); - if (!hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_RD,ATYPE_ONCE,calcFPS(1,T_IRR)); - if (hasParam(parameters,"anim_baleog_sword_left")) anim_baleog_sword_left=loadAnimation(getParameters(parameters["anim_baleog_sword_left"],':')); else anim_baleog_sword_left=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_left.png"),8,BP_MD,ATYPE_ONCE); - if (hasParam(parameters,"anim_baleog_sword_right")) anim_baleog_sword_left=loadAnimation(getParameters(parameters["anim_baleog_sword_right"],':')); + if (hasParam(parameters,"anim_baleog_sword_right")) anim_baleog_sword_right=loadAnimation(getParameters(parameters["anim_baleog_sword_right"],':')); else anim_baleog_sword_right=loadAnimation(scenario->imgcache->loadImage(8,"BaleogCyborg_Slash_right.png"),8,BP_MD,ATYPE_ONCE); if (hasParam(parameters,"audio_sword")) au_sword=scenario->sndcache->loadWAV(parameters["audio_sword"]); Modified: trunk/src/objects/olaf.cpp =================================================================== --- trunk/src/objects/olaf.cpp 2005-09-12 16:09:21 UTC (rev 169) +++ trunk/src/objects/olaf.cpp 2005-09-12 20:46:25 UTC (rev 170) @@ -13,14 +13,6 @@ Player(xcord,ycord,parameters), fart(V_FART) { /* Parameters */ - if (!hasParam(parameters,"anim_left")) anim_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_left.bmp")); - if (!hasParam(parameters,"anim_right")) anim_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_right.bmp")); - if (!hasParam(parameters,"anim_walk_left")) anim_walk_left=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_left.png"),8); - if (!hasParam(parameters,"anim_walk_right")) anim_walk_right=loadAnimation(scenario->imgcache->loadImage(8,"olaf1-run_right.png"),8); - if (!hasParam(parameters,"anim_crash_left")) anim_crash_left=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_left.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - if (!hasParam(parameters,"anim_crash_right")) anim_crash_right=loadAnimation(scenario->imgcache->loadImage(1,"olaf1_land_right.bmp"),1,BP_MD,ATYPE_ONCE,calcFPS(1,T_IRR)); - if (!hasParam(parameters,"anim_die_bones_left")) anim_die_bones_left=loadAnimation(scenario->imgcache->loadImage(60,0,"kuru.bmp"),12,BP_MD,ATYPE_ONCE,25); - if (hasParam(parameters,"anim_olaf_small_left")) anim_olaf_small_left=loadAnimation(getParameters(parameters["anim_olaf_small_left"],':')); else anim_olaf_small_left=loadAnimation(scenario->imgcache->loadImage(7,"Olaf_Small_Walk_left.png"),1); if (hasParam(parameters,"anim_olaf_small_right")) anim_olaf_small_right=loadAnimation(getParameters(parameters["anim_olaf_small_right"],':')); From DONOTREPLY at icculus.org Tue Sep 13 08:56:33 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 13 Sep 2005 08:56:33 -0400 Subject: r171 - trunk/data Message-ID: <20050913125633.18488.qmail@icculus.org> Author: jonas Date: 2005-09-13 08:56:33 -0400 (Tue, 13 Sep 2005) New Revision: 171 Added: trunk/data/scorch.inf Modified: trunk/data/erik.inf trunk/data/map1.cfg Log: added prelimenary scorch lvl image support (scorch description file) Modified: trunk/data/erik.inf =================================================================== --- trunk/data/erik.inf 2005-09-12 20:46:25 UTC (rev 170) +++ trunk/data/erik.inf 2005-09-13 12:56:33 UTC (rev 171) @@ -1,5 +1,5 @@ #ERIK -anim_left= name=erik_idle_left: scale=2: bp_type=rightdown +anim_left= name=erik_idle_left: scale=2: bp_type=rightdown anim_right= name=erik_idle_right: scale=2: bp_type=leftdown anim_rock_left= name=erik_rock_left: scale=2: bp_type=rightdown anim_rock_right= name=erik_rock_right: scale=2: bp_type=leftdown Modified: trunk/data/map1.cfg =================================================================== --- trunk/data/map1.cfg 2005-09-12 20:46:25 UTC (rev 170) +++ trunk/data/map1.cfg 2005-09-13 12:56:33 UTC (rev 171) @@ -19,5 +19,5 @@ Erik file=erik.inf Baleog file=baleog.inf Olaf 0 5 file=olaf.inf -#Scorch 0 10 +Scorch 0 10 file=scorch.inf #Fang 30 10 Added: trunk/data/scorch.inf =================================================================== --- trunk/data/scorch.inf 2005-09-12 20:46:25 UTC (rev 170) +++ trunk/data/scorch.inf 2005-09-13 12:56:33 UTC (rev 171) @@ -0,0 +1,18 @@ +#SCORCH +anim_left= name=scorch_idle_left: scale=2: bp_type=rightdown +anim_right= name=scorch_idle_right: scale=2: bp_type=leftdown +anim_walk_left= name=scorch_walk_left: scale=2: bp_type=rightdown +anim_walk_right= name=scorch_walk_right: scale=2: bp_type=leftdown +anim_push_left= name=scorch_push_left: scale=2: bp_type=rightdown +anim_push_right= name=scorch_push_right: scale=2: bp_type=leftdown +anim_crash_left= name=scorch_crash_left: scale=2: bp_type=rightdown: type=once +anim_crash_right= name=scorch_crash_right: scale=2: bp_type=leftdown: type=once +anim_teleport_left= name=scorch_teleport_left: scale=2: bp_type=rightdown: type=once +anim_teleport_right= name=scorch_teleport_right: scale=2: bp_type=leftdown: type=once +anim_die_crash_left= name=scorch_die_crash_left: scale=2: bp_type=rightdown: type=once +anim_die_crash_right= name=scorch_die_crash_right: scale=2: bp_type=leftdown: type=once +anim_die_burn_left= name=scorch_die_burn_left: scale=2: bp_type=rightdown: type=once +anim_die_burn_right= name=scorch_die_burn_right: scale=2: bp_type=leftdown: type=once +anim_die_bones_left= name=scorch_die_bones_left: scale=2: bp_type=rightdown: type=once +anim_die_bones_right= name=scorch_die_bones_right: scale=2: bp_type=leftdown: type=once +anim_bar= name=bar_scorch: scale=2: type=once From DONOTREPLY at icculus.org Tue Sep 13 08:58:51 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 13 Sep 2005 08:58:51 -0400 Subject: r172 - trunk/data Message-ID: <20050913125851.18792.qmail@icculus.org> Author: jonas Date: 2005-09-13 08:58:51 -0400 (Tue, 13 Sep 2005) New Revision: 172 Modified: trunk/data/map2.cfg Log: 10l Modified: trunk/data/map2.cfg =================================================================== --- trunk/data/map2.cfg 2005-09-13 12:56:33 UTC (rev 171) +++ trunk/data/map2.cfg 2005-09-13 12:58:51 UTC (rev 172) @@ -26,7 +26,7 @@ #Vikings Fang 0 116 Erik 0 116 file=erik.inf -Olaf 0 116 +Olaf 0 116 file=olaf.inf #Scorch 0 116 #Baleog 0 116 From DONOTREPLY at icculus.org Wed Sep 14 09:21:13 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 14 Sep 2005 09:21:13 -0400 Subject: r173 - in trunk: data src Message-ID: <20050914132113.26569.qmail@icculus.org> Author: jonas Date: 2005-09-14 09:21:13 -0400 (Wed, 14 Sep 2005) New Revision: 173 Modified: trunk/data/baleog.inf trunk/data/erik.inf trunk/data/olaf.inf trunk/data/scorch.inf trunk/src/objects_common.cpp Log: support keyword scale parameter (lvl) Modified: trunk/data/baleog.inf =================================================================== --- trunk/data/baleog.inf 2005-09-13 12:58:51 UTC (rev 172) +++ trunk/data/baleog.inf 2005-09-14 13:21:13 UTC (rev 173) @@ -1,34 +1,34 @@ #BALEOG -anim_left= name=baleog_idle_left: scale=2: bp_type=rightdown -anim_right= name=baleog_idle_right: scale=2: bp_type=leftdown -anim_rock_left= name=baleog_rock_left: scale=2: bp_type=rightdown -anim_rock_right= name=baleog_rock_right: scale=2: bp_type=leftdown -anim_walk_left= name=baleog_walk_left: scale=2: bp_type=rightdown -anim_walk_right= name=baleog_walk_right: scale=2: bp_type=leftdown -anim_push_left= name=baleog_push_left: scale=2: bp_type=rightdown -anim_push_right= name=baleog_push_right: scale=2: bp_type=leftdown -#anim_fall_middle= name=baleog_fall_middle: scale=2 -anim_fall_left= name=baleog_fall_left: scale=2: bp_type=rightdown -anim_fall_right= name=baleog_fall_right: scale=2: bp_type=leftdown -anim_fall_fast_left= name=baleog_fall_fast_left: scale=2: bp_type=rightdown -anim_fall_fast_right= name=baleog_fall_fast_right: scale=2: bp_type=leftdown -anim_crash_left= name=baleog_crash_left: scale=2: bp_type=rightdown: type=once -anim_crash_right= name=baleog_crash_right: scale=2: bp_type=leftdown: type=once -anim_rope_left= name=baleog_rope_left: scale=2: bp_type=rightdown -anim_rope_right= name=baleog_rope_right: scale=2: bp_type=leftdown -#anim_teleport_left= name=baleog_teleport_left: scale=2: bp_type=rightdown: type=once -#anim_teleport_right= name=baleog_teleport_right: scale=2: bp_type=leftdown: type=once -anim_die_crash_left= name=baleog_die_crash_left: scale=2: bp_type=rightdown: type=once -anim_die_crash_right= name=baleog_die_crash_right: scale=2: bp_type=leftdown: type=once -#anim_die_burn_left= name=baleog_die_burn_left: scale=2: bp_type=rightdown: type=once -#anim_die_burn_right= name=baleog_die_burn_right: scale=2: bp_type=leftdown: type=once -anim_die_bones_left= name=baleog_die_bones_left: scale=2: bp_type=rightdown: type=once -anim_die_bones_right= name=baleog_die_bones_right: scale=2: bp_type=leftdown: type=once -anim_die_elec_left= name=baleog_die_elec_left: scale=2: bp_type=rightdown: type=once -anim_die_elec_right= name=baleog_die_elec_right: scale=2: bp_type=leftdown: type=once -#anim_die_spike_left= name=baleog_die_spike_left: scale=2: bp_type=rightdown: type=once -#anim_die_spike_right= name=baleog_die_spike_right: scale=2: bp_type=leftdown: type=once -anim_bar= name=bar_baleog: scale=2: type=once +anim_left= name=baleog_idle_left: scale=lvl: bp_type=rightdown +anim_right= name=baleog_idle_right: scale=lvl: bp_type=leftdown +anim_rock_left= name=baleog_rock_left: scale=lvl: bp_type=rightdown +anim_rock_right= name=baleog_rock_right: scale=lvl: bp_type=leftdown +anim_walk_left= name=baleog_walk_left: scale=lvl: bp_type=rightdown +anim_walk_right= name=baleog_walk_right: scale=lvl: bp_type=leftdown +anim_push_left= name=baleog_push_left: scale=lvl: bp_type=rightdown +anim_push_right= name=baleog_push_right: scale=lvl: bp_type=leftdown +#anim_fall_middle= name=baleog_fall_middle: scale=lvl +anim_fall_left= name=baleog_fall_left: scale=lvl: bp_type=rightdown +anim_fall_right= name=baleog_fall_right: scale=lvl: bp_type=leftdown +anim_fall_fast_left= name=baleog_fall_fast_left: scale=lvl: bp_type=rightdown +anim_fall_fast_right= name=baleog_fall_fast_right: scale=lvl: bp_type=leftdown +anim_crash_left= name=baleog_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_crash_right= name=baleog_crash_right: scale=lvl: bp_type=leftdown: type=once +anim_rope_left= name=baleog_rope_left: scale=lvl: bp_type=rightdown +anim_rope_right= name=baleog_rope_right: scale=lvl: bp_type=leftdown +#anim_teleport_left= name=baleog_teleport_left: scale=lvl: bp_type=rightdown: type=once +#anim_teleport_right= name=baleog_teleport_right: scale=lvl: bp_type=leftdown: type=once +anim_die_crash_left= name=baleog_die_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_die_crash_right= name=baleog_die_crash_right: scale=lvl: bp_type=leftdown: type=once +#anim_die_burn_left= name=baleog_die_burn_left: scale=lvl: bp_type=rightdown: type=once +#anim_die_burn_right= name=baleog_die_burn_right: scale=lvl: bp_type=leftdown: type=once +anim_die_bones_left= name=baleog_die_bones_left: scale=lvl: bp_type=rightdown: type=once +anim_die_bones_right= name=baleog_die_bones_right: scale=lvl: bp_type=leftdown: type=once +anim_die_elec_left= name=baleog_die_elec_left: scale=lvl: bp_type=rightdown: type=once +anim_die_elec_right= name=baleog_die_elec_right: scale=lvl: bp_type=leftdown: type=once +#anim_die_spike_left= name=baleog_die_spike_left: scale=lvl: bp_type=rightdown: type=once +#anim_die_spike_right= name=baleog_die_spike_right: scale=lvl: bp_type=leftdown: type=once +anim_bar= name=bar_baleog: scale=lvl: type=once -anim_baleog_sword_left= name=baleog_sword_left: scale=2: bp_type=rightdown: type=once -anim_baleog_sword_right= name=baleog_sword_right: scale=2: bp_type=leftdown: type=once +anim_baleog_sword_left= name=baleog_sword_left: scale=lvl: bp_type=rightdown: type=once +anim_baleog_sword_right= name=baleog_sword_right: scale=lvl: bp_type=leftdown: type=once Modified: trunk/data/erik.inf =================================================================== --- trunk/data/erik.inf 2005-09-13 12:58:51 UTC (rev 172) +++ trunk/data/erik.inf 2005-09-14 13:21:13 UTC (rev 173) @@ -1,50 +1,50 @@ #ERIK -anim_left= name=erik_idle_left: scale=2: bp_type=rightdown -anim_right= name=erik_idle_right: scale=2: bp_type=leftdown -anim_rock_left= name=erik_rock_left: scale=2: bp_type=rightdown -anim_rock_right= name=erik_rock_right: scale=2: bp_type=leftdown -anim_walk_left= name=erik_walk_left: scale=2: bp_type=rightdown -anim_walk_right= name=erik_walk_right: scale=2: bp_type=leftdown -anim_push_left= name=erik_push_left: scale=2: bp_type=rightdown -anim_push_right= name=erik_push_right: scale=2: bp_type=leftdown -anim_fall_middle= name=erik_fall_middle: scale=2 -anim_fall_left= name=erik_fall_left: scale=2: bp_type=rightdown -anim_fall_right= name=erik_fall_right: scale=2: bp_type=leftdown -anim_fall_fast_left= name=erik_fall_fast_left: scale=2: bp_type=rightdown -anim_fall_fast_right= name=erik_fall_fast_right: scale=2: bp_type=leftdown -anim_crash_left= name=erik_crash_left: scale=2: bp_type=rightdown: type=once -anim_crash_right= name=erik_crash_right: scale=2: bp_type=leftdown: type=once -anim_rope_left= name=erik_rope_left: scale=2: bp_type=rightdown -anim_rope_right= name=erik_rope_right: scale=2: bp_type=leftdown -anim_teleport_left= name=erik_teleport_left: scale=2: bp_type=rightdown: type=once -anim_teleport_right= name=erik_teleport_right: scale=2: bp_type=leftdown: type=once -anim_die_crash_left= name=erik_die_crash_left: scale=2: bp_type=rightdown: type=once -anim_die_crash_right= name=erik_die_crash_right: scale=2: bp_type=leftdown: type=once -anim_die_burn_left= name=erik_die_burn_left: scale=2: bp_type=rightdown: type=once -anim_die_burn_right= name=erik_die_burn_right: scale=2: bp_type=leftdown: type=once -anim_die_bones_left= name=erik_die_bones_left: scale=2: bp_type=rightdown: type=once -anim_die_bones_right= name=erik_die_bones_right: scale=2: bp_type=leftdown: type=once -anim_die_elec_left= name=erik_die_elec_left: scale=2: bp_type=rightdown: type=once -anim_die_elec_right= name=erik_die_elec_right: scale=2: bp_type=leftdown: type=once -anim_die_spike_left= name=erik_die_spike_left: scale=2: bp_type=rightdown: type=once -anim_die_spike_right= name=erik_die_spike_right: scale=2: bp_type=leftdown: type=once -anim_bar= name=bar_erik: scale=2: type=once +anim_left= name=erik_idle_left: scale=lvl: bp_type=rightdown +anim_right= name=erik_idle_right: scale=lvl: bp_type=leftdown +anim_rock_left= name=erik_rock_left: scale=lvl: bp_type=rightdown +anim_rock_right= name=erik_rock_right: scale=lvl: bp_type=leftdown +anim_walk_left= name=erik_walk_left: scale=lvl: bp_type=rightdown +anim_walk_right= name=erik_walk_right: scale=lvl: bp_type=leftdown +anim_push_left= name=erik_push_left: scale=lvl: bp_type=rightdown +anim_push_right= name=erik_push_right: scale=lvl: bp_type=leftdown +anim_fall_middle= name=erik_fall_middle: scale=lvl +anim_fall_left= name=erik_fall_left: scale=lvl: bp_type=rightdown +anim_fall_right= name=erik_fall_right: scale=lvl: bp_type=leftdown +anim_fall_fast_left= name=erik_fall_fast_left: scale=lvl: bp_type=rightdown +anim_fall_fast_right= name=erik_fall_fast_right: scale=lvl: bp_type=leftdown +anim_crash_left= name=erik_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_crash_right= name=erik_crash_right: scale=lvl: bp_type=leftdown: type=once +anim_rope_left= name=erik_rope_left: scale=lvl: bp_type=rightdown +anim_rope_right= name=erik_rope_right: scale=lvl: bp_type=leftdown +anim_teleport_left= name=erik_teleport_left: scale=lvl: bp_type=rightdown: type=once +anim_teleport_right= name=erik_teleport_right: scale=lvl: bp_type=leftdown: type=once +anim_die_crash_left= name=erik_die_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_die_crash_right= name=erik_die_crash_right: scale=lvl: bp_type=leftdown: type=once +anim_die_burn_left= name=erik_die_burn_left: scale=lvl: bp_type=rightdown: type=once +anim_die_burn_right= name=erik_die_burn_right: scale=lvl: bp_type=leftdown: type=once +anim_die_bones_left= name=erik_die_bones_left: scale=lvl: bp_type=rightdown: type=once +anim_die_bones_right= name=erik_die_bones_right: scale=lvl: bp_type=leftdown: type=once +anim_die_elec_left= name=erik_die_elec_left: scale=lvl: bp_type=rightdown: type=once +anim_die_elec_right= name=erik_die_elec_right: scale=lvl: bp_type=leftdown: type=once +anim_die_spike_left= name=erik_die_spike_left: scale=lvl: bp_type=rightdown: type=once +anim_die_spike_right= name=erik_die_spike_right: scale=lvl: bp_type=leftdown: type=once +anim_bar= name=bar_erik: scale=lvl: type=once #anim_die_water and anim_climb not specified -anim_erik_jump_left= name=erik_jump_left: scale=2: bp_type=rightdown: type=once -anim_erik_jump_right= name=erik_jump_right: scale=2: bp_type=leftdown: type=once -anim_erik_jump2_left= name=erik_jump2_left: scale=2: bp_type=rightdown: type=once -anim_erik_jump2_right= name=erik_jump2_right: scale=2: bp_type=leftdown: type=once -anim_erik_start_run_left= name=erik_start_run_left: scale=2: bp_type=rightdown: type=once -anim_erik_start_run_right= name=erik_start_run_right: scale=2: bp_type=leftdown: type=once -anim_erik_run_left= name=erik_run_left: scale=2: bp_type=rightdown: type=once -anim_erik_run_right= name=erik_run_right: scale=2: bp_type=leftdown: type=once -anim_erik_swim_left= name=erik_swim_left: scale=2: bp_type=rightdown: type=once -anim_erik_swim_right= name=erik_swim_right: scale=2: bp_type=leftdown: type=once -anim_erik_swim_up_left= name=erik_swim_up_left: scale=2: bp_type=rightdown: type=once -anim_erik_swim_up_right= name=erik_swim_up_right: scale=2: bp_type=leftdown: type=once -anim_erik_hit_water_left= name=erik_hit_water_left: scale=2: bp_type=rightdown: type=once -anim_erik_hit_water_right= name=erik_hit_water_right: scale=2: bp_type=leftdown: type=once +anim_erik_jump_left= name=erik_jump_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_jump_right= name=erik_jump_right: scale=lvl: bp_type=leftdown: type=once +anim_erik_jump2_left= name=erik_jump2_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_jump2_right= name=erik_jump2_right: scale=lvl: bp_type=leftdown: type=once +anim_erik_start_run_left= name=erik_start_run_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_start_run_right= name=erik_start_run_right: scale=lvl: bp_type=leftdown: type=once +anim_erik_run_left= name=erik_run_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_run_right= name=erik_run_right: scale=lvl: bp_type=leftdown: type=once +anim_erik_swim_left= name=erik_swim_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_swim_right= name=erik_swim_right: scale=lvl: bp_type=leftdown: type=once +anim_erik_swim_up_left= name=erik_swim_up_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_swim_up_right= name=erik_swim_up_right: scale=lvl: bp_type=leftdown: type=once +anim_erik_hit_water_left= name=erik_hit_water_left: scale=lvl: bp_type=rightdown: type=once +anim_erik_hit_water_right= name=erik_hit_water_right: scale=lvl: bp_type=leftdown: type=once au_hit= erikhit.wav au_jump= rboots.wav Modified: trunk/data/olaf.inf =================================================================== --- trunk/data/olaf.inf 2005-09-13 12:58:51 UTC (rev 172) +++ trunk/data/olaf.inf 2005-09-14 13:21:13 UTC (rev 173) @@ -1,37 +1,37 @@ #OLAF -anim_left= name=olaf_idle_left: scale=2: bp_type=rightdown -anim_right= name=olaf_idle_right: scale=2: bp_type=leftdown -anim_rock_left= name=olaf_rock_left: scale=2: bp_type=rightdown -anim_rock_right= name=olaf_rock_right: scale=2: bp_type=leftdown -anim_walk_left= name=olaf_walk_left: scale=2: bp_type=rightdown -anim_walk_right= name=olaf_walk_right: scale=2: bp_type=leftdown -anim_push_left= name=olaf_push_left: scale=2: bp_type=rightdown -anim_push_right= name=olaf_push_right: scale=2: bp_type=leftdown -anim_fall_left= name=olaf_fall_left: scale=2: bp_type=rightdown -anim_fall_right= name=olaf_fall_right: scale=2: bp_type=leftdown -anim_fall_fast_left= name=olaf_fall_fast_left: scale=2: bp_type=rightdown -anim_fall_fast_right= name=olaf_fall_fast_right: scale=2: bp_type=leftdown -anim_crash_left= name=olaf_crash_left: scale=2: bp_type=rightdown: type=once -anim_crash_right= name=olaf_crash_right: scale=2: bp_type=leftdown: type=once -anim_rope_left= name=olaf_rope_left: scale=2: bp_type=rightdown -anim_rope_right= name=olaf_rope_right: scale=2: bp_type=leftdown -anim_teleport_left= name=olaf_teleport_left: scale=2: bp_type=rightdown: type=once -anim_teleport_right= name=olaf_teleport_right: scale=2: bp_type=leftdown: type=once -anim_die_bones_left= name=olaf_die_bones_left: scale=2: bp_type=rightdown: type=once -anim_die_bones_right= name=olaf_die_bones_right: scale=2: bp_type=leftdown: type=once -anim_die_elec_left= name=olaf_die_elec_left: scale=2: bp_type=rightdown: type=once -anim_die_elec_right= name=olaf_die_elec_right: scale=2: bp_type=leftdown: type=once -anim_die_spike_left= name=olaf_die_spike_left: scale=2: bp_type=rightdown: type=once -anim_die_spike_right= name=olaf_die_spike_right: scale=2: bp_type=leftdown: type=once -anim_bar= name=bar_olaf: scale=2: type=once +anim_left= name=olaf_idle_left: scale=lvl: bp_type=rightdown +anim_right= name=olaf_idle_right: scale=lvl: bp_type=leftdown +anim_rock_left= name=olaf_rock_left: scale=lvl: bp_type=rightdown +anim_rock_right= name=olaf_rock_right: scale=lvl: bp_type=leftdown +anim_walk_left= name=olaf_walk_left: scale=lvl: bp_type=rightdown +anim_walk_right= name=olaf_walk_right: scale=lvl: bp_type=leftdown +anim_push_left= name=olaf_push_left: scale=lvl: bp_type=rightdown +anim_push_right= name=olaf_push_right: scale=lvl: bp_type=leftdown +anim_fall_left= name=olaf_fall_left: scale=lvl: bp_type=rightdown +anim_fall_right= name=olaf_fall_right: scale=lvl: bp_type=leftdown +anim_fall_fast_left= name=olaf_fall_fast_left: scale=lvl: bp_type=rightdown +anim_fall_fast_right= name=olaf_fall_fast_right: scale=lvl: bp_type=leftdown +anim_crash_left= name=olaf_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_crash_right= name=olaf_crash_right: scale=lvl: bp_type=leftdown: type=once +anim_rope_left= name=olaf_rope_left: scale=lvl: bp_type=rightdown +anim_rope_right= name=olaf_rope_right: scale=lvl: bp_type=leftdown +anim_teleport_left= name=olaf_teleport_left: scale=lvl: bp_type=rightdown: type=once +anim_teleport_right= name=olaf_teleport_right: scale=lvl: bp_type=leftdown: type=once +anim_die_bones_left= name=olaf_die_bones_left: scale=lvl: bp_type=rightdown: type=once +anim_die_bones_right= name=olaf_die_bones_right: scale=lvl: bp_type=leftdown: type=once +anim_die_elec_left= name=olaf_die_elec_left: scale=lvl: bp_type=rightdown: type=once +anim_die_elec_right= name=olaf_die_elec_right: scale=lvl: bp_type=leftdown: type=once +anim_die_spike_left= name=olaf_die_spike_left: scale=lvl: bp_type=rightdown: type=once +anim_die_spike_right= name=olaf_die_spike_right: scale=lvl: bp_type=leftdown: type=once +anim_bar= name=bar_olaf: scale=lvl: type=once -anim_olaf_small_left= name=olaf_idle_small_left: scale=2: bp_type=rightdown -anim_olaf_small_right= name=olaf_idle_small_right: scale=2: bp_type=leftdown -anim_olaf_walk_small_left= name=olaf_walk_small_left: scale=2: bp_type=rightdown -anim_olaf_walk_small_right= name=olaf_walk_small_right: scale=2: bp_type=leftdown -anim_olaf_shield_left= name=olaf_idle_shield_left: scale=2: bp_type=rightdown -anim_olaf_shield_right= name=olaf_idle_shield_right: scale=2: bp_type=leftdown -anim_olaf_fall_shield_left= name=olaf_fall_shield_left: scale=2: bp_type=rightdown -anim_olaf_fall_shield_right= name=olaf_fall_shield_right: scale=2: bp_type=leftdown -anim_olaf_walk_shield_left= name=olaf_walk_shield_left: scale=2: bp_type=rightdown -anim_olaf_walk_shield_right= name=olaf_walk_shield_right: scale=2: bp_type=leftdown +anim_olaf_small_left= name=olaf_idle_small_left: scale=lvl: bp_type=rightdown +anim_olaf_small_right= name=olaf_idle_small_right: scale=lvl: bp_type=leftdown +anim_olaf_walk_small_left= name=olaf_walk_small_left: scale=lvl: bp_type=rightdown +anim_olaf_walk_small_right= name=olaf_walk_small_right: scale=lvl: bp_type=leftdown +anim_olaf_shield_left= name=olaf_idle_shield_left: scale=lvl: bp_type=rightdown +anim_olaf_shield_right= name=olaf_idle_shield_right: scale=lvl: bp_type=leftdown +anim_olaf_fall_shield_left= name=olaf_fall_shield_left: scale=lvl: bp_type=rightdown +anim_olaf_fall_shield_right= name=olaf_fall_shield_right: scale=lvl: bp_type=leftdown +anim_olaf_walk_shield_left= name=olaf_walk_shield_left: scale=lvl: bp_type=rightdown +anim_olaf_walk_shield_right= name=olaf_walk_shield_right: scale=lvl: bp_type=leftdown Modified: trunk/data/scorch.inf =================================================================== --- trunk/data/scorch.inf 2005-09-13 12:58:51 UTC (rev 172) +++ trunk/data/scorch.inf 2005-09-14 13:21:13 UTC (rev 173) @@ -1,18 +1,18 @@ #SCORCH -anim_left= name=scorch_idle_left: scale=2: bp_type=rightdown -anim_right= name=scorch_idle_right: scale=2: bp_type=leftdown -anim_walk_left= name=scorch_walk_left: scale=2: bp_type=rightdown -anim_walk_right= name=scorch_walk_right: scale=2: bp_type=leftdown -anim_push_left= name=scorch_push_left: scale=2: bp_type=rightdown -anim_push_right= name=scorch_push_right: scale=2: bp_type=leftdown -anim_crash_left= name=scorch_crash_left: scale=2: bp_type=rightdown: type=once -anim_crash_right= name=scorch_crash_right: scale=2: bp_type=leftdown: type=once -anim_teleport_left= name=scorch_teleport_left: scale=2: bp_type=rightdown: type=once -anim_teleport_right= name=scorch_teleport_right: scale=2: bp_type=leftdown: type=once -anim_die_crash_left= name=scorch_die_crash_left: scale=2: bp_type=rightdown: type=once -anim_die_crash_right= name=scorch_die_crash_right: scale=2: bp_type=leftdown: type=once -anim_die_burn_left= name=scorch_die_burn_left: scale=2: bp_type=rightdown: type=once -anim_die_burn_right= name=scorch_die_burn_right: scale=2: bp_type=leftdown: type=once -anim_die_bones_left= name=scorch_die_bones_left: scale=2: bp_type=rightdown: type=once -anim_die_bones_right= name=scorch_die_bones_right: scale=2: bp_type=leftdown: type=once -anim_bar= name=bar_scorch: scale=2: type=once +anim_left= name=scorch_idle_left: scale=lvl: bp_type=rightdown +anim_right= name=scorch_idle_right: scale=lvl: bp_type=leftdown +anim_walk_left= name=scorch_walk_left: scale=lvl: bp_type=rightdown +anim_walk_right= name=scorch_walk_right: scale=lvl: bp_type=leftdown +anim_push_left= name=scorch_push_left: scale=lvl: bp_type=rightdown +anim_push_right= name=scorch_push_right: scale=lvl: bp_type=leftdown +anim_crash_left= name=scorch_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_crash_right= name=scorch_crash_right: scale=lvl: bp_type=leftdown: type=once +anim_teleport_left= name=scorch_teleport_left: scale=lvl: bp_type=rightdown: type=once +anim_teleport_right= name=scorch_teleport_right: scale=lvl: bp_type=leftdown: type=once +anim_die_crash_left= name=scorch_die_crash_left: scale=lvl: bp_type=rightdown: type=once +anim_die_crash_right= name=scorch_die_crash_right: scale=lvl: bp_type=leftdown: type=once +anim_die_burn_left= name=scorch_die_burn_left: scale=lvl: bp_type=rightdown: type=once +anim_die_burn_right= name=scorch_die_burn_right: scale=lvl: bp_type=leftdown: type=once +anim_die_bones_left= name=scorch_die_bones_left: scale=lvl: bp_type=rightdown: type=once +anim_die_bones_right= name=scorch_die_bones_right: scale=lvl: bp_type=leftdown: type=once +anim_bar= name=bar_scorch: scale=lvl: type=once Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-13 12:58:51 UTC (rev 172) +++ trunk/src/objects_common.cpp 2005-09-14 13:21:13 UTC (rev 173) @@ -151,7 +151,10 @@ double fps=0; AllignType allign_type=AT_MD; - if (hasParam(parameters,"scale")) scale_factor=atof(parameters.find("scale")->second.c_str()); + if (hasParam(parameters,"scale")) { + if (parameters.find("scale")->second == "lvl") scale_factor=config.lvlscale; + else scale_factor=atof(parameters.find("scale")->second.c_str()); + } if (hasParam(parameters,"bp_type")) { if (parameters.find("bp_type")->second.find("hleft") !=string::npos) { if (parameters.find("bp_type")->second.find("vup") !=string::npos) bp_type=BP_LU; From DONOTREPLY at icculus.org Wed Sep 14 12:00:24 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 14 Sep 2005 12:00:24 -0400 Subject: r174 - in trunk: data src Message-ID: <20050914160024.11244.qmail@icculus.org> Author: jonas Date: 2005-09-14 12:00:24 -0400 (Wed, 14 Sep 2005) New Revision: 174 Added: trunk/data/fang.inf Modified: trunk/data/map1.cfg trunk/data/map2.cfg trunk/src/objects_common.cpp Log: added fang lvl animations, fixed a huge animation type bug Added: trunk/data/fang.inf =================================================================== --- trunk/data/fang.inf 2005-09-14 13:21:13 UTC (rev 173) +++ trunk/data/fang.inf 2005-09-14 16:00:24 UTC (rev 174) @@ -0,0 +1,27 @@ +#FANG +anim_left= name=fang_idle_left: scale=lvl: bp_type=rightdown +anim_right= name=fang_idle_right: scale=lvl: bp_type=leftdown +anim_rock_left= name=fang_rock_left: scale=lvl: bp_type=rightdown +anim_rock_right= name=fang_rock_right: scale=lvl: bp_type=leftdown +anim_walk_left= name=fang_walk_left: scale=lvl: bp_type=rightdown +anim_walk_right= name=fang_walk_right: scale=lvl: bp_type=leftdown +anim_push_left= name=fang_push_left: scale=lvl: bp_type=rightdown +anim_push_right= name=fang_push_right: scale=lvl: bp_type=leftdown +anim_fall_left= name=fang_fall_left: scale=lvl: bp_type=rightdown +anim_fall_right= name=fang_fall_right: scale=lvl: bp_type=leftdown +anim_rope_left= name=fang_rope_left: scale=lvl: bp_type=rightdown +anim_rope_right= name=fang_rope_right: scale=lvl: bp_type=leftdown +anim_teleport_left= name=fang_teleport_left: scale=lvl: bp_type=rightdown: type=once +anim_teleport_right= name=fang_teleport_right: scale=lvl: bp_type=leftdown: type=once +anim_die_burn_left= name=fang_die_burn_left: scale=lvl: bp_type=rightdown: type=once +anim_die_burn_right= name=fang_die_burn_right: scale=lvl: bp_type=leftdown: type=once +anim_die_bones_left= name=fang_die_bones_left: scale=lvl: bp_type=rightdown: type=once +anim_die_bones_right= name=fang_die_bones_right: scale=lvl: bp_type=leftdown: type=once +anim_die_elec_left= name=fang_die_elec_left: scale=lvl: bp_type=rightdown: type=once +anim_die_elec_right= name=fang_die_elec_right: scale=lvl: bp_type=leftdown: type=once +anim_die_spike_left= name=fang_die_spike_left: scale=lvl: bp_type=rightdown: type=once +anim_die_spike_right= name=fang_die_spike_right: scale=lvl: bp_type=leftdown: type=once +anim_bar= name=bar_fang: scale=lvl: type=once + +anim_fang_claw_left= name=fang_claw_left: scale=lvl: bp_type=rightdown: type=once +anim_fang_claw_right= name=fang_claw_right: scale=lvl: bp_type=leftdown: type=once Modified: trunk/data/map1.cfg =================================================================== --- trunk/data/map1.cfg 2005-09-14 13:21:13 UTC (rev 173) +++ trunk/data/map1.cfg 2005-09-14 16:00:24 UTC (rev 174) @@ -20,4 +20,4 @@ Baleog file=baleog.inf Olaf 0 5 file=olaf.inf Scorch 0 10 file=scorch.inf -#Fang 30 10 +Fang 30 10 file=fang.inf Modified: trunk/data/map2.cfg =================================================================== --- trunk/data/map2.cfg 2005-09-14 13:21:13 UTC (rev 173) +++ trunk/data/map2.cfg 2005-09-14 16:00:24 UTC (rev 174) @@ -24,7 +24,7 @@ Geyser 200 668 image=viking1.bmp,aspeed=-1200 #Vikings -Fang 0 116 +Fang 0 116 file=fang.inf Erik 0 116 file=erik.inf Olaf 0 116 file=olaf.inf #Scorch 0 116 Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-14 13:21:13 UTC (rev 173) +++ trunk/src/objects_common.cpp 2005-09-14 16:00:24 UTC (rev 174) @@ -172,11 +172,11 @@ } if (hasParam(parameters,"type")) { animation_type=NOTHING; - if (parameters.find("type")->second.find("once")) animation_type|=ATYPE_ONCE; - if (parameters.find("type")->second.find("loop")) animation_type|=ATYPE_LOOP; - if (parameters.find("type")->second.find("swing")) animation_type|=ATYPE_SWING; - if (parameters.find("type")->second.find("step")) animation_type|=ATYPE_STEP; - if (parameters.find("type")->second.find("reverse")) { + if (parameters.find("type")->second.find("once") !=string::npos) animation_type|=ATYPE_ONCE; + if (parameters.find("type")->second.find("loop") !=string::npos) animation_type|=ATYPE_LOOP; + if (parameters.find("type")->second.find("swing") !=string::npos) animation_type|=ATYPE_SWING; + if (parameters.find("type")->second.find("step") !=string::npos) animation_type|=ATYPE_STEP; + if (parameters.find("type")->second.find("reverse" !=string::npos)) { animation_type<<=1; } if (animation_type==NOTHING) animation_type=ATYPE_LOOP; From DONOTREPLY at icculus.org Wed Sep 14 12:03:34 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 14 Sep 2005 12:03:34 -0400 Subject: r175 - trunk/src Message-ID: <20050914160334.11683.qmail@icculus.org> Author: jonas Date: 2005-09-14 12:03:34 -0400 (Wed, 14 Sep 2005) New Revision: 175 Modified: trunk/src/objects_common.cpp Log: 100l Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-14 16:00:24 UTC (rev 174) +++ trunk/src/objects_common.cpp 2005-09-14 16:03:34 UTC (rev 175) @@ -172,13 +172,12 @@ } if (hasParam(parameters,"type")) { animation_type=NOTHING; - if (parameters.find("type")->second.find("once") !=string::npos) animation_type|=ATYPE_ONCE; - if (parameters.find("type")->second.find("loop") !=string::npos) animation_type|=ATYPE_LOOP; - if (parameters.find("type")->second.find("swing") !=string::npos) animation_type|=ATYPE_SWING; - if (parameters.find("type")->second.find("step") !=string::npos) animation_type|=ATYPE_STEP; - if (parameters.find("type")->second.find("reverse" !=string::npos)) { - animation_type<<=1; - } + if (parameters.find("type")->second.find("once") !=string::npos) animation_type|=ATYPE_ONCE; + if (parameters.find("type")->second.find("loop") !=string::npos) animation_type|=ATYPE_LOOP; + if (parameters.find("type")->second.find("swing") !=string::npos) animation_type|=ATYPE_SWING; + if (parameters.find("type")->second.find("step") !=string::npos) animation_type|=ATYPE_STEP; + if (parameters.find("type")->second.find("reverse") !=string::npos) animation_type<<=1; + if (animation_type==NOTHING) animation_type=ATYPE_LOOP; if (parameters.find("type")->second.find("switch")) animation_type|=ATYPE_ST_SWITCH; } From DONOTREPLY at icculus.org Wed Sep 14 13:38:52 2005 From: DONOTREPLY at icculus.org (DONOTREPLY at icculus.org) Date: 14 Sep 2005 13:38:52 -0400 Subject: r176 - trunk/src Message-ID: <20050914173852.21962.qmail@icculus.org> Author: jonas Date: 2005-09-14 13:38:52 -0400 (Wed, 14 Sep 2005) New Revision: 176 Modified: trunk/src/objects_common.cpp Log: 1000l Modified: trunk/src/objects_common.cpp =================================================================== --- trunk/src/objects_common.cpp 2005-09-14 16:03:34 UTC (rev 175) +++ trunk/src/objects_common.cpp 2005-09-14 17:38:52 UTC (rev 176) @@ -178,8 +178,8 @@ if (parameters.find("type")->second.find("step") !=string::npos) animation_type|=ATYPE_STEP; if (parameters.find("type")->second.find("reverse") !=string::npos) animation_type<<=1; - if (animation_type==NOTHING) animation_type=ATYPE_LOOP; - if (parameters.find("type")->second.find("switch")) animation_type|=ATYPE_ST_SWITCH; + if (animation_type==NOTHING) animation_type=ATYPE_LOOP; + if (parameters.find("type")->second.find("switch") !=string::npos) animation_type|=ATYPE_ST_SWITCH; } if (hasParam(parameters,"fps")) fps=atof(parameters.find("fps")->second.c_str()); if (hasParam(parameters,"allign_type")) {