From 59779a76e2a5f10742aa9f38d6308a477c69f841 Mon Sep 17 00:00:00 2001 From: Nathan Rajlich Date: Thu, 5 Oct 2023 14:50:29 -0300 Subject: [PATCH] Fix "starwars" example --- apps/starwars/src/main.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/starwars/src/main.ts b/apps/starwars/src/main.ts index 78e9ee50..6cfaab64 100644 --- a/apps/starwars/src/main.ts +++ b/apps/starwars/src/main.ts @@ -6,11 +6,6 @@ const fontData = Switch.readFileSync( const font = new FontFace('Hack', fontData); Switch.fonts.add(font); -const ctx = Switch.screen.getContext('2d'); -const fontSize = 30.83; -const yOffset = 180; -ctx.font = `${fontSize}px Hack`; - function fdToStream(fd: number) { const decoder = new TextDecoder(); const buffer = new ArrayBuffer(102400); @@ -45,7 +40,7 @@ async function main() { // wait for prompt while (true) { const chunk = await reader.read(); - if (chunk.value?.includes('More commands become available')) { + if (chunk.value?.includes('Press control-C')) { break; } } @@ -56,6 +51,11 @@ async function main() { // next line is the "starwars" echo, which we can ignore await reader.read(); + const ctx = Switch.screen.getContext('2d'); + const fontSize = 30.83; + const yOffset = 180; + ctx.font = `${fontSize}px Hack`; + // dump the movie to the console let lineCount = 0; while (true) {