Skip to content
Browse files

winning now has scores

  • Loading branch information...
1 parent e32871d commit e6e4a18e12d52092e42c7a7b3182167e95fe7919 @LindseyB LindseyB committed Oct 24, 2010
Showing with 25 additions and 3 deletions.
  1. +25 −3 levelScreen.d
View
28 levelScreen.d
@@ -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++){
@@ -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.
Something went wrong with that request. Please try again.