-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Cong Le Ba
committed
Apr 26, 2018
1 parent
8ba006f
commit 6987d33
Showing
34 changed files
with
1,018 additions
and
574 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,54 @@ | ||
# depslib dependency file v1.0 | ||
1521101881 source:e:\workplace\cong\main.cpp | ||
1524555855 source:e:\workplace\cong\main.cpp | ||
<iostream> | ||
<cstdlib> | ||
<ctime> | ||
<cstring> | ||
<SDL.h> | ||
"graphics.h" | ||
"painter.h" | ||
"Window.h" | ||
"Painter.h" | ||
"Game.h" | ||
"SDL_mixer.h" | ||
|
||
1521101941 source:e:\workplace\cong\graphics.cpp | ||
1523591454 source:e:\workplace\cong\graphics.cpp | ||
"graphics.h" | ||
<iostream> | ||
|
||
1520474533 e:\workplace\cong\graphics.h | ||
1523274691 e:\workplace\cong\graphics.h | ||
<iostream> | ||
<SDL.h> | ||
|
||
1521101662 source:e:\workplace\cong\painter.cpp | ||
1524495293 source:e:\workplace\cong\painter.cpp | ||
<cmath> | ||
<cstdlib> | ||
<iostream> | ||
<SDL.h> | ||
<SDL_image.h> | ||
"painter.h" | ||
"Painter.h" | ||
|
||
1521096980 e:\workplace\cong\painter.h | ||
1524489429 e:\workplace\cong\painter.h | ||
<string> | ||
<SDL.h> | ||
<SDL_image.h> | ||
|
||
1524488751 e:\workplace\cong\window.h | ||
<iostream> | ||
<SDL.h> | ||
|
||
1524488478 source:e:\workplace\cong\window.cpp | ||
"Window.h" | ||
<iostream> | ||
|
||
1524643213 source:e:\workplace\cong\game.cpp | ||
<cstring> | ||
<cstdlib> | ||
<ctime> | ||
<SDL.h> | ||
<SDL_image.h> | ||
"Game.h" | ||
"Painter.h" | ||
<SDL_mixer.h> | ||
|
||
1524494135 e:\workplace\cong\game.h | ||
<SDL.h> | ||
<SDL_image.h> | ||
"Painter.h" | ||
"Window.h" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,39 @@ | ||
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> | ||
<CodeBlocks_layout_file> | ||
<ActiveTarget name="Debug" /> | ||
<File name="painter.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="8" zoom_2="0"> | ||
<File name="Painter.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="8" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="780" topLine="24" /> | ||
<Cursor1 position="873" topLine="29" /> | ||
</Cursor> | ||
</File> | ||
<File name="painter.cpp" open="1" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="10" zoom_2="0"> | ||
<File name="Window.cpp" open="1" top="0" tabpos="4" split="0" active="1" splitpos="0" zoom_1="9" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="153" topLine="9" /> | ||
<Cursor1 position="2078" topLine="45" /> | ||
</Cursor> | ||
</File> | ||
<File name="graphics.cpp" open="0" top="0" tabpos="5" split="0" active="1" splitpos="0" zoom_1="13" zoom_2="0"> | ||
<File name="Painter.cpp" open="0" top="0" tabpos="2" split="0" active="1" splitpos="0" zoom_1="7" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="1984" topLine="56" /> | ||
<Cursor1 position="101" topLine="93" /> | ||
</Cursor> | ||
</File> | ||
<File name="graphics.h" open="0" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="10" zoom_2="0"> | ||
<File name="Game.h" open="1" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="13" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="583" topLine="0" /> | ||
<Cursor1 position="89" topLine="0" /> | ||
</Cursor> | ||
</File> | ||
<File name="main.cpp" open="1" top="1" tabpos="1" split="0" active="1" splitpos="0" zoom_1="10" zoom_2="0"> | ||
<File name="Window.h" open="0" top="0" tabpos="3" split="0" active="1" splitpos="0" zoom_1="10" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="1517" topLine="54" /> | ||
<Cursor1 position="290" topLine="3" /> | ||
</Cursor> | ||
</File> | ||
<File name="Game.cpp" open="1" top="1" tabpos="2" split="0" active="1" splitpos="0" zoom_1="13" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="1033" topLine="82" /> | ||
</Cursor> | ||
</File> | ||
<File name="main.cpp" open="1" top="0" tabpos="1" split="0" active="1" splitpos="0" zoom_1="10" zoom_2="0"> | ||
<Cursor> | ||
<Cursor1 position="698" topLine="25" /> | ||
</Cursor> | ||
</File> | ||
</CodeBlocks_layout_file> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
#include <cstring> | ||
#include <cstdlib> | ||
#include <ctime> | ||
#include <SDL.h> | ||
#include <SDL_image.h> | ||
#include "Game.h" | ||
#include "Painter.h" | ||
#include <SDL_mixer.h> | ||
|
||
using namespace std; | ||
|
||
Game::Game( SDL_Window* window, SDL_Renderer* renderer, Window& canvas, Painter& painter ) { | ||
srand(time(NULL)); | ||
|
||
// Sence1 and Sence2's sound | ||
Mix_Chunk* sence2 = NULL; | ||
sence2 = Mix_LoadWAV( "sound/sence2.ogx" ); | ||
if (sence2 == NULL) | ||
{ | ||
cout << Mix_GetError(); | ||
} | ||
if( Mix_PlayChannel( -1, sence2, -1 ) == -1 ) | ||
{ | ||
return; | ||
} | ||
|
||
// Sence1 here | ||
painter.showSence1(); | ||
if (canvas.havePressed()) cout << "Click on sence 1"<<endl; else canvas.quitSDL(window, renderer); | ||
|
||
// Sence2 here | ||
painter.showSence2(); | ||
if (canvas.havePressed()) cout << "Click on sence 2"<<endl; else canvas.quitSDL(window, renderer); | ||
|
||
Mix_Pause( -1 ); | ||
Mix_Chunk* music = NULL , *winsound = NULL , *losssound = NULL ; | ||
music = Mix_LoadWAV( "sound/show.wav" ); | ||
winsound = Mix_LoadWAV( "sound/win.wav" ); | ||
losssound = Mix_LoadWAV( "sound/loss.mp3" ); | ||
if (music == NULL || winsound == NULL || losssound == NULL) | ||
{ | ||
cout << Mix_GetError(); | ||
} | ||
// Slideshow here | ||
bool visit[22]; | ||
for (int level=1; level<=5; level++) { | ||
memset(visit,0,sizeof(visit)); | ||
int res = -1; | ||
for (int i=1; i<=12; i++) { | ||
int image_index = rand() % 15 + 1; | ||
//int image_index = rand() % 15 + 1; | ||
int image_dir = 1; | ||
painter.showImage(image_dir, image_index); | ||
if( Mix_PlayChannel( -1, music, 0 ) == -1 ) | ||
{ | ||
return; | ||
} | ||
canvas.haveClick(visit , image_index, res); | ||
if (res!=-1) { | ||
if (res) | ||
{ | ||
if( Mix_PlayChannel( -1, winsound, 0 ) == -1 ) | ||
{ | ||
return; | ||
} | ||
} | ||
else | ||
{ | ||
if( Mix_PlayChannel( -1, losssound, 0 ) == -1 ) | ||
{ | ||
return; | ||
} | ||
} | ||
painter.showResult(res); | ||
if (canvas.havePressed()) cout << "Click on sence 3"<<endl; else canvas.quitSDL(window, renderer); | ||
break; | ||
} | ||
else | ||
if (visit[image_index]) { | ||
res = 0; | ||
if( Mix_PlayChannel( -1, losssound, 0 ) == -1 ) | ||
{ | ||
return; | ||
} | ||
painter.showResult(res); | ||
if (canvas.havePressed()) cout << "Click on sence 3"<<endl; else canvas.quitSDL(window, renderer); | ||
break; | ||
} | ||
else visit[image_index] = 1; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#ifndef GAME_H_INCLUDED | ||
#define GAME_H_INCLUDED | ||
#include <SDL.h> | ||
#include <SDL_image.h> | ||
#include "Painter.h" | ||
#include "Window.h" | ||
|
||
class Game | ||
{ | ||
public: | ||
Game( SDL_Window* window, SDL_Renderer* renderer, Window& canvas, Painter& painter ); | ||
|
||
}; | ||
#endif // GAME_H_INCLUDED |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.