[nostalgia] Add implementation of single tile sprites on OpenGL
This commit is contained in:
@@ -12,14 +12,14 @@ static int spriteY = 64;
|
||||
static int updateHandler(core::Context *ctx) noexcept {
|
||||
int xmod = 0;
|
||||
int ymod = 0;
|
||||
if (core::buttonDown(ctx, core::GamePad_Right)) {
|
||||
if (core::buttonDown(ctx, core::Alpha_D) || core::buttonDown(ctx, core::GamePad_Right)) {
|
||||
xmod = 2;
|
||||
} else if (core::buttonDown(ctx, core::GamePad_Left)) {
|
||||
} else if (core::buttonDown(ctx, core::Alpha_A) || core::buttonDown(ctx, core::GamePad_Left)) {
|
||||
xmod = -2;
|
||||
}
|
||||
if (core::buttonDown(ctx, core::GamePad_Down)) {
|
||||
if (core::buttonDown(ctx, core::Alpha_S) || core::buttonDown(ctx, core::GamePad_Down)) {
|
||||
ymod = 2;
|
||||
} else if (core::buttonDown(ctx, core::GamePad_Up)) {
|
||||
} else if (core::buttonDown(ctx, core::Alpha_W) || core::buttonDown(ctx, core::GamePad_Up)) {
|
||||
ymod = -2;
|
||||
}
|
||||
if (!xmod && !ymod) {
|
||||
@@ -27,10 +27,10 @@ static int updateHandler(core::Context *ctx) noexcept {
|
||||
}
|
||||
spriteX += xmod;
|
||||
spriteY += ymod;
|
||||
constexpr auto s = "nostalgia";
|
||||
constexpr ox::StringView s = "nostalgia";
|
||||
for (unsigned i = 0; s[i]; ++i) {
|
||||
const auto c = static_cast<unsigned>(s[i] - ('a' - 1));
|
||||
core::setSprite(ctx, i, static_cast<unsigned>(spriteX) + 8 * (i + 1), static_cast<unsigned>(spriteY), c);
|
||||
core::setSprite(ctx, i, spriteX + 8 * (static_cast<int>(i) + 1), spriteY, c);
|
||||
}
|
||||
return 16;
|
||||
}
|
||||
@@ -53,4 +53,4 @@ ox::Error run(ox::UniquePtr<ox::FileSystem> fs) noexcept {
|
||||
core::setUpdateHandler(ctx.get(), updateHandler);
|
||||
core::setKeyEventHandler(ctx.get(), keyEventHandler);
|
||||
return core::run(ctx.get());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user