forked from LindseyB/AsciiAsciiRevolution
-
Notifications
You must be signed in to change notification settings - Fork 0
/
levelScreen.d
83 lines (70 loc) · 1.84 KB
/
levelScreen.d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
module levelScreen;
import tango.stdc.stringz;
import ncurses;
import tango.io.Stdout;
import level;
import dataScore;
import arrowSection;
import dancingMan;
import asciiSprite;
import narwhal;
import backupDancer;
import warningBar;
import util.soundclip;
class LevelScreen {
DataScore _score;
ArrowSection _arrowSect;
DancingMan _dancingMan;
AsciiSprite _spotlight;
Narwhal _narwhal;
BackupDancer _backup1;
BackupDancer _backup2;
WarningBar _warningBar;
bool _playing;
this(Level currentLevel) {
_score = new DataScore(currentLevel._name);
_arrowSect = new ArrowSection(currentLevel._arrowChart);
_dancingMan = new DancingMan();
_backup1 = new BackupDancer(20, 20);
_backup2 = new BackupDancer(32, 20);
_playing = true;
_spotlight = new AsciiSprite("graphics/spotlight.txt", null, false, 10, 18);
_narwhal = new Narwhal();
_warningBar = new WarningBar();
}
void draw(bool fast) {
_score.setScore((-50*_arrowSect.misses) + (100*_arrowSect.good) + (200*_arrowSect.great));
_warningBar.updateWarningBar(_arrowSect.misses, _arrowSect.great);
if(_warningBar._level >= 32 && _arrowSect.misses > 5){
endGame(false);
}
if(_arrowSect.noMoreBeats){
endGame(true);
}
move(0,0);
_score.draw();
_warningBar.draw();
_spotlight.drawSprite();
_arrowSect.draw(fast);
_dancingMan.draw();
_narwhal.animate();
_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);
if(win){
sc = new SoundClip("sounds/win.mp3");
sc.start();
winText.drawSprite();
} else {
sc = new SoundClip("sounds/fail.mp3");
sc.start();
loseText.drawSprite();
}
}
}