Permalink
Browse files

arrow foo and q in select screen

  • Loading branch information...
1 parent 170db51 commit c7f28cb5b7c77bf6ffaf3250c7be7007b37276d0 @wolfwood wolfwood committed Oct 24, 2010
Showing with 79 additions and 15 deletions.
  1. +66 −2 arrowSection.d
  2. +4 −11 input.d
  3. +9 −2 ycurses/examples/tutorial/basics/key_code.d
View
@@ -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;
+}
View
15 input.d
@@ -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;
-}
+}
+
@@ -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.