Skip to content

Commit

Permalink
arrow foo and q in select screen
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfwood committed Oct 24, 2010
1 parent 170db51 commit c7f28cb
Show file tree
Hide file tree
Showing 3 changed files with 79 additions and 15 deletions.
68 changes: 66 additions & 2 deletions arrowSection.d
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,81 @@ import ncurses;
import tango.io.Stdout;
import tango.util.Convert;

import tango.math.random.Random;

import asciiSprite;

class ArrowSection {
AsciiSprite _frame;

AsciiSprite _frame, l, r, u, d;

double sleep;

this() {
_frame = new AsciiSprite("graphics/arrow-frame.txt", null, true, 60, 0);
//l = new AsciiSprite("graphics/arrow-frame.txt", null, true, 60, 0);
}

void draw() {
_frame.drawSprite();
// draw arrows and shit

if(offset == 0){
// parse shite frum file, appendto arrows and drop top if required
Beat* beat = new Beat;

beat.arrows = randomArrows();
beat.period = 1.0;

beats ~= beat;

if(beats.length > beatsOnScreen){
beats = beats[1..$];
}

sleep = beats[0].period;
}

offset++;
offset %= 4;


// Draw
for(int i = 0; i < beats.length; i++){

ubyte arrows = beats[i].arrows;

// draw left arrow
if(arrows & 1){

}

// draw right arrow
if(arrows & 2){

}

// draw up arrow
if(arrows & 4){

}

// draw down arrow
if(arrows & 8){

}
}
}

private:
Beat*[] beats;
int beatsOnScreen = 5, offset;

ubyte randomArrows(){
return rand.uniformR(16);
}
}

struct Beat{
ubyte arrows; //lrud
double period;
}
15 changes: 4 additions & 11 deletions input.d
Original file line number Diff line number Diff line change
Expand Up @@ -28,22 +28,15 @@ bool levelInput(SelectScreen screen, WINDOW* win){
screen.up();
}else if(key == Key.DownArrow){
screen.down();
}else if(key == 'q'){
return false;
}

clear();
screen.drawScreen();
refresh();
}

/*screen.down();
clear();
screen.drawScreen();
refresh();
Thread.sleep(5);
screen.selectLevel();
*/

return true;
}
}

11 changes: 9 additions & 2 deletions ycurses/examples/tutorial/basics/key_code.d
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@ void main()
noecho();
keypad(stdscr, true);

ch = getch();
while(1){
ch = getch();

printw("The key pressed is %d\n", ch);
refresh();
if(ch == 'q'){
break;
}
}
endwin();
printf("The key pressed is %d\n", ch);
}

0 comments on commit c7f28cb

Please sign in to comment.