From 84eda56087307ae735ac9e7d7fdfb902ec584f1c Mon Sep 17 00:00:00 2001 From: Kiritow <1362050620@qq.com> Date: Wed, 7 Aug 2019 03:35:00 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=A0=B7=E4=BE=8B=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- code/game.lua | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/code/game.lua b/code/game.lua index 7242323..94aada9 100644 --- a/code/game.lua +++ b/code/game.lua @@ -1,15 +1,34 @@ wnd = Window("Hello", 1024, 768) rnd = Renderer(wnd) +font = Font("asserts/msyh.ttf", 18) +music = Music("asserts/mp3/bgm1.mp3") +musicPlayer = MusicPlayer() + +wnd:setTimeout(function() + print("Playing music") + musicPlayer:play(music) + print("Music started playing.") +end, 3000) + wnd:on('click', function(x, y) print("Clicked", x, y) + rnd:clear() + local t = font:renderText(rnd, string.format("%f-%f", x, y), {r=255,g=255,b=255,a=0,type="color"}) + rnd:copyTo(t, {x=x,y=y,type="point"}) + rnd:update() end) wnd:on('quit', function() print("before quit") end) wnd:on('keydown', function(key) print("Keydown", key) + rnd:clear() + rnd:update() wnd:setTimeout(function() print("timer callback.") + rnd:clear() + rnd:copyTo(rnd:loadTexture("asserts/bqb/1.jpg"), {x=0,y=0,type="point"}) + rnd:update() end, 1000) end)