[nostalgia/player] Make sprites in demo scene auto-scroll
This commit is contained in:
parent
3b19909eb1
commit
6a02161b37
@ -6,24 +6,31 @@
|
||||
|
||||
using namespace nostalgia;
|
||||
|
||||
static unsigned spriteX = 72;
|
||||
static unsigned spriteY = 64;
|
||||
static int spriteX = 72;
|
||||
static int spriteY = 64;
|
||||
|
||||
static int updateHandler(core::Context *ctx) noexcept {
|
||||
int xmod = 0;
|
||||
int ymod = 0;
|
||||
if (core::buttonDown(ctx, core::GamePad_Right)) {
|
||||
spriteX += 2;
|
||||
xmod = 2;
|
||||
} else if (core::buttonDown(ctx, core::GamePad_Left)) {
|
||||
spriteX -= 2;
|
||||
xmod = -2;
|
||||
}
|
||||
if (core::buttonDown(ctx, core::GamePad_Down)) {
|
||||
spriteY += 2;
|
||||
ymod = 2;
|
||||
} else if (core::buttonDown(ctx, core::GamePad_Up)) {
|
||||
spriteY -= 2;
|
||||
ymod = -2;
|
||||
}
|
||||
if (!xmod && !ymod) {
|
||||
spriteX += 2;
|
||||
}
|
||||
spriteX += xmod;
|
||||
spriteY += ymod;
|
||||
constexpr auto s = "nostalgia";
|
||||
for (unsigned i = 0; s[i]; ++i) {
|
||||
const auto c = static_cast<unsigned>(s[i] - ('a' - 1));
|
||||
core::setSprite(ctx, i, spriteX + 8 * (i + 1), spriteY, c);
|
||||
core::setSprite(ctx, i, static_cast<unsigned>(spriteX) + 8 * (i + 1), static_cast<unsigned>(spriteY), c);
|
||||
}
|
||||
return 16;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user