YenningComity
Still Fresh
- Joined
- Sep 19, 2005
- Messages
- 12
I have been fooling around with the following piece of code, but am failing to get it to exit a simple loop. I know my input works correctly because I can reassign quit to any input, and it works flawlessly. However, I am unable to increment credits.
CODE
include "input.h"
void attractInput(bool& quit, int& credits, bool& start, SDL_Event& event){
while(SDL_PollEvent(&event)){
//If a key was pressed
if(event.type == SDL_KEYDOWN){
switch(event.key.keysym.sym){
case SDLK_ESCAPE: quit = true;
break;
case SDLK_1: credits += 1;
break;
case SDLK_RETURN: start = true;
break;
}
}
}
}
CODE
void attractOn(bool& quit, int& credits){
SDL_Event event;
//Is True when Player Hits Start Button
bool checkForStart = false;
string backgroundFile = "attractTest.png";
//Load The Background
if(loadBackground(backgroundFile)==false){
return;
}//if(swapBuffers()==false)
while (quit == false){
//Get Player Input
attractInput(quit, credits, checkForStart, event);
//Check Starting Conditions
if(checkForStart == true){
if(credits > 0){
credits -= 1;
//Clear Images
cleanUp();
return;
}
}
//Clear Images
cleanUp();
return;
}//void attractMode()
CODE
include "input.h"
void attractInput(bool& quit, int& credits, bool& start, SDL_Event& event){
while(SDL_PollEvent(&event)){
//If a key was pressed
if(event.type == SDL_KEYDOWN){
switch(event.key.keysym.sym){
case SDLK_ESCAPE: quit = true;
break;
case SDLK_1: credits += 1;
break;
case SDLK_RETURN: start = true;
break;
}
}
}
}
CODE
void attractOn(bool& quit, int& credits){
SDL_Event event;
//Is True when Player Hits Start Button
bool checkForStart = false;
string backgroundFile = "attractTest.png";
//Load The Background
if(loadBackground(backgroundFile)==false){
return;
}//if(swapBuffers()==false)
while (quit == false){
//Get Player Input
attractInput(quit, credits, checkForStart, event);
//Check Starting Conditions
if(checkForStart == true){
if(credits > 0){
credits -= 1;
//Clear Images
cleanUp();
return;
}
}
//Clear Images
cleanUp();
return;
}//void attractMode()