Skip to content

Commit

Permalink
winning now has scores
Browse files Browse the repository at this point in the history
  • Loading branch information
LindseyB committed Oct 24, 2010
1 parent e32871d commit e6e4a18
Showing 1 changed file with 25 additions and 3 deletions.
28 changes: 25 additions & 3 deletions levelScreen.d
Expand Up @@ -62,20 +62,28 @@ class LevelScreen {
_dancingMan.animate();
_backup1.animate();
_backup2.animate();

}

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

double grade;

if (_arrowSect.great + _arrowSect.good + _arrowSect.actualMisses != 0){
grade = 50 * ((_arrowSect.great*2 + _arrowSect.good)/(_arrowSect.great + _arrowSect.good + _arrowSect.actualMisses));
} else {
grade = 0;
}

AsciiSprite gradeSprite = new AsciiSprite("graphics/" ~ getLetterGrade(grade) ~ ".txt", null, false, 73, 20);

if(win){
sc = new SoundClip("sounds/win.mp3");
sc.start();
winText.drawSprite();

gradeSprite.drawSprite();
AnimatedAsciiSprite popcorn = new AnimatedAsciiSprite("graphics/cron-popcron.txt", null, false, false, 20, 20);

for(int i=0; i<popcorn._animation.length; i++){
Expand All @@ -93,4 +101,18 @@ class LevelScreen {

}

char getLetterGrade(double percent){
if(percent > 90.0) {
return 'A';
} else if(percent > 80.0) {
return 'B';
} else if(percent > 70.0) {
return 'C';
} else if(percent > 60.0) {
return 'D';
} else {
return 'F';
}
}

}

0 comments on commit e6e4a18

Please sign in to comment.