X-Git-Url: https://git.jsancho.org/?a=blobdiff_plain;f=Source%2FGameTick.cpp;h=5670dc3bc5eb12430461b8e4ef8c86b13adcfb0a;hb=f4685cb5e78e8e8056448d1de1bb75edb9a4fb1b;hp=2e3cd8303aff75a4b43154f37f172671104dc70a;hpb=4ee4eeed40f5f6a5e1811608ca53b2b8bdae5926;p=lugaru.git diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index 2e3cd83..5670dc3 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -32,6 +32,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "openal_wrapper.h" #include "Settings.h" #include "Input.h" +#include "Animation.h" using namespace std; @@ -47,7 +48,6 @@ extern XYZ viewer; extern int environment; extern float texscale; extern Terrain terrain; -extern OPENAL_SAMPLE *samp[100]; extern int channels[100]; extern int kTextureSize; extern float screenwidth,screenheight; @@ -59,7 +59,6 @@ extern int slomo; extern float slomodelay; extern bool floatjump; extern float volume; -extern Animation animation[animation_count]; extern Light light; extern float texdetail; extern GLubyte bloodText[512*512*3]; @@ -242,7 +241,6 @@ static bool stripfx(const char *str, const char *pfx) return !strncasecmp(str, pfx, strlen(pfx)); } -extern OPENAL_STREAM * strm[20]; extern "C" void PlaySoundEx(int channel, OPENAL_SAMPLE *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); extern "C" void PlayStreamEx(int chan, OPENAL_STREAM *sptr, OPENAL_DSPUNIT *dsp, signed char startpaused); @@ -1159,7 +1157,7 @@ static void cmd_dispatch(Game *game, const char *cmd) } /********************> Tick() <*****/ -extern void ScreenShot(const char * fname); +extern bool save_image(const char * fname); void Screenshot (void) { char temp[1024]; @@ -1172,8 +1170,8 @@ void Screenshot (void) #else mkdir("Screenshots", S_IRWXU); #endif - - ScreenShot(temp); + + save_image(temp); } @@ -1389,7 +1387,7 @@ void Game::Setenvironment(int which) windvector.z=3; if(ambientsound){ //PlaySoundEx( wind, samp[wind], NULL, true); - PlayStreamEx(stream_wind, strm[stream_wind], 0, true); + PlayStreamEx(stream_wind, samp[stream_wind], 0, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 256); } @@ -1399,18 +1397,10 @@ void Game::Setenvironment(int which) LoadTexture(":Data:Textures:bouldersnow.jpg",&objects.rocktextureptr,1,0); LoadTexture(":Data:Textures:snowbox.jpg",&objects.boxtextureptr,1,0); - OPENAL_Sample_Free(samp[footstepsound]); - OPENAL_Sample_Free(samp[footstepsound2]); - OPENAL_Sample_Free(samp[footstepsound3]); - OPENAL_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); + footstepsound = footstepsn1; + footstepsound2 = footstepsn2; + footstepsound3 = footstepst1; + footstepsound4 = footstepst2; LoadTexture(":Data:Textures:snow.jpg",&terraintexture,1,0); @@ -1448,23 +1438,15 @@ void Game::Setenvironment(int which) if(ambientsound){ //PlaySoundEx( desertambient, samp[desertambient], NULL, true); - PlayStreamEx( stream_desertambient, strm[stream_desertambient], NULL, true); + PlayStreamEx( stream_desertambient, samp[stream_desertambient], NULL, true); OPENAL_SetPaused(channels[stream_desertambient], false); OPENAL_SetVolume(channels[stream_desertambient], 256); } - OPENAL_Sample_Free(samp[footstepsound]); - OPENAL_Sample_Free(samp[footstepsound2]); - OPENAL_Sample_Free(samp[footstepsound3]); - OPENAL_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepsnow2.ogg"), OPENAL_HW3D, 0, 0); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); + footstepsound = footstepsn1; + footstepsound2 = footstepsn2; + footstepsound3 = footstepsn1; + footstepsound4 = footstepsn2; LoadTexture(":Data:Textures:sand.jpg",&terraintexture,1,0); @@ -1499,23 +1481,15 @@ void Game::Setenvironment(int which) LoadTexture(":Data:Textures:grassbox.jpg",&objects.boxtextureptr,1,0); if(ambientsound){ - PlayStreamEx( stream_wind, strm[stream_wind], NULL, true); + PlayStreamEx( stream_wind, samp[stream_wind], NULL, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 100); } - OPENAL_Sample_Free(samp[footstepsound]); - OPENAL_Sample_Free(samp[footstepsound2]); - OPENAL_Sample_Free(samp[footstepsound3]); - OPENAL_Sample_Free(samp[footstepsound4]); - samp[footstepsound] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound2] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepgrass2.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound3] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone1.ogg"), OPENAL_HW3D, 0, 0); - samp[footstepsound4] = OPENAL_Sample_Load(OPENAL_FREE, ConvertFileName(":Data:Sounds:footstepstone2.ogg"), OPENAL_HW3D, 0, 0); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound2], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound3], 4.0f, 1000.0f); - OPENAL_Sample_SetMinMaxDistance(samp[footstepsound4], 4.0f, 1000.0f); + footstepsound = footstepgr1; + footstepsound2 = footstepgr2; + footstepsound3 = footstepst1; + footstepsound4 = footstepst2; LoadTexture(":Data:Textures:grassdirt.jpg",&terraintexture,1,0); @@ -1629,7 +1603,7 @@ void Game::Loadlevel(char *name){ won=0; //campaign=0; - animation[bounceidleanim].Load((char *)":Data:Animations:Idle",middleheight,neutral); + animation[bounceidleanim].Load((char *)"Idle",middleheight,neutral); numdialogues=0; @@ -2195,7 +2169,7 @@ void Game::Loadlevel(char *name){ player[i].proportionlegs.z=0; } - player[i].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0); + player[i].tempanimation.Load((char *)"Tempanim",0,0); player[i].headmorphness=0; player[i].targetheadmorphness=1; @@ -2296,7 +2270,7 @@ void Game::Loadlevel(char *name){ { if(ambientsound) { - PlayStreamEx(stream_wind, strm[stream_wind], NULL, true); + PlayStreamEx(stream_wind, samp[stream_wind], NULL, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 256); } @@ -2308,7 +2282,7 @@ void Game::Loadlevel(char *name){ //PlaySoundEx(desertambient, // samp[desertambient], NULL, true); PlayStreamEx(stream_desertambient, - strm[stream_desertambient], NULL, true); + samp[stream_desertambient], NULL, true); OPENAL_SetPaused(channels[stream_desertambient], false); OPENAL_SetVolume(channels[stream_desertambient], 256); } @@ -2318,7 +2292,7 @@ void Game::Loadlevel(char *name){ if(ambientsound) { //PlaySoundEx(wind, samp[wind], NULL, true); - PlayStreamEx(stream_wind, strm[stream_wind], NULL, true); + PlayStreamEx(stream_wind, samp[stream_wind], NULL, true); OPENAL_SetPaused(channels[stream_wind], false); OPENAL_SetVolume(channels[stream_wind], 100); } @@ -2403,7 +2377,7 @@ void Game::Tick() if(mainmenu&&endgame==1)mainmenu=10; if( (Input::isKeyDown(SDLK_ESCAPE)||(mainmenu==0&&((Input::isKeyDown(jumpkey)||Input::isKeyDown(SDLK_SPACE)||(campaign)))&&!oldjumpkeydown&&campaign&&winfreeze)) && !mainmenutogglekeydown - && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==11||mainmenu==13||mainmenu==17||mainmenu==10) + && (!mainmenu||gameon||mainmenu==3||mainmenu==4||mainmenu==5||mainmenu==6||(mainmenu==7&&!entername)||mainmenu==9||mainmenu==10) ) { // go back selected=-1; if(mainmenu==1||mainmenu==2||mainmenu==0){ @@ -2416,7 +2390,7 @@ void Game::Tick() if(mainmenu&&musictoggle){ if(mainmenu==1||mainmenu==2||mainmenu==100){ OPENAL_SetFrequency(OPENAL_ALL, 0.001); - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); OPENAL_SetVolume(channels[stream_music3], 256); OPENAL_SetPaused(channels[music1], true); @@ -2439,7 +2413,7 @@ void Game::Tick() SaveSettings(*this); } - if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==13||mainmenu==10||mainmenu==11||mainmenu==100){ + if(mainmenu==4||mainmenu==5||mainmenu==6||mainmenu==7||mainmenu==9||mainmenu==10||mainmenu==100){ fireSound(); flash(); @@ -2452,8 +2426,6 @@ void Game::Tick() if(mainmenu==6)mainmenu=5; if(mainmenu==7)mainmenu=1; if(mainmenu==9)mainmenu=5; - if(mainmenu==11)mainmenu=5; - if(mainmenu==13)mainmenu=12; if(mainmenu==10)mainmenu=5; if(mainmenu==100){ mainmenu=5; @@ -2467,16 +2439,6 @@ void Game::Tick() } } - /*static bool minimaptogglekeydown; - if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown){ - minimap=1-minimap; - minimaptogglekeydown=1; - } - if(!Input::isKeyDown(SDLK_TAB)){ - minimaptogglekeydown=0; - } - */ - static bool minimaptogglekeydown; if(Input::isKeyDown(SDLK_TAB)&&!minimaptogglekeydown&&tutoriallevel){ if(tutorialstage!=51) @@ -2635,7 +2597,7 @@ void Game::Tick() } if(musictoggle){ - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); OPENAL_SetVolume(channels[stream_music3], 256); } @@ -2738,7 +2700,7 @@ void Game::Tick() gameon=1; OPENAL_SetPaused(channels[stream_music3], true); } - if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){//selected>=7&&(selected-7<=campaignnumchoices)){ + if(Input::Button()&&!oldbutton&&(selected-7>=accountactive->getCampaignChoicesMade())){ fireSound(); flash(); @@ -2835,36 +2797,6 @@ void Game::Tick() mainmenu=5; } } - if(mainmenu==11){ - if(Input::Button()&&!oldbutton&&selected=0&&selected<=accountactive->getProgress()){ - fireSound(); - - flash(); - - startbonustotal=0; - - loading=2; - loadtime=0; - targetlevel=selected; - if(firstload) { - TickOnceAfter(); - Loadlevel(selected); - } else - LoadStuff(); - campaign=0; - - mainmenu=0; - gameon=1; - OPENAL_SetPaused(channels[stream_music3], true); - } - if(Input::Button()&&!oldbutton&&selected==numchallengelevels){ - fireSound(); - - flash(); - - mainmenu=5; - } - } if(mainmenu==10){ endgame=2; if(Input::Button()&&!oldbutton&&selected==3){ @@ -5143,7 +5075,7 @@ void Game::Tick() player[numplayers].proportionlegs.z=0; } - player[numplayers].tempanimation.Load((char *)":Data:Animations:Tempanim",0,0); + player[numplayers].tempanimation.Load((char *)"Tempanim",0,0); player[numplayers].damagetolerance=200; @@ -7734,7 +7666,7 @@ void Game::Tick() OPENAL_StopSound(OPENAL_ALL); // hack...OpenAL renderer isn't stopping music after tutorial goes to level menu... OPENAL_SetFrequency(OPENAL_ALL, 0.001); - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); OPENAL_SetVolume(channels[stream_music3], 256); @@ -7948,15 +7880,15 @@ void Game::TickOnceAfter(){ if(musictoggle){ if(musicvolume[0]>0&&oldmusicvolume[0]<=0){ - PlayStreamEx( music1, strm[music1], NULL, true); + PlayStreamEx( music1, samp[music1], NULL, true); OPENAL_SetPaused(channels[music1], false); } if(musicvolume[1]>0&&oldmusicvolume[1]<=0){ - PlayStreamEx( stream_music2, strm[stream_music2], NULL, true); + PlayStreamEx( stream_music2, samp[stream_music2], NULL, true); OPENAL_SetPaused(channels[stream_music2], false); } if(musicvolume[2]>0&&oldmusicvolume[2]<=0){ - PlayStreamEx( stream_music3, strm[stream_music3], NULL, true); + PlayStreamEx( stream_music3, samp[stream_music3], NULL, true); OPENAL_SetPaused(channels[stream_music3], false); } if(musicvolume[0]<=0&&oldmusicvolume[0]>0){