Skip to content

Commit

Permalink
quitting the game works as expected now
Browse files Browse the repository at this point in the history
  • Loading branch information
LindseyB committed Oct 24, 2010
1 parent 9880d3b commit 49c3649
Show file tree
Hide file tree
Showing 3 changed files with 45 additions and 24 deletions.
51 changes: 32 additions & 19 deletions AAR.d
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ SelectScreen selectS;
LevelScreen levelS;
SoundClip sc;

bool userquit = false;
bool playgame = true;
void main(){
selectS = new SelectScreen("levels.txt");
sc = new SoundClip("sounds/title.mp3");
Expand All @@ -40,27 +42,34 @@ void main(){
refresh();
logo.drawSprite();
refresh();

Thread.sleep(5);

keypad(win, true);

while(1){
keypad(win, true);
sc = new SoundClip("music/ID__Baobinga_-_10_-_Raise_Riddim.mp3");
sc.start();
//clear();
//refresh();
playgame = levelInput(selectS, win);
sc.stop();
if(!playgame){
break;
}

currentLevel = selectS._levels[selectS._selectedLevel];
levelS = new LevelScreen(currentLevel);

Shitz shitzShitty = new Shitz(levelS, win);
Thread inputThread = new Thread(&shitzShitty.callMyShit);
inputThread.start();

Thread.sleep(5);

AnimatedAsciiSprite narwhal = new AnimatedAsciiSprite("graphics/man-moonwalk.txt", win, true, true, 16, 9);
AsciiSprite light = new AsciiSprite("graphics/spotlight.txt", win, false, 0, 5);

sc = new SoundClip("music/ID__Baobinga_-_10_-_Raise_Riddim.mp3");
sc.start();
if(!levelInput(selectS, win)){endwin();}
sc.stop();

currentLevel = selectS._levels[selectS._selectedLevel];
levelS = new LevelScreen(currentLevel);

Shitz shitzShitty = new Shitz(levelS, win);
Thread inputThread = new Thread(&shitzShitty.callMyShit);
inputThread.start();
drawLevelScreen();

drawLevelScreen();
listenforkey = false;

}

endwin();
}
Expand All @@ -72,7 +81,7 @@ void drawLevelScreen() {
sc.start();

int count = 0;
while(levelS._playing){
while(levelS._playing && !userquit){
clear();
if(count%2 == 0){
levelS.draw(false);
Expand All @@ -86,4 +95,8 @@ void drawLevelScreen() {

sc.stop();

Thread.sleep(5);
clear();
refresh();

}
5 changes: 4 additions & 1 deletion input.d
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ import levelScreen;
import tango.core.Thread;
import types;
import tango.io.stream.TextFile;
import AAR;

bool listenforkey = true;

bool levelInput(SelectScreen screen, WINDOW* win){
int key;
Expand Down Expand Up @@ -55,7 +57,7 @@ class Shitz {
void levelInput(LevelScreen screen, WINDOW* win){
int key;

while((key = getch()) != ERR){
while((key = getch()) != ERR && listenforkey){
if(key == Key.UpArrow) {
screen._arrowSect._input |= 4;
screen._dancingMan.setCurAnimation(Animate.UP);
Expand All @@ -69,6 +71,7 @@ void levelInput(LevelScreen screen, WINDOW* win){
screen._arrowSect._input |= 2;
screen._dancingMan.setCurAnimation(Animate.RIGHT);
} else if (key == 'q') {
userquit = true;
// do nothing.
}

Expand Down
13 changes: 9 additions & 4 deletions levelScreen.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ class LevelScreen {
endGame(false);
}

if(_arrowSect.noMoreBeats){
endGame(true);
}

move(0,0);
_score.draw();
_warningBar.draw();
Expand All @@ -59,14 +63,15 @@ class LevelScreen {

void endGame(bool win) {
_playing = false;
AsciiSprite winText = new AsciiSprite("graphics/victory.txt", null, true, 15, 15);
AsciiSprite loseText = new AsciiSprite("graphics/failure.txt", null, true, 15, 15);


move(50,100);
if(win){
addstr(toStringz("You Win!"));
winText.drawSprite();
} else {
addstr(toStringz("You Lose!"));
loseText.drawSprite();
}

}

}

0 comments on commit 49c3649

Please sign in to comment.