From 709a108c933e217796f48c1cd64e66e499f96e9c Mon Sep 17 00:00:00 2001 From: Geoff Date: Tue, 5 Aug 2014 12:06:06 -0400 Subject: [PATCH] fixed aspect ratio, fixed exit pre-intro --- main.cpp | 29 ++++++++++++++++------------- menu.cpp | 15 +++++++++------ sdlGraphics.cpp | 2 +- 3 files changed, 26 insertions(+), 20 deletions(-) diff --git a/main.cpp b/main.cpp index b3a20bd..d3d27e6 100644 --- a/main.cpp +++ b/main.cpp @@ -43,20 +43,23 @@ int main(int argc, char* args[]) gameRunning = false; } } - g_menu->menuMusic(false); - int gameStatus = g_game->intro(); - cout << "gameStatus is " << gameStatus << endl; - if (gameStatus == 0) + if (menuStatus != 0) { - gameRunning = false; - return 0; - } - cout << "starting level" << endl; - gameStatus = g_game->level(); - if (gameStatus == 0) - { - gameRunning = false; - return 0; + g_menu->menuMusic(false); + int gameStatus = g_game->intro(); + cout << "gameStatus is " << gameStatus << endl; + if (gameStatus == 0) + { + gameRunning = false; + return 0; + } + cout << "starting level" << endl; + gameStatus = g_game->level(); + if (gameStatus == 0) + { + gameRunning = false; + return 0; + } } } delete g_menu; diff --git a/menu.cpp b/menu.cpp index 6a8d62b..63bb416 100644 --- a/menu.cpp +++ b/menu.cpp @@ -12,14 +12,14 @@ mainMenu::mainMenu() mMusic = Mix_LoadMUS("audio/mainMenu1.mp3"); gSelect = Mix_LoadWAV("audio/select.wav"); Mix_Volume(2, currentSVolume); - StarT.x = 110; StarT.y = 335; StarT.w = 114; + StarT.x = (SCREEN_WIDTH / 4 - StarT.w) + SCREEN_WIDTH / 8; StarT.h = 49; - OptionS.x = 350; OptionS.y = 335; OptionS.w = 165; OptionS.h = 57; + OptionS.x = (SCREEN_WIDTH / 4 + SCREEN_WIDTH / 2 - OptionS.w / 2) - SCREEN_WIDTH / 8; } @@ -205,16 +205,19 @@ int mainMenu::loadOptions() SDL_QueryTexture(settingBar, NULL, NULL, &iW, &iH); SbaR.w = iW; SbaR.h = iH; - int mStop = currentMVolume * 4.2; - for (int i = 100; i < mStop; i += 10) + cout << "current volume is " << currentMVolume << endl; + cout << "current volume / 128 is " << (float)currentMVolume / 128 << endl; + cout << "current volume percentage is " << (((float)currentMVolume / 128) * 100) << endl; + int mStop = (SCREEN_WIDTH / 3) + ((SCREEN_WIDTH / 3) * ((float)currentMVolume / 128)); + for (int i = SCREEN_WIDTH / 3; i < mStop; i += 10) { SbaR.x = i; SbaR.y = 200; SDL_RenderCopy(renderer, settingBar, NULL, &SbaR); } - int sStop = currentSVolume * 4.2; + int sStop = (SCREEN_WIDTH / 3) + ((SCREEN_WIDTH / 3) * ((float)currentSVolume / 128)); SDL_RenderCopy(renderer, Svolume, NULL, &SvolumE); - for (int i = 100; i < sStop; i += 10) + for (int i = SCREEN_WIDTH / 3; i < sStop; i += 10) { SbaR.x = i; SbaR.y = 330; diff --git a/sdlGraphics.cpp b/sdlGraphics.cpp index 45f19ac..82b3950 100644 --- a/sdlGraphics.cpp +++ b/sdlGraphics.cpp @@ -1,5 +1,5 @@ #include "sdlGraphics.h" -const int SCREEN_WIDTH = 640; +const int SCREEN_WIDTH = 854; const int SCREEN_HEIGHT = 480; const char* WINDOW_TITLE = "Baldr"; int currentMVolume = 70;