diff options
| author | Matthias Melcher <fltk@matthiasm.com> | 2007-11-19 14:14:13 +0000 |
|---|---|---|
| committer | Matthias Melcher <fltk@matthiasm.com> | 2007-11-19 14:14:13 +0000 |
| commit | b92ee9f21ccbc52e1c2f6d1c0818c9bff9f6ac50 (patch) | |
| tree | d35ee6cd8bfd977f322e1b87c99f7cd6c843be49 /test | |
| parent | 745548245824be2cf5ecd5cb325cbcffa95aee70 (diff) | |
Fixed some typos and some funny language (my own) in the documentation of the test applications. ADded a hidden [+] key support for 'Blocks' so that I can increase the level to my prefered one (6) and not have to play through 1-5 ;-)
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.1@5976 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
| -rw-r--r-- | test/blocks.cxx | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/test/blocks.cxx b/test/blocks.cxx index 02999d6f2..d221bed7d 100644 --- a/test/blocks.cxx +++ b/test/blocks.cxx @@ -476,6 +476,7 @@ class BlockWindow : public Fl_Double_Window int handle(int event); void new_game(); int score() { return (score_); } + void up_level(); }; @@ -734,6 +735,12 @@ BlockWindow::handle(int event) { else if (interval_ < 0.0 || paused_) return (0); switch (event) { + case FL_KEYBOARD: + if (Fl::event_text()) { + if (strcmp(Fl::event_text(), "+") == 0) + up_level(); + } + break; case FL_PUSH : mx = w() - Fl::event_x() + BLOCK_SIZE; my = h() - Fl::event_y(); @@ -841,6 +848,15 @@ BlockWindow::play_cb(Fl_Widget *wi, BlockWindow *bw) { } } +void BlockWindow::up_level() { + interval_ *= 0.95; + opened_columns_ = 0; + if (num_colors_ < 7) num_colors_ ++; + level_ ++; + sprintf(title_, "Level: %d", level_); + title_y_ = h(); + Fl::repeat_timeout(interval_, (Fl_Timeout_Handler)timeout_cb, (void *)this); +} // Animate the game... void @@ -940,14 +956,7 @@ BlockWindow::timeout_cb(BlockWindow *bw) { bw->opened_columns_ ++; if (bw->opened_columns_ > (2 * BLOCK_COLS)) { - bw->interval_ *= 0.95; - bw->opened_columns_ = 0; - - if (bw->num_colors_ < 7) bw->num_colors_ ++; - - bw->level_ ++; - sprintf(bw->title_, "Level: %d", bw->level_); - bw->title_y_ = bw->h(); + bw->up_level(); } c = bw->columns_; |
