]> git.localhorst.tv Git - ffmpeg-test.git/commitdiff
add sweeping to drawing game master
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 12 Nov 2024 22:13:08 +0000 (23:13 +0100)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Tue, 12 Nov 2024 22:13:08 +0000 (23:13 +0100)
src/app/DrawingGame.h

index b162822cf84ed20d4008171b877b0bd933187b7a..da88be39296a8f8f62114b845786025d763d4da8 100644 (file)
@@ -122,21 +122,29 @@ public:
                                AddDigit(c - '0');
                                break;
                        case 'w': case 'W':
-                       case 'i': case 'I':
                                MoveUp();
                                break;
                        case 's': case 'S':
-                       case 'k': case 'K':
                                MoveDown();
                                break;
                        case 'a': case 'A':
-                       case 'j': case 'J':
                                MoveLeft();
                                break;
                        case 'd': case 'D':
-                       case 'l': case 'L':
                                MoveRight();
                                break;
+                       case 'i': case 'I':
+                               SweepUp();
+                               break;
+                       case 'k': case 'K':
+                               SweepDown();
+                               break;
+                       case 'j': case 'J':
+                               SweepLeft();
+                               break;
+                       case 'l': case 'L':
+                               SweepRight();
+                               break;
                        case 'r': case 'R':
                                SetRed();
                                break;
@@ -235,6 +243,46 @@ public:
                ConsumeNumber();
        }
 
+       void SweepUp() {
+               int distance = GetAbsoluteNumber(1, h) % h;
+               for (int i = 0; i < distance; ++i) {
+                       y = (y + h - 1) % h;
+                       Paste();
+               }
+               text_dirty = true;
+               ConsumeNumber();
+       }
+
+       void SweepDown() {
+               int distance = GetAbsoluteNumber(1, h) % h;
+               for (int i = 0; i < distance; ++i) {
+                       y = (y + 1) % h;
+                       Paste();
+               }
+               text_dirty = true;
+               ConsumeNumber();
+       }
+
+       void SweepLeft() {
+               int distance = GetAbsoluteNumber(1, w) % w;
+               for (int i = 0; i < distance; ++i) {
+                       x = (x + w - 1) % w;
+                       Paste();
+               }
+               text_dirty = true;
+               ConsumeNumber();
+       }
+
+       void SweepRight() {
+               int distance = GetAbsoluteNumber(1, w) % w;
+               for (int i = 0; i < distance; ++i) {
+                       x = (x + 1) % w;
+                       Paste();
+               }
+               text_dirty = true;
+               ConsumeNumber();
+       }
+
        void SetColor(const gfx::ColorRGB &c) {
                cells[y * w + x] = c;
        }