Skip to content

Commit

Permalink
Finished, done working.
Browse files Browse the repository at this point in the history
Everything's just fantastic.
  • Loading branch information
AoutoCooper committed Oct 7, 2022
1 parent 55caafd commit 5952fa9
Show file tree
Hide file tree
Showing 9 changed files with 196 additions and 40 deletions.
Binary file modified Debug/ScreamingMan.ilk
Binary file not shown.
1 change: 1 addition & 0 deletions Debug/ScreamingMan.log
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
 Main.cpp
Q:\Projects\ScreamingMan\ScreamingMan\ScreamingMan\Main.cpp(64,39): warning C4305: 'initializing': truncation from 'double' to 'float'
ScreamingMan.vcxproj -> Q:\Projects\ScreamingMan\ScreamingMan\Debug\ScreamingMan.exe
Binary file modified Debug/ScreamingMan.tlog/link.read.1.tlog
Binary file not shown.
Binary file modified Debug/main.obj.enc
Binary file not shown.
Binary file modified Debug/vc143.idb
Binary file not shown.
Binary file modified Debug/vc143.pdb
Binary file not shown.
235 changes: 195 additions & 40 deletions Main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,41 @@ SDL_Window* window = nullptr;
SDL_Renderer* renderer = nullptr;


//texture
//textures

SDL_Texture* moonSmug = nullptr;
SDL_Texture* normalFace = nullptr;
SDL_Texture* initSurprised = nullptr;
SDL_Texture* realiaiztion = nullptr;
SDL_Texture* sadOpenEyes = nullptr;
SDL_Texture* sadTalking = nullptr;
SDL_Texture* sadSqueentTalking = nullptr;
SDL_Texture* justSad = nullptr;
SDL_Texture* talkingHappy = nullptr;

SDL_Texture* moonScared = nullptr;

Mix_Music* guitarFX = nullptr;
Mix_Music* currentFX = nullptr;

Timer* mTimer = nullptr;

bool held = false;
bool normal = true;
bool bInitSurprised = false;
bool realizing = false;
bool sadOpenEyes = false;
bool sadTalking = false;
bool sadSqueentTalking = false;
bool justSad = false;
bool bSadOpenEyes = false;
bool bSadTalking = false;
bool bSadSqueentTalking = false;
bool bJustSad = false;
bool bTalkingHappy = false;
bool playedGuitar = false;
bool talkedHappily = false;


float currentTime{ 0.0 };
float timeToBeSad{ 2.0 };
float timeToBeNormal{ 2.0 };
float timeToBeTalkingHappy{ 6.0 };
float timeToBeInitSurprised{ 5.0 };
float timeToBeSadOpenEyes{ 3.0 };
float timeToBeSadTalking{ 2.5 };
float timeToBeSadSqueentTalking{ 3.95 };

int main(int argc, char* args[]) {

Expand All @@ -55,18 +70,53 @@ int main(int argc, char* args[]) {
return -1;
}

moonSmug = LoadTexture("images/normal.png");
if (moonSmug == NULL) {
normalFace = LoadTexture("images/normal.png");
if (normalFace == NULL) {
printf("Couldn't load image.");
return -1;
}
talkingHappy = LoadTexture("images/talkingHappy.png");
if (talkingHappy == NULL) {
printf("Couldn't load image.");
return -1;
}

sadTalking = LoadTexture("images/sadTalking.png");
if (sadTalking == NULL) {
printf("Couldn't load image.");
return -1;
}
sadSqueentTalking = LoadTexture("images/sadSqueentTalking.png");
if (sadSqueentTalking == NULL) {
printf("Couldn't load image.");
return -1;
}

initSurprised = LoadTexture("images/initSurprise.png");
if (initSurprised == NULL) {
printf("Couldn't load image.");
return -1;
}

realiaiztion = LoadTexture("images/realization.png");
if (realiaiztion == NULL) {
printf("Couldn't load image.");
return -1;
}

sadOpenEyes = LoadTexture("images/sadOpenEyes.png");
if (sadOpenEyes == NULL) {
printf("Couldn't load image.");
return -1;
}

moonScared = LoadTexture("images/initSurprise.png");
if (moonSmug == NULL) {
justSad = LoadTexture("images/justSad.png");
if (justSad == NULL) {
printf("Couldn't load image.");
return -1;
}


MakeWindowTransparent(window, RGB(0, 255, 0));

bool exit = false;
Expand All @@ -91,14 +141,20 @@ int main(int argc, char* args[]) {
}

if (e.type == SDL_MOUSEBUTTONDOWN) {
normal = false;
if (!bInitSurprised) {
bInitSurprised = true;
}
//then realization
mouseButtonHeld = true;
}

if (e.type == SDL_MOUSEBUTTONUP) {
mouseButtonHeld = false;
held = true;
//wait for finished something, then play audio
PlayAudio("sound/sadGuitar.wav");
realizing = false;
if (!bSadOpenEyes) {
bSadOpenEyes = true;
}
}

if (mouseButtonHeld) {
Expand All @@ -125,6 +181,8 @@ int main(int argc, char* args[]) {

bool Initialize() {

currentTime = 0;

if (SDL_Init(SDL_INIT_VIDEO) < 0) {
printf("SDL could not be initialized. SDL_Error: %s\n", SDL_GetError());
return false;
Expand Down Expand Up @@ -157,18 +215,100 @@ bool Initialize() {
}

void FixedUpdate() {
if (held) {
SDL_RenderCopy(renderer, moonScared, NULL, NULL);

//cout << "init surprised: " << bInitSurprised << endl;
//cout << "realizing: " << realizing << endl;
//cout << "normal: " << normal << endl;
if (normal) {
SDL_RenderCopy(renderer, normalFace, NULL, NULL);
currentTime += mTimer->GetDeltaTime();

if (currentTime >= timeToBeSad) {
held = false;
if (!talkedHappily) {
if (currentTime >= timeToBeNormal) {
normal = false;
currentTime = 0;
bTalkingHappy = true;
}
}

}

if (bTalkingHappy) {
SDL_RenderCopy(renderer, talkingHappy, NULL, NULL);
currentTime += mTimer->GetDeltaTime();
PlayAudio("sound/happy.wav");

if (currentTime >= timeToBeTalkingHappy) {
bTalkingHappy = false;
currentTime = 0;
talkedHappily = true;
normal = true;
}
}
else {
SDL_RenderCopy(renderer, moonSmug, NULL, NULL);

if (bInitSurprised) {
SDL_RenderCopy(renderer, initSurprised, NULL, NULL);
currentTime += mTimer->GetDeltaTime();

if (currentTime >= timeToBeInitSurprised) {
bInitSurprised = false;
currentTime = 0;
realizing = true;
}
}

if (realizing) {
SDL_RenderCopy(renderer, realiaiztion, NULL, NULL);
currentTime = 0;
//this stays like this until mouse gets held up
}


if (bSadOpenEyes) {
SDL_RenderCopy(renderer, sadOpenEyes, NULL, NULL);

currentTime += mTimer->GetDeltaTime();
if (currentTime >= timeToBeSadOpenEyes) {
bSadOpenEyes = false;
currentTime = 0;
bSadTalking = true;
PlayAudio("sound/sad.wav");
//start audio talking
}
}
if (bSadTalking) {
SDL_RenderCopy(renderer, sadTalking, NULL, NULL);

currentTime += mTimer->GetDeltaTime();
if (currentTime >= timeToBeSadTalking) {
bSadTalking = false;
currentTime = 0;
bSadSqueentTalking = true;
//start audio talking
}

}
if (bSadSqueentTalking) {
SDL_RenderCopy(renderer, sadSqueentTalking, NULL, NULL);
currentTime += mTimer->GetDeltaTime();

if (currentTime >= timeToBeSadSqueentTalking) {
bSadSqueentTalking = false;
currentTime = 0;
bJustSad = true;
}

}
if (bJustSad) {
SDL_RenderCopy(renderer, justSad, NULL, NULL);

if (!playedGuitar) {
PlayAudio("sound/sadGuitar.wav");
playedGuitar = true;
}
}


//show the final render
SDL_RenderPresent(renderer);

Expand Down Expand Up @@ -208,21 +348,35 @@ bool InitWindow() {
}

void Close() {

SDL_DestroyWindow(window);
SDL_DestroyTexture(moonScared);
SDL_DestroyTexture(moonSmug);
SDL_DestroyTexture(initSurprised);
SDL_DestroyTexture(realiaiztion);
SDL_DestroyTexture(normalFace);
SDL_DestroyTexture(sadTalking);
SDL_DestroyTexture(sadOpenEyes);
SDL_DestroyTexture(sadSqueentTalking);
SDL_DestroyTexture(justSad);
SDL_DestroyTexture(talkingHappy);
SDL_DestroyRenderer(renderer);

Mix_FreeMusic(guitarFX);

window = nullptr;
renderer = nullptr;
moonSmug = nullptr;
moonScared = nullptr;
mTimer = nullptr;
window = nullptr;
normalFace = nullptr;
talkingHappy = nullptr;
initSurprised = nullptr;
realiaiztion = nullptr;
sadOpenEyes = nullptr;
sadTalking = nullptr;
sadSqueentTalking = nullptr;
justSad = nullptr;


Mix_FreeMusic(currentFX);

guitarFX = nullptr;
currentFX = nullptr;

mTimer = nullptr;

Mix_Quit();

Expand Down Expand Up @@ -252,6 +406,14 @@ SDL_Texture* LoadTexture(std::string file) {
return newTexture;
}

void PlayAudio(std::string file) {

if (!Mix_PlayingMusic()) {
currentFX = Mix_LoadMUS(file.c_str());
Mix_PlayMusic(currentFX, 0);
}
}

bool MakeWindowTransparent(SDL_Window* window, COLORREF colorKey) {
// Get window handle (https://stackoverflow.com/a/24118145/3357935)
SDL_SysWMinfo wmInfo;
Expand All @@ -266,10 +428,3 @@ bool MakeWindowTransparent(SDL_Window* window, COLORREF colorKey) {
return SetLayeredWindowAttributes(hWnd, colorKey, 0, LWA_COLORKEY);
}

void PlayAudio(std::string file) {

if (!Mix_PlayingMusic()) {
guitarFX = Mix_LoadMUS(file.c_str());
Mix_PlayMusic(guitarFX, 0);
}
}
Binary file added sound/happy.wav
Binary file not shown.
Binary file added sound/sad.wav
Binary file not shown.

0 comments on commit 5952fa9

Please sign in to comment.