diff --git a/COM380/Project5/836518156-saving-money-coin-money-euro-ambition.jpg b/COM380/Project5/836518156-saving-money-coin-money-euro-ambition.jpg new file mode 100644 index 0000000..5ac4be3 Binary files /dev/null and b/COM380/Project5/836518156-saving-money-coin-money-euro-ambition.jpg differ diff --git a/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp b/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp index 94cca02..ca47430 100644 --- a/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp +++ b/COM380/Project5/GambleKit/CustomGameLogic/MainWindow.cpp @@ -74,6 +74,9 @@ void MainWindow::Resize(int width, int height) void MainWindow::KeyDown(int keyCode) { if (keyCode == VK_SPACE) + { + this->game->mainPage; + } if (keyCode == VK_ESCAPE) this->DestroyFormWindow(); diff --git a/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp index db9d3a5..ef12700 100644 --- a/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp +++ b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.cpp @@ -10,7 +10,7 @@ MainPage::MainPage(CustomGame *game) this->bet = 10; this->lines = 5; this->winning = 0; - this->credits = 100; + this->credits = 1000; // Add the background this->AddEntity(new GkGameAnimation(game->AcquireAnimatedTexture(L"Background.png"))); @@ -41,11 +41,11 @@ MainPage::MainPage(CustomGame *game) // Create the combinations generator. The combinations generator represents a model of collection of reels. Each of its reels can have a different model // The GkGameReelStripModel is a GkGameReelModel, representing a reel with a fixed sequence of finite number of items. Here, it is used for all the reels of the combination generator. this->combinationsGenerator = new GkGameReelsCombinationGenerator(5, 3); - this->combinationsGenerator->SetReelModel(0, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_Space, ReelItem_Cherry, ReelItem_Grape, ReelItem_Cherry, ReelItem_Lemon)); - this->combinationsGenerator->SetReelModel(1, new GkGameReelStripModel(3, 6, ReelItem_Grape, ReelItem_Lemon, ReelItem_Space, ReelItem_Lemon, ReelItem_Lemon, ReelItem_Cherry)); - this->combinationsGenerator->SetReelModel(2, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_7, ReelItem_Lemon, ReelItem_Cherry, ReelItem_7, ReelItem_Space)); - this->combinationsGenerator->SetReelModel(3, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_Bar1, ReelItem_Bar2, ReelItem_Space, ReelItem_Cherry, ReelItem_Grape)); - this->combinationsGenerator->SetReelModel(4, new GkGameReelStripModel(3, 6, ReelItem_Cherry, ReelItem_Space, ReelItem_Bar3, ReelItem_Cherry, ReelItem_Lemon, ReelItem_Grape)); + this->combinationsGenerator->SetReelModel(0, new GkGameReelStripModel(3, 15, 6, 6, 6, 2, 0, 4, 0, 1, 2, 2, 2, 0, 5, 7, 1)); + this->combinationsGenerator->SetReelModel(1, new GkGameReelStripModel(3, 15, 4, 2, 4, 0, 1, 4, 4, 7, 6, 6, 3, 7, 4, 3, 1)); + this->combinationsGenerator->SetReelModel(2, new GkGameReelStripModel(3, 15, 3, 0, 7, 6, 7, 3, 3, 2, 5, 5, 3, 4, 5, 5, 7)); + this->combinationsGenerator->SetReelModel(3, new GkGameReelStripModel(3, 15, 2, 3, 3, 3, 3, 4, 0, 7, 1, 7, 2, 2, 3, 2, 4)); + this->combinationsGenerator->SetReelModel(4, new GkGameReelStripModel(3, 15, 1, 1, 5, 6, 0, 0, 6, 0, 6, 6, 1, 1, 5, 3, 2)); // Create the visual object for the reels this->reels = (GkGameReels*)this->AddEntity(new GkGameReels(5, 3, 8, 670, 331)); @@ -54,9 +54,9 @@ MainPage::MainPage(CustomGame *game) this->reels->symbols[ReelItem_Grape ] = game->AcquireAnimatedTexture(L"symbol_grape.png"); this->reels->symbols[ReelItem_Lemon ] = game->AcquireAnimatedTexture(L"symbol_lemon.png"); this->reels->symbols[ReelItem_7 ] = game->AcquireAnimatedTexture(L"symbol_seven.png"); - this->reels->symbols[ReelItem_Bar1 ] = game->AcquireAnimatedTexture(L"symbol_bar1.png"); - this->reels->symbols[ReelItem_Bar2 ] = game->AcquireAnimatedTexture(L"symbol_bar2.png"); - this->reels->symbols[ReelItem_Bar3 ] = game->AcquireAnimatedTexture(L"symbol_bar3.png"); + this->reels->symbols[ReelItem_Bar1 ] = game->AcquireAnimatedTexture(L"symbol_1bar.png"); + this->reels->symbols[ReelItem_Bar2 ] = game->AcquireAnimatedTexture(L"symbol_2bar.png"); + this->reels->symbols[ReelItem_Bar3 ] = game->AcquireAnimatedTexture(L"symbol_3bar.png"); this->reels->x = 62; this->reels->y = 90; @@ -72,11 +72,11 @@ MainPage::MainPage(CustomGame *game) // The winnings model defines two things. One is the properties of the symbols - their coefficients and special behaviour. Second - the shape of the winning lines. this->winningsModel = new GkGameWinningsModel(5, 3, 5, 8, 0); - this->winningsModel->SetupSymbol(ReelItem_Space , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 0, 0, 0); - this->winningsModel->SetupSymbol(ReelItem_Cherry, 0, GkGameWinningsModel::SymbolFlag_Wild, GkGameWinningsModel::SymbolFlag_None, 0, 0, 10, 20, 80); - this->winningsModel->SetupSymbol(ReelItem_Grape , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 20, 40, 200); - this->winningsModel->SetupSymbol(ReelItem_Lemon , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 50, 100, 500); - this->winningsModel->SetupSymbol(ReelItem_7 , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_Wild, 0, 0, 1000, 10000, 100000); + this->winningsModel->SetupSymbol(ReelItem_Space , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_Wild, 0, 0, 0, 0, 0); + this->winningsModel->SetupSymbol(ReelItem_Cherry, 0, GkGameWinningsModel::SymbolFlag_Wild, GkGameWinningsModel::SymbolFlag_None, 0, 0, 10, 100, 1000); + this->winningsModel->SetupSymbol(ReelItem_Grape , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 10, 20, 30); + this->winningsModel->SetupSymbol(ReelItem_Lemon , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_None, 0, 0, 25, 50, 75); + this->winningsModel->SetupSymbol(ReelItem_7 , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_Wild, 0, 0, 100, 300, 500); this->winningsModel->SetupSymbol(ReelItem_Bar1 , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_Wild, 0, 0, 1000, 10000, 100000); this->winningsModel->SetupSymbol(ReelItem_Bar2 , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_Wild, 0, 0, 1000, 10000, 100000); this->winningsModel->SetupSymbol(ReelItem_Bar3 , 0, GkGameWinningsModel::SymbolFlag_Default, GkGameWinningsModel::SymbolFlag_Wild, 0, 0, 1000, 10000, 100000); @@ -92,7 +92,12 @@ MainPage::MainPage(CustomGame *game) this->sndReels = game->AcquireSoundSource(L"reels.wav"); this->sndReelStop = game->AcquireSoundSource(L"reel.wav"); this->sndBlip = game->AcquireSoundSource(L"start.wav"); + this->sndGameOver = game->AcquireSoundSource(L"gameover.wav"); + this->sndWinBig = game->AcquireSoundSource(L"wina.wav"); + this->sndWinSmall = game->AcquireSoundSource(L"winb.wav"); game->soundDevice->PlaySource(this->sndBlip); + + this->isPlayingReels = false; } @@ -110,19 +115,37 @@ void MainPage::Process(GkGame *game) // Start button - hide the lines, generate a random combination, set it to appear on the reels after spinning, analyze its winning and start the reels if (this->btnStart->IsClicked()) { - for (int lineIndex = 0; lineIndex < this->winningsModel->numLines; lineIndex++) - this->lineAnimations[lineIndex]->visible = false; + game->soundDevice->PlaySource(this->sndBlip); + if (this->credits <= 0) + { + HMODULE hMainMod = GetModuleHandle(0); + if (MessageBox(NULL, "You are out of credits! Would you like to borrow 1000 more?", "Out of credits!", MB_YESNO | MB_ICONHAND | MB_DEFBUTTON1) + == IDYES) + { + this->credits = 1000; + } + else + { + game->soundDevice->PlaySource(this->sndGameOver); + MessageBox(NULL, "You have run out of money", "Game Over", MB_OK | MB_ICONEXCLAMATION | MB_DEFBUTTON1); + } + } + if (this->credits > 0) + { - this->credits -= this->bet * this->lines; + for (int lineIndex = 0; lineIndex < this->winningsModel->numLines; lineIndex++) + this->lineAnimations[lineIndex]->visible = false; - this->combinationsGenerator->GenerateCombination(); - this->reels->SetItems(this->combinationsGenerator); - this->winningsAnalyzer->AnalyzeWinnings(this->combinationsGenerator); - this->winningsAnalyzer->MultiplyWinnings(this->bet); + this->credits -= this->bet * this->lines; - this->reels->Start(); + this->combinationsGenerator->GenerateCombination(); + this->reels->SetItems(this->combinationsGenerator); + this->winningsAnalyzer->AnalyzeWinnings(this->combinationsGenerator); + this->winningsAnalyzer->MultiplyWinnings(this->bet); - game->soundDevice->PlaySourceLooping(this->sndReels); + this->reels->Start(); + game->soundDevice->PlaySourceLooping(this->sndReels); + } } // Bet button - change the bet @@ -143,7 +166,7 @@ void MainPage::Process(GkGame *game) game->soundDevice->PlaySource(this->sndBlip); } - + } // Stop the spinning reels when the button is pressed @@ -156,13 +179,25 @@ void MainPage::Process(GkGame *game) // When reels' state HAS JUST CHANGED to Idle, then show any winning lines, if any, and update combination winning and credits if (this->reels->stateChange == Idle) { + game->soundDevice->PauseSource(this->sndReels); + for (int winIndex = 0; winIndex < this->winningsAnalyzer->winnings.count; winIndex++) this->lineAnimations[this->winningsAnalyzer->winnings.win[winIndex].lineIndex]->visible = true; this->winning = this->winningsAnalyzer->totalWinning; + if (winning > 0) + { + if (winning >= 1000) + { + game->soundDevice->PlaySource(this->sndWinBig); + } + else + { + game->soundDevice->PlaySource(this->sndWinSmall); + } + } this->credits += this->winning; - game->soundDevice->PauseSource(this->sndReels); } // Sound on every reel stop diff --git a/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h index 3e75de6..8c56f95 100644 --- a/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h +++ b/COM380/Project5/GambleKit/CustomGameLogic/Pages/MainPage.h @@ -31,7 +31,9 @@ public: int bet, lines, winning, credits; - GkSoundSource *sndReels, *sndReelStop, *sndBlip; + bool isPlayingReels; + + GkSoundSource *sndReels, *sndReelStop, *sndBlip, *sndGameOver, *sndWinBig, *sndWinSmall; MainPage(CustomGame *game); diff --git a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp index 78b7fc5..e4a51d4 100644 --- a/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp +++ b/COM380/Project5/GambleKit/Engine/OSSpecific/GkWindowsForm.cpp @@ -11,6 +11,7 @@ //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- #include "GkWindowsForm.h" +#include "../../resource.h" #include @@ -292,7 +293,7 @@ GkWindowsForm::GkWindowsForm(void) this->top = 0; this->width = 640; this->height = 480; - this->caption = "Amrit's COM 380 Slot Machine"; + this->caption = "Amrit's COM 380 Money Machine"; //this->windowMode = GkWindowsForm::WindowMode_Windowed; this->windowMode = GkWindowsForm::WindowMode_FullScreen; @@ -319,13 +320,15 @@ bool GkWindowsForm::RegisterWindowClass() //memfun = &GkWindowsForm::WndProc; //this->ex.lpfnWndProc = *((WNDPROC*) (&memfun)); + HMODULE hMainMod = GetModuleHandle(0); + this->windowClass.cbSize = sizeof(WNDCLASSEX); this->windowClass.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; this->windowClass.lpfnWndProc = (WNDPROC)GkWindowsForm::WndProc; this->windowClass.cbClsExtra = 0; this->windowClass.cbWndExtra = 0; this->windowClass.hInstance = this->applicationInstance; - this->windowClass.hIcon = LoadIcon(NULL, IDI_APPLICATION); + this->windowClass.hIcon = LoadIcon(hMainMod, MAKEINTRESOURCE(IDI_ICON1)); this->windowClass.hCursor = LoadCursor(NULL, IDC_ARROW); this->windowClass.hbrBackground = NULL; this->windowClass.lpszMenuName = NULL; @@ -337,7 +340,7 @@ bool GkWindowsForm::RegisterWindowClass() bool GkWindowsForm::CreateFormWindow() { - long wndStyle = this->windowMode == GkWindowsForm::WindowMode_FullScreen ? WS_POPUP | WS_CAPTION: WS_OVERLAPPEDWINDOW | WS_CAPTION; + long wndStyle = this->windowMode == GkWindowsForm::WindowMode_FullScreen ? WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME : WS_OVERLAPPEDWINDOW ^ WS_THICKFRAME; wndStyle |= WS_CLIPCHILDREN | WS_CLIPSIBLINGS; // Translate from client rect to window rect diff --git a/COM380/Project5/GambleKit/GambleKit.vcxproj b/COM380/Project5/GambleKit/GambleKit.vcxproj index 1349b21..b194988 100644 --- a/COM380/Project5/GambleKit/GambleKit.vcxproj +++ b/COM380/Project5/GambleKit/GambleKit.vcxproj @@ -183,6 +183,7 @@ + @@ -190,6 +191,13 @@ + + + + + + + diff --git a/COM380/Project5/GambleKit/GambleKit.vcxproj.filters b/COM380/Project5/GambleKit/GambleKit.vcxproj.filters index 81c7764..6c94c4b 100644 --- a/COM380/Project5/GambleKit/GambleKit.vcxproj.filters +++ b/COM380/Project5/GambleKit/GambleKit.vcxproj.filters @@ -339,6 +339,7 @@ Engine + @@ -346,4 +347,11 @@ + + + + + + + \ No newline at end of file diff --git a/COM380/Project5/GambleKit/Resource.rc b/COM380/Project5/GambleKit/Resource.rc new file mode 100644 index 0000000..f0b142f Binary files /dev/null and b/COM380/Project5/GambleKit/Resource.rc differ diff --git a/COM380/Project5/GambleKit/resource.h b/COM380/Project5/GambleKit/resource.h new file mode 100644 index 0000000..5394957 Binary files /dev/null and b/COM380/Project5/GambleKit/resource.h differ diff --git a/COM380/Project5/GameData/Background.png b/COM380/Project5/GameData/Background.png index bd0a252..e9b5743 100644 Binary files a/COM380/Project5/GameData/Background.png and b/COM380/Project5/GameData/Background.png differ diff --git a/COM380/Project5/GameData/Background.xcf b/COM380/Project5/GameData/Background.xcf new file mode 100644 index 0000000..0b80a28 Binary files /dev/null and b/COM380/Project5/GameData/Background.xcf differ diff --git a/COM380/Project5/GameData/Thumbs.db b/COM380/Project5/GameData/Thumbs.db index 2ad1074..0f0b80f 100644 Binary files a/COM380/Project5/GameData/Thumbs.db and b/COM380/Project5/GameData/Thumbs.db differ diff --git a/COM380/Project5/GameData/gameover.wav b/COM380/Project5/GameData/gameover.wav new file mode 100644 index 0000000..eadbe12 Binary files /dev/null and b/COM380/Project5/GameData/gameover.wav differ diff --git a/COM380/Project5/GameData/wina.wav b/COM380/Project5/GameData/wina.wav new file mode 100644 index 0000000..805afbb Binary files /dev/null and b/COM380/Project5/GameData/wina.wav differ diff --git a/COM380/Project5/GameData/winb.wav b/COM380/Project5/GameData/winb.wav new file mode 100644 index 0000000..8e0ab70 Binary files /dev/null and b/COM380/Project5/GameData/winb.wav differ diff --git a/COM380/Project5/Thumbs.db b/COM380/Project5/Thumbs.db new file mode 100644 index 0000000..ffdfc7f Binary files /dev/null and b/COM380/Project5/Thumbs.db differ diff --git a/COM380/Project5/application.ico b/COM380/Project5/application.ico new file mode 100644 index 0000000..176b647 Binary files /dev/null and b/COM380/Project5/application.ico differ diff --git a/COM380/Project5/money.ico b/COM380/Project5/money.ico new file mode 100644 index 0000000..0fa9eb9 Binary files /dev/null and b/COM380/Project5/money.ico differ