r147 - in trunk/src: . objects
DONOTREPLY at icculus.org
DONOTREPLY at icculus.org
Mon Sep 5 17:53:58 EDT 2005
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);
}
More information about the lostpenguins-commits
mailing list