summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLAMMJohnson <johnanthony@lavabit.com>2012-07-31 08:31:37 -0700
committerLAMMJohnson <johnanthony@lavabit.com>2012-07-31 08:31:37 -0700
commit5aa9933a245632b0f88a3abb352fbbd63968b62c (patch)
treed42eab98677f961d1b587a28d93396c9a331a6a0
parent5dafce09925d028569975e2b8666b3863c9ca50d (diff)
parent2863639aa4f18bffd8456c5d78c9ec1bf3d6b80a (diff)
downloadnyancat-5aa9933a245632b0f88a3abb352fbbd63968b62c.tar.gz
nyancat-5aa9933a245632b0f88a3abb352fbbd63968b62c.tar.bz2
nyancat-5aa9933a245632b0f88a3abb352fbbd63968b62c.zip
Merge pull request #2 from Compendium/master
Added options for volume control (-v, --volume [int])
-rw-r--r--README1
-rw-r--r--nyan.c13
2 files changed, 14 insertions, 0 deletions
diff --git a/README b/README
index 4028347..9b5536f 100644
--- a/README
+++ b/README
@@ -6,5 +6,6 @@ Usage: nyancat [OPTIONS]
-nc, --nocursor Don't show the cursor (default)
-sc, --cursor, --showcursor Show the cursor
-ns, --nosound Don't play sound
+ -v, --volume Sets Volume, if enabled, from 0 - 128
-r, --resolution Make next two arguments the screen resolution to use (0 and 0 for full resolution) (800x600 default)
-hw, -sw Use hardware or software SDL rendering, respectively. Hardware is default
diff --git a/nyan.c b/nyan.c
index 097e96d..dbe7667 100644
--- a/nyan.c
+++ b/nyan.c
@@ -78,6 +78,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;
@@ -267,6 +268,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")) {
@@ -338,6 +349,7 @@ init(void) {
Mix_OpenAudio( 44100, AUDIO_S16, 2, 256 );
load_music();
Mix_PlayMusic(music, 0);
+ Mix_VolumeMusic(sound_volume);
}
/* Choose our image set */
@@ -553,6 +565,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\