From 1a8814881cedb63ffd0204304c7935b94e8e0c6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Ma=C5=A1karinec?= Date: Wed, 17 Apr 2024 09:51:03 +0100 Subject: [PATCH] Playground fixes MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Marek Maškarinec --- etc/playground.html | 62 ++++++++++++++++++++++----------------------- 1 file changed, 31 insertions(+), 31 deletions(-) diff --git a/etc/playground.html b/etc/playground.html index 2d37fc5..0040b44 100644 --- a/etc/playground.html +++ b/etc/playground.html @@ -160,10 +160,10 @@

Tophat playground

) fn init*() { - window.setup("Hello world", 200, 200) + window::setup("Hello world", 200, 200) - window.onFrame.register({ - canvas.drawText("Hello world", { 1, 1 }, th.green, 1) + window::onFrame.register({ + canvas::drawText("Hello world", { 1, 1 }, th::green, 1) }) }`); break; @@ -176,17 +176,17 @@

Tophat playground

"std.um" ) -var ft: font.Font +var ft: font::Font fn init*() { - window.setup("Hello world", 200, 200) + window::setup("Hello world", 200, 200) - var err: std.Err - ft, err = font.load("etc/roboto.ttf", 32) - std.exitif(err) + var err: std::Err + ft, err = font::load("etc/roboto.ttf", 32) + std::exitif(err) - window.onFrame.register({ - ft.draw("Hello world", { 1, 1 }, th.green, 1) + window::onFrame.register({ + ft.draw("Hello world", { 1, 1 }, th::green, 1) }) }`); break; @@ -194,28 +194,28 @@

Tophat playground

window.jar.updateCode( `import ("th.um"; "rect.um"; "input.um"; "canvas.um"; "window.um"; "signal.um") -pos := th.Vf2{100, 100} +pos := th::Vf2{100, 100} fn init*() { const speed = 100 - window.setup("my game", 400, 400) - window.setViewport(th.Vf2{200, 200}) + window::setup("my game", 400, 400) + window::setViewport(th::Vf2{200, 200}) - window.onFrame.register(signal.Callback{ - var change: th.Vf2 + window::onFrame.register({ + var change: th::Vf2 // Handle input - if input.isPressedc('A') { change.x -= 1 } - if input.isPressedc('D') { change.x += 1 } - if input.isPressedc('W') { change.y -= 1 } - if input.isPressedc('S') { change.y += 1 } + if input::isPressedc('A') { change.x -= 1 } + if input::isPressedc('D') { change.x += 1 } + if input::isPressedc('W') { change.y -= 1 } + if input::isPressedc('S') { change.y += 1 } // Apply movement - pos = pos.add(change.norm().mulf(speed * th.delta / 1000.0)) + pos = pos.add(change.norm().mulf(speed * th::delta / 1000.0)) // Draw! - canvas.drawRect(th.green, rect.mk(pos.x, pos.y, 10, 10)) + canvas::drawRect(th::green, rect::mk(pos.x, pos.y, 10, 10)) }) }`); break; @@ -223,20 +223,20 @@

Tophat playground

window.jar.updateCode( `import ("window.um"; "image.um"; "th.um"; "signal.um"; "std.um") -var img: image.Image +var img: image::Image const scale = 4 fn init*() { - window.setup("image drawing", 400, 400) - var err: std.Err - img, err = image.load("etc/logo/logo-hatonly.png") - std.exitif(err) - - window.onFrame.register(signal.Callback{ - img.draw(th.mkTransform( - window.wp.sub(img.getDims().mulf(scale)).divf(2), - th.vf2f(scale) )) + window::setup("image drawing", 400, 400) + var err: std::Err + img, err = image::load("etc/logo/logo-hatonly.png") + std::exitif(err) + + window::onFrame.register({ + img.draw(th::mkTransform( + window::wp.sub(img.getDims().mulf(scale)).divf(2), + th::vf2f(scale) )) }) }`); break;