summaryrefslogtreecommitdiffstats
path: root/nyan.c
diff options
context:
space:
mode:
authorCompendium <starstrider.industries@googlemail.com>2012-07-31 17:06:25 +0200
committerCompendium <starstrider.industries@googlemail.com>2012-07-31 17:06:25 +0200
commit2863639aa4f18bffd8456c5d78c9ec1bf3d6b80a (patch)
treeca6fa90b7b002ba996ac866f4b497164f6d336cf /nyan.c
parent8bb4fea24e25218ee6a9b3c9c86038c2b7d36aa6 (diff)
downloadnyancat-2863639aa4f18bffd8456c5d78c9ec1bf3d6b80a.tar.gz
nyancat-2863639aa4f18bffd8456c5d78c9ec1bf3d6b80a.tar.bz2
nyancat-2863639aa4f18bffd8456c5d78c9ec1bf3d6b80a.zip
Added options for volume control (-v, --volume)
Diffstat (limited to 'nyan.c')
-rw-r--r--nyan.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/nyan.c b/nyan.c
index d7ebdbb..790405d 100644
--- a/nyan.c
+++ b/nyan.c
@@ -76,6 +76,7 @@ static SDL_Event event;
static int running = 1;
static int SURF_TYPE = SDL_HWSURFACE;
static int sound = 1;
+static int sound_volume = 128;
static int fullscreen = 1;
static int catsize = 0;
static int cursor = 0;
@@ -259,6 +260,16 @@ handle_args(int argc, char **argv) {
cursor = 1;
else if(!strcmp(argv[i], "-ns") || !strcmp(argv[i], "--nosound"))
sound = 0;
+ else if((!strcmp(argv[i], "-v") || !strcmp(argv[i], "--volume")) && i < argc - 1) {
+ int vol = atoi(argv[++i]);
+ if(vol >= 0 && vol <= 128){
+ sound_volume = vol;
+ }
+ else {
+ puts("Arguments for Volume are not valid. Disabling sound.");
+ sound = 0;
+ }
+ }
else if(!strcmp(argv[i], "-h") || !strcmp(argv[i], "--help"))
usage(argv[0]);
else if(!strcmp(argv[i], "-c") || !strcmp(argv[i], "--catsize")) {
@@ -320,6 +331,7 @@ init(void) {
Mix_OpenAudio( 44100, AUDIO_S16, 2, 256 );
load_music();
Mix_PlayMusic(music, 0);
+ Mix_VolumeMusic(sound_volume);
}
/* Choose our image set */
@@ -549,6 +561,7 @@ usage(char* exname) {
-nc, --nocursor Don't show the cursor (default)\n\
-sc, --cursor, --showcursor Show the cursor\n\
-ns, --nosound Don't play sound\n\
+ -v, --volume Set Volume, if enabled, from 0 - 128\n\
-r, --resolution Make next two arguments the screen \n\
resolution to use (0 and 0 for full \n\
resolution) (800x600 default)\n\