diff --git a/AAR.d b/AAR.d index b552e17..a77039a 100644 --- a/AAR.d +++ b/AAR.d @@ -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"); @@ -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(); } @@ -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); @@ -85,5 +94,11 @@ void drawLevelScreen() { } sc.stop(); + + if(!userquit){ + Thread.sleep(5); + } + clear(); + refresh(); } diff --git a/arrowSection.d b/arrowSection.d index 34d8c5f..aeb0660 100644 --- a/arrowSection.d +++ b/arrowSection.d @@ -1,5 +1,7 @@ module arrowSection; +import ldc.intrinsics; + import tango.stdc.stringz; import ncurses; import tango.io.Stdout; @@ -31,14 +33,16 @@ class ArrowSection { this(char[] arrowFile) { chartFile = new TextFileInput("arrow_charts/" ~ arrowFile); + if(chartFile is null){ assert(false);_exit(1);} + auto bpm = chartFile.next; - if(bpm[0..4] == "BPM:"){ - sleep = 60.0 / to!(double)(bpm[4..$]); - }else{ + //if(bpm[0..4] == "BPM:"){ + sleep = 60.0 / to!(double)(bpm); + /*}else{ assert(false, "BAD arrowchart!"); _exit(1); - } + }*/ // burn the second line -- how long the song is bpm = chartFile.next; @@ -64,8 +68,28 @@ class ArrowSection { if(!fast){ // XXX: atomic swap on _input - ubyte diff, cacheInput = _input; - _input = 0; + ubyte diff, cacheInput;// = _input; + //_input = 0; + + cacheInput = llvm_atomic_swap!(ubyte)(&_input, 0); + + //cacheInput = _input; + //_input = 0; + /* + asm{ + push EDX; + push ECX; + + mov EDX, 0; + mov ECX, input; + lock; + xchg [ECX], EDX; + mov ECX, cacheInput; + mov [ECX], EDX; + + pop ECX; + pop EDX; + }*/ if(offset > 1){ //beats[0] arrows - inputs @@ -80,7 +104,7 @@ class ArrowSection { beats[0].inputs |= diff; } - if(offset > 3){ + if(offset < 3){ // _input - diff ==> inputs that counted above don't count twice ubyte diff2 = cacheInput & (~diff); @@ -119,11 +143,11 @@ class ArrowSection { if(beats.length > beatsOnScreen){ // score Misses on dis - misses = beats[0].arrows & (~beats[0].inputs); + ubyte temp = beats[0].arrows & (~beats[0].inputs); - misses += lut[misses]; + misses += lut[temp]; - if(beat[0].end){noMoreBeats = true;} + if(beats[0].end){noMoreBeats = true;} beats = beats[1..$]; } diff --git a/arrow_charts/anamanaguchi_flora_fauna.txt b/arrow_charts/anamanaguchi_flora_fauna.txt index fb0f006..b8a0569 100644 --- a/arrow_charts/anamanaguchi_flora_fauna.txt +++ b/arrow_charts/anamanaguchi_flora_fauna.txt @@ -1,4 +1,4 @@ -BPM: 75 +75 diff --git a/arrow_charts/random.txt b/arrow_charts/random.txt index fa929d2..e351416 100644 --- a/arrow_charts/random.txt +++ b/arrow_charts/random.txt @@ -1,4 +1,4 @@ -BPM: 150 +150 x diff --git a/input.d b/input.d index 48bbcc2..ffadfb2 100644 --- a/input.d +++ b/input.d @@ -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; @@ -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); @@ -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. } diff --git a/levelScreen.d b/levelScreen.d index b5cd5f1..0e44251 100644 --- a/levelScreen.d +++ b/levelScreen.d @@ -41,6 +41,14 @@ class LevelScreen { _score.setScore((-50*_arrowSect.misses) + (100*_arrowSect.good) + (200*_arrowSect.great)); _warningBar.updateWarningBar(_arrowSect.misses, (_arrowSect.good + _arrowSect.great)); + if(_warningBar._level >= 32){ + endGame(false); + } + + if(_arrowSect.noMoreBeats){ + endGame(true); + } + move(0,0); _score.draw(); _warningBar.draw(); @@ -53,4 +61,17 @@ class LevelScreen { _backup2.animate(); } + void endGame(bool win) { + _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){ + winText.drawSprite(); + } else { + loseText.drawSprite(); + } + + } + } diff --git a/levels.txt b/levels.txt index cf0cee0..cdc7b8b 100644 --- a/levels.txt +++ b/levels.txt @@ -1,20 +1,20 @@ Anamanaguchi_-_02_-_Helix_Nebula.mp3 Helix Nebula by Anamanaguchi -5 -random.txt +9 +helix_nebula-random.txt Anamanaguchi_-_03_-_Airbase.mp3 Airbase by Anamanaguchi 5 -anamanaguchi_flora_fauna.txt +airbase-random.txt Anamanaguchi_-_04_-_Video_Challenge.mp3 Video Challenge by Anamanaguchi 5 -anamanaguchi_flora_fauna.txt +video_challenge-random.txt Anamanaguchi_-_06_-_FloraFauna.mp3 FloraFauna -5 -anamanaguchi_flora_fauna.txt +3 +flora_fauna-random.txt Anamanaguchi_-_07_-_Power_Supply.mp3 Power Supply -5 -anamanaguchi_flora_fauna.txt +7 +power_supply-random.txt diff --git a/warningBar.d b/warningBar.d index 3b66855..7fd9ff9 100644 --- a/warningBar.d +++ b/warningBar.d @@ -20,11 +20,11 @@ class WarningBar { } void draw() { - move(0,120); + move(0,105); for(int i=0; i<_level; i++){ addstr(toStringz("---")); - move(i,120); + move(i,105); } } }