Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
Jackie Kircher committed Oct 24, 2010
2 parents d8c5fa7 + fa74199 commit cbf8bed
Show file tree
Hide file tree
Showing 8 changed files with 105 additions and 42 deletions.
53 changes: 34 additions & 19 deletions AAR.d
Expand Up @@ -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");
Expand All @@ -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();
}
Expand All @@ -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);
Expand All @@ -85,5 +94,11 @@ void drawLevelScreen() {
}

sc.stop();

if(!userquit){
Thread.sleep(5);
}
clear();
refresh();

}
44 changes: 34 additions & 10 deletions arrowSection.d
@@ -1,5 +1,7 @@
module arrowSection;

import ldc.intrinsics;

import tango.stdc.stringz;
import ncurses;
import tango.io.Stdout;
Expand Down Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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);

Expand Down Expand Up @@ -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..$];
}
Expand Down
2 changes: 1 addition & 1 deletion arrow_charts/anamanaguchi_flora_fauna.txt
@@ -1,4 +1,4 @@
BPM: 75
75



Expand Down
2 changes: 1 addition & 1 deletion arrow_charts/random.txt
@@ -1,4 +1,4 @@
BPM: 150
150


x
Expand Down
5 changes: 4 additions & 1 deletion input.d
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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.
}

Expand Down
21 changes: 21 additions & 0 deletions levelScreen.d
Expand Up @@ -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();
Expand All @@ -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();
}

}

}
16 changes: 8 additions & 8 deletions 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
4 changes: 2 additions & 2 deletions warningBar.d
Expand Up @@ -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);
}
}
}

0 comments on commit cbf8bed

Please sign in to comment.