commit 6d48320c
Now changes music to one with higher beat while near death
git-svn-id: https://blockattack.svn.sourceforge.net/svnroot/blockattack/trunk@73 9d7177f8-192b-0410-8f35-a16a89829b06
Changed files
| A | Game/music/highbeat.ogg |
| M | source/AUTH before |
| M | source/code/BlockGame.hpp before |
| M | source/code/main.cpp before |
| M | source/code/mainVars.hpp before |
diff --git a/Game/music/highbeat.ogg b/Game/music/highbeat.ogg
new file mode 100644
index 0000000..3d21dae
Binary files /dev/null and b/Game/music/highbeat.ogg differ
diff --git a/source/AUTH b/source/AUTH
index ece7723..bf6a392 100644
--- a/source/AUTH
+++ b/source/AUTH
@@ -136,7 +136,9 @@ counter.ogg openarena-svn900:/sound/feedback/hitlo.wav
counterFinal.ogg openarena-svn900:/sound/feedback/hit.wav
/music/
-bgMusic.ogg Trackballs team (http://trackballs.sourceforge.net/) v 1.2 (GPL2)
+bgMusic.ogg Trackballs team (http://trackballs.sourceforge.net/) v 1.2 (GPL2), copy of tb_design.ogg
+highbeat.ogg Trackballs team (http://trackballs.sourceforge.net/) v 1.2 (GPL2), derived from tb_genesis.ogg
+
diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp
index a49ed3e..3ded117 100644
--- a/source/code/BlockGame.hpp
+++ b/source/code/BlockGame.hpp
@@ -25,6 +25,7 @@
#include "stats.h"
#include "common.h"
+#include "mainVars.hpp"
////////////////////////////////////////////////////////////////////////////////
@@ -2123,10 +2124,26 @@ public:
}
else
{
- if( (0==lastCounter) && (SoundEnabled)&&(!NoSound))
- Mix_PlayChannel(1,counterFinalChunk,0);
- lastCounter = -1;
+ if(SoundEnabled&&(!NoSound)&&(timetrial)&&(SDL_GetTicks()>gameStartedAt+10000)&&(!bGameOver))
+ {
+ int currentCounter = (SDL_GetTicks()-(int)gameStartedAt)/1000;
+ if(currentCounter!=lastCounter)
+ {
+ if(currentCounter>117 && currentCounter<120)
+ Mix_PlayChannel(1,counterChunk,0);
+ }
+ lastCounter = currentCounter;
+ }
+ else
+ {
+ if( (0==lastCounter) && (SoundEnabled)&&(!NoSound))
+ {
+ Mix_PlayChannel(1,counterFinalChunk,0);
+ }
+ lastCounter = -1;
+ }
}
+
if ((bGameOver)&&(!editorMode))
if (hasWonTheGame)DrawIMG(iWinner, sBoard, 0, 5*bsize);
else if (bDraw) DrawIMG(iDraw, sBoard, 0, 5*bsize);
@@ -2199,9 +2216,13 @@ public:
stageButtonStatus = SBstageClear;
}
if ((TowerHeight>12)&&(prevTowerHeight<13)&&(!puzzleMode)) {
- if (SoundEnabled) Mix_PlayChannel(1, heartBeat, 0);
+ //if (SoundEnabled) Mix_PlayChannel(1, heartBeat, 0);
stop+=1000;
}
+
+ if ((TowerHeight>12)&&(!puzzleMode)&&(!bGameOver)) {
+ bNearDeath = true;
+ }
while (nowTime>nrStops*40+gameStartedAt) //Increase stops, till we reach nowTime
{
@@ -2279,8 +2300,8 @@ public:
}
ReduceStuff();
if ((timetrial) && (!bGameOver) && (nowTime>gameStartedAt+2*60*1000)) {
- if (SoundEnabled) Mix_PlayChannel(1, timesUp, 0);
SetGameOver();
+ if(!NoSound && SoundEnabled)Mix_PlayChannel(1,counterFinalChunk,0);
if ((theTopScoresTimeTrial.isHighScore(score))&&(!AI_Enabled)) {
theTopScoresTimeTrial.addScore(name, score);
//new highscore
diff --git a/source/code/main.cpp b/source/code/main.cpp
index d062ed7..22952c0 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -693,13 +693,12 @@ int InitImages()
{
//And here the music:
bgMusic = Mix_LoadMUS2((char*)"music/bgMusic.ogg");
+ highbeatMusic = Mix_LoadMUS2((char*)"music/highbeat.ogg");
//the music... we just hope it exists, else the user won't hear anything
//Same goes for the sounds
boing = Mix_LoadWAV2((char*)"sound/pop.ogg");
- timesUp = Mix_LoadWAV2((char*)"sound/whistleblow.ogg");
applause = Mix_LoadWAV2((char*)"sound/applause.ogg");
photoClick = Mix_LoadWAV2((char*)"sound/cameraclick.ogg");
- heartBeat = Mix_LoadWAV2((char*)"sound/heartbeat3.ogg");
typingChunk = Mix_LoadWAV2((char*)"sound/typing.ogg");
counterChunk = Mix_LoadWAV2((char*)"sound/counter.ogg");
counterFinalChunk = Mix_LoadWAV2((char*)"sound/counterFinal.ogg");
@@ -717,11 +716,10 @@ void UnloadImages()
if (!NoSound) //Only unload then it has been loaded!
{
Mix_FreeMusic(bgMusic);
+ Mix_FreeMusic(highbeatMusic);
Mix_FreeChunk(boing);
- Mix_FreeChunk(timesUp);
Mix_FreeChunk(applause);
Mix_FreeChunk(photoClick);
- Mix_FreeChunk(heartBeat);
Mix_FreeChunk(counterChunk);
Mix_FreeChunk(counterFinalChunk);
Mix_FreeChunk(typingChunk);
@@ -981,7 +979,7 @@ public:
}
}; //aBall
-const int maxNumberOfBalls = 100;
+const int maxNumberOfBalls = 6*12*2*2;
class ballManeger
{
@@ -1001,18 +999,19 @@ public:
}
}
+ //Adds a ball to the screen at given coordiantes, traveling right or not with color
int addBall(int x, int y,bool right,int color)
{
- //cout << "Tries to add a ball" << endl;
int ballNumber = 0;
+ //Find a free ball
while ((ballUsed[ballNumber])&&(ballNumber<maxNumberOfBalls))
ballNumber++;
+ //Could not find a free ball, return -1
if (ballNumber==maxNumberOfBalls)
return -1;
currentTime = SDL_GetTicks();
ballArray[ballNumber] = aBall(x,y,right,color);
ballUsed[ballNumber] = true;
- //cout << "Ball added" << endl;
return 1;
} //addBall
@@ -1027,7 +1026,7 @@ public:
oldBallUsed[i] = true;
oldBallArray[i] = ballArray[i];
ballArray[i].update();
- if (ballArray[i].getY()>800)
+ if (ballArray[i].getY()>800 || ballArray[i].getX()>xsize || ballArray[i].getX()<-ballSize)
{
ballArray[i].~aBall();
ballUsed[i] = false;
@@ -2548,7 +2547,7 @@ void DrawEverything(int xsize, int ysize,BlockGame &theGame, BlockGame &theGame2
if (seconds>9)
strHolder = itoa(minutes)+":"+itoa(seconds);
else strHolder = itoa(minutes)+":0"+itoa(seconds);
- if ((SoundEnabled)&&(!NoSound)&&(tid>0)&&(seconds<5)&&(minutes == 0)&&(seconds>1)&&(!(Mix_Playing(6)))) Mix_PlayChannel(6,heartBeat,0);
+ //if ((SoundEnabled)&&(!NoSound)&&(tid>0)&&(seconds<5)&&(minutes == 0)&&(seconds>1)&&(!(Mix_Playing(6)))) Mix_PlayChannel(6,heartBeat,0);
SFont_Write(screen,fBlueFont,theGame.topx+310,theGame.topy+150,strHolder.c_str());
}
else
@@ -2606,7 +2605,7 @@ void DrawEverything(int xsize, int ysize,BlockGame &theGame, BlockGame &theGame2
strHolder = itoa(minutes)+":"+itoa(seconds);
else
strHolder = itoa(minutes)+":0"+itoa(seconds);
- if ((SoundEnabled)&&(!NoSound)&&(tid>0)&&(seconds<5)&&(minutes == 0)&&(seconds>1)&&(!(Mix_Playing(6)))) Mix_PlayChannel(6,heartBeat,0);
+ //if ((SoundEnabled)&&(!NoSound)&&(tid>0)&&(seconds<5)&&(minutes == 0)&&(seconds>1)&&(!(Mix_Playing(6)))) Mix_PlayChannel(6,heartBeat,0);
SFont_Write(screen,fBlueFont,theGame2.topx+310,theGame2.topy+150,strHolder.c_str());
}
else
@@ -3251,8 +3250,28 @@ void changePuzzleLevels()
}
+class Keymenu {
+ static void setXY(int x, int y)
+ {
+ keymenu.x = x;
+ keymenu.y = y;
+ }
+
+ static void startMenu()
+ {
+ keymenu.activated = true;
+ setXY(0,0);
+ }
+
+ static void stopMenu()
+ {
+ keymenu.activated = false;
+ }
+};
+
#if NETWORK
#include "NetworkThing.hpp"
+#include "MenuSystem.h"
#endif
//The main function, quite big... too big
@@ -3496,8 +3515,8 @@ int main(int argc, char *argv[])
keySettings[0].down = SDLK_DOWN;
keySettings[0].left = SDLK_LEFT;
keySettings[0].right = SDLK_RIGHT;
- keySettings[0].change = SDLK_KP_ENTER;
- keySettings[0].push = SDLK_KP0;
+ keySettings[0].change = SDLK_RCTRL;
+ keySettings[0].push = SDLK_RSHIFT;
keySettings[2].up= SDLK_w;
keySettings[2].down = SDLK_s;
@@ -4047,6 +4066,22 @@ int main(int argc, char *argv[])
***************************** Joypad start ****************************
**********************************************************************/
+ //Menu
+ if(joypad1.working)
+ {
+ joypad1.update();
+ if(joypad1.but1)
+ {
+ if(!keymenu.activated && keymenu.canBeActivatedTime > SDL_GetTicks())
+ {
+ keymenu.activated = true;
+ keymenu.x = 0;
+ keymenu.y = 0;
+ }
+ }
+ }
+
+ //Gameplay
if (joyplay1||joyplay2)
{
if (joypad1.working && !theGame.AI_Enabled)
@@ -4204,7 +4239,13 @@ int main(int argc, char *argv[])
keys = SDL_GetKeyState(NULL);
- SDL_GetMouseState(&mousex,&mousey);
+ if(keymenu.activated)
+ {
+ mousex = keymenu.x*buttonXsize-10;
+ mousey = keymenu.y*buttonYsize-10;
+ }
+ else
+ SDL_GetMouseState(&mousex,&mousey);
/********************************************************************
**************** Here comes mouse play ******************************
@@ -4763,13 +4804,36 @@ int main(int argc, char *argv[])
//Sees if music is stopped and if music is enabled
- if ((!NoSound)&&(!Mix_PlayingMusic())&&(MusicEnabled))
+ if ((!NoSound)&&(!Mix_PlayingMusic())&&(MusicEnabled)&&(!bNearDeath))
{
// then starts playing it.
- Mix_VolumeMusic(MIX_MAX_VOLUME/2);
- Mix_PlayMusic(bgMusic, 0); //music loop
+ Mix_VolumeMusic(MIX_MAX_VOLUME);
+ Mix_PlayMusic(bgMusic, -1); //music loop
}
+ if(bNearDeath!=bNearDeathPrev)
+ {
+ if(bNearDeath)
+ {
+ if(!NoSound &&(MusicEnabled)) {
+ Mix_VolumeMusic(MIX_MAX_VOLUME);
+ Mix_PlayMusic(highbeatMusic, 1);
+ }
+ }
+ else
+ {
+ if(!NoSound &&(MusicEnabled)) {
+ Mix_VolumeMusic(MIX_MAX_VOLUME);
+ Mix_PlayMusic(bgMusic, -1);
+ }
+ }
+ }
+
+ bNearDeathPrev = bNearDeath;
+
+
+ //set bNearDeath to false theGame*.Update() will change to true as needed
+ bNearDeath = false;
//Updates the objects
theGame.Update();
theGame2.Update();
diff --git a/source/code/mainVars.hpp b/source/code/mainVars.hpp
index 6ebdee3..ea14264 100644
--- a/source/code/mainVars.hpp
+++ b/source/code/mainVars.hpp
@@ -23,6 +23,10 @@ Copyright (C) 2007 Poul Sander
blockattack@poulsander.com
*/
+//Make sure it is only included once
+#ifndef _MAINVARS_HPP
+#define _MAINVARS_HPP
+
//main variables and constants
//Some definitions
@@ -110,9 +114,6 @@ SDL_Surface *bOn;
SDL_Surface *bOff;
SDL_Surface *bChange;
SDL_Surface *b1024;
-//SDL_Surface *b1280;
-//SDL_Surface *b1400;
-//SDL_Surface *b1600;
SDL_Surface *iLevelCheck; //To the level select screen
SDL_Surface *iLevelCheckBox;
SDL_Surface *iCheckBoxArea;
@@ -129,15 +130,11 @@ SDL_Surface *garbageFill;
SDL_Surface *garbageM;
SDL_Surface *garbageML;
SDL_Surface *garbageMR;
-//new in 1.3.0 start
SDL_Surface *smiley[4];
SDL_Surface *garbageGM;
SDL_Surface *garbageGML;
SDL_Surface *garbageGMR;
-//new in 1.3.0 end
-//new in 1.3.2 start
SDL_Surface *transCover; //The transperant block, covers the upcomming
-//also new in 1.3.2 for the editor
#if LEVELEDITOR
SDL_Surface *bCreateFile;
SDL_Surface *bDeletePuzzle;
@@ -154,8 +151,6 @@ SDL_Surface *bSavePuzzle;
SDL_Surface *bSaveToFile;
SDL_Surface *bTestPuzzle;
#endif
-//new in 1.3.2 end
-//new in 1.4.0
SDL_Surface *bTheme;
SDL_Surface *bSkip;
SDL_Surface *bRetry;
@@ -175,11 +170,10 @@ SFont_Font *fSmallFont; //Stores the small font (SFont)
//TTFont ttfont; //Stores the TTF font (TTFSDL)
Mix_Music *bgMusic; //backgroundMusic
+Mix_Music *highbeatMusic; //Background music with higher beat
Mix_Chunk *boing; //boing sound when clearing
-Mix_Chunk *timesUp; //whistle when times up
Mix_Chunk *applause; //Applause, then the player is good
Mix_Chunk *photoClick; //clickSound
-Mix_Chunk *heartBeat; //heart beat
Mix_Chunk *typingChunk; //When writing
Mix_Chunk *counterChunk; //When counting down
Mix_Chunk *counterFinalChunk;
@@ -201,22 +195,20 @@ bool showGame; //the game is active don't show highscores/options
bool showOptions; //true if options is open
bool bScreenLocked; //Don't take input or allow any mouse interaction! Used for dialogbox and warningbox
bool showDialog;
-//new in 1.3.1
bool NoSound; //if true, absolutely no sound will be played, can be set from the commandline
//prevents crash on systems without a soundcard
-//end new 1.3.1
bool MusicEnabled; //true if background music is enabled
bool SoundEnabled; //true if sound effects is enabled
+bool bNearDeath; //Play music faster or louder while tru
+bool bNearDeathPrev; //Near death status last time checked.
bool bFullscreen; //true if game is running fullscreen
bool puzzleLoaded; //true if the puzzle levels have been loaded
bool drawBalls; //if true balls are drawed to the screen, this might lower framerate too much
bool standardBackground;
bool highPriority;
-//new in 1.3.2
bool editorMode = false;
bool editorModeTest = false;
-//end new 1.3.2
//Things for network play:
#if NETWORK
@@ -352,14 +344,17 @@ struct ButtonCords
};
ButtonCords cordNextButton = {
-cordNextButton.x = 3*bsize+(3*bsize-buttonXsize)/2,
-cordNextButton.y = 10*bsize,
-cordNextButton.xsize = buttonXsize,
-cordNextButton.ysize = buttonYsize};
+ cordNextButton.x = 3*bsize+(3*bsize-buttonXsize)/2,
+ cordNextButton.y = 10*bsize,
+ cordNextButton.xsize = buttonXsize,
+ cordNextButton.ysize = buttonYsize
+};
ButtonCords cordRetryButton = {
-cordRetryButton.x = (3*bsize-buttonXsize)/2,
-cordRetryButton.y = 10*bsize,
-cordRetryButton.xsize = buttonXsize,
-cordRetryButton.ysize = buttonYsize
+ cordRetryButton.x = (3*bsize-buttonXsize)/2,
+ cordRetryButton.y = 10*bsize,
+ cordRetryButton.xsize = buttonXsize,
+ cordRetryButton.ysize = buttonYsize
};
+
+#endif
\ No newline at end of file