Permalink
Browse files

fixed whale drawing issues

  • Loading branch information...
1 parent 8110ce4 commit 84e5ca5009c3a16cc8ae5179ba3e3ff2e3bf4d84 @LindseyB LindseyB committed Oct 24, 2010
Showing with 51 additions and 43 deletions.
  1. +8 −3 AAR.d
  2. +5 −4 animatedAsciiSprite.d
  3. +33 −33 arrowSection.d
  4. +1 −0 dancingMan.d
  5. +4 −3 levelScreen.d
View
11 AAR.d
@@ -71,12 +71,17 @@ void drawLevelScreen() {
sc = new SoundClip("music/" ~ currentLevel._audio);
sc.start();
+ int count = 0;
while(levelS._playing){
clear();
- levelS.draw();
- //Thread.sleep(0.05);
- Thread.sleep(levelS._arrowSect.sleep);
+ if(count%5 == 0){
+ levelS.draw(false);
+ } else {
+ levelS.draw(true);
+ }
refresh();
+ Thread.sleep(levelS._arrowSect.sleep/5.0);
+ count++;
}
sc.stop();
View
@@ -12,14 +12,15 @@ class AnimatedAsciiSprite : AsciiSprite {
bool _loop;
bool _animate;
- this(char[] filePath, WINDOW* win, bool transparent = false, bool loop = false, int x=0, int y=0){
+ this(char[] filePath, WINDOW* win, bool transparent, bool loop, int x=0, int y=0){
_frame = 0;
auto _spriteFile = new TextFileInput(filePath);
super._x = x;
super._y = y;
super._win = win;
super._transparent = transparent;
_animate = true;
+ _loop = loop;
bool firstLine = true;
char[][] newFrame;
@@ -49,10 +50,10 @@ class AnimatedAsciiSprite : AsciiSprite {
void nextFrame() {
if(_animate){
- int before = _frame++;
+ int before = ++_frame;
_frame %= _animation.length;
-
- if(before == _animation.length && _frame == 0){
+
+ if(!_loop && before == _animation.length && _frame == 0){
_animate = false;
}
View
@@ -44,47 +44,47 @@ class ArrowSection {
}
}
- void draw() {
+ void draw(bool fast) {
_frame.drawSprite();
// draw arrows and shit
hit.drawSprite();
-
- if(offset == 0){
- // parse shite frum file, appendto arrows and drop top if required
- Beat* beat = new Beat;
-
- char[] line = chartFile.next;
-
- foreach(ch; line){
- switch(ch){
- case 'l': beat.arrows |= 1; break;
- case 'r': beat.arrows |= 2; break;
- case 'u': beat.arrows |= 4; break;
- case 'd': beat.arrows |= 8; break;
- case 'x': break;
+ if(!fast){
+ if(offset == 0){
+ // parse shite frum file, appendto arrows and drop top if required
+ Beat* beat = new Beat;
+
+ char[] line = chartFile.next;
+
+ foreach(ch; line){
+ switch(ch){
+ case 'l': beat.arrows |= 1; break;
+ case 'r': beat.arrows |= 2; break;
+ case 'u': beat.arrows |= 4; break;
+ case 'd': beat.arrows |= 8; break;
+ case 'x': break;
+ }
+ }
+
+ //beat.arrows = randomArrows();
+ //beat.period = .1;
+
+ beats ~= beat;
+
+ if(beats.length > beatsOnScreen){
+ beats = beats[1..$];
+ }
+
+ /*if(beats[0].period != 0){
+ sleep = beats[0].period;
+ }*/
}
- }
-
- //beat.arrows = randomArrows();
- //beat.period = .1;
- beats ~= beat;
-
- if(beats.length > beatsOnScreen){
- beats = beats[1..$];
- }
-
- /*if(beats[0].period != 0){
- sleep = beats[0].period;
- }*/
+ offset--;
+ if(offset < 0){offset = 4;}
}
- offset--;
- if(offset < 0){offset = 4;}
-
-
// Draw
for(int i = 0; i < beats.length; i++){
@@ -131,4 +131,4 @@ private:
struct Beat{
ubyte arrows; //lrud
double period;
-}
+}
View
@@ -22,6 +22,7 @@ class DancingMan {
void setCurAnimation(Animate animation) {
_curAnimation = animation;
+ _animations[_curAnimation]._animate = true;
}
void animate() {
View
@@ -28,13 +28,14 @@ class LevelScreen {
_narwhal = new Narwhal();
}
- void draw() {
+ void draw(bool fast) {
move(0,0);
_score.draw();
_spotlight.drawSprite();
- _arrowSect.draw();
+ _arrowSect.draw(fast);
_dancingMan.draw();
_narwhal.animate();
_dancingMan.animate();
- }
+ }
+
}

0 comments on commit 84e5ca5

Please sign in to comment.