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