From f353c89172495f0916431c365260f45584b3b6ec Mon Sep 17 00:00:00 2001 From: Jorim Tielemans Date: Wed, 31 Jul 2019 18:15:03 +0200 Subject: [PATCH] Add relative scroll to backgrounds --- engine/include/libgba-sprite-engine/background/background.h | 3 ++- engine/src/background/background.cpp | 5 +++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/engine/include/libgba-sprite-engine/background/background.h b/engine/include/libgba-sprite-engine/background/background.h index f55ae01..efcfcf1 100644 --- a/engine/include/libgba-sprite-engine/background/background.h +++ b/engine/include/libgba-sprite-engine/background/background.h @@ -25,9 +25,10 @@ public: const int getCharBlock() { return charBlockIndex; } void useMapScreenBlock(int block) { screenBlockIndex = block; } void scroll(int x, int y); + void scrollSpeed(int dx, int dy); Background(int bgIndex, const void *data, int size, const void* map, int mapSize) : data(data), bgIndex(bgIndex), size(size), map(map), - screenBlockIndex(0), charBlockIndex(0), mapSize(mapSize) {} + screenBlockIndex(0), charBlockIndex(0), mapSize(mapSize) {} virtual void persist(); void updateMap(const void* map); void clearMap(); diff --git a/engine/src/background/background.cpp b/engine/src/background/background.cpp index f5121c5..3191005 100644 --- a/engine/src/background/background.cpp +++ b/engine/src/background/background.cpp @@ -78,4 +78,9 @@ void Background::buildRegister() { void Background::scroll(int x, int y) { REG_BG_OFS[bgIndex].x = x; REG_BG_OFS[bgIndex].y = y; +} + +void Background::scrollSpeed(int dx, int dy) { + REG_BG_OFS[bgIndex].x += dx; + REG_BG_OFS[bgIndex].y += dy; } \ No newline at end of file