From 2f6c5b546b7cddc0efd27dc3188793499c50d075 Mon Sep 17 00:00:00 2001 From: ZILtoid1991 Date: Tue, 12 Dec 2023 22:50:24 +0100 Subject: [PATCH] Updating the test script to the new script architecture --- assets/test4.lua | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/assets/test4.lua b/assets/test4.lua index 0365183..7d80b10 100644 --- a/assets/test4.lua +++ b/assets/test4.lua @@ -3,20 +3,15 @@ Globalstate = 0 MoveX = 1 MoveY = 1 ---Script entry point -function Main(luastate) - Globalstate = luastate - local sprtLayer = getLayer(16) - local dlangman = getBitmapResource("dlangman") - addSprite(sprtLayer, dlangman, 0, 0, 0, 0, 0, 255, 1024, 1024) - --timer_register(Globalstate, 20, "UpdateFunc") - return 0 +--Script initialization +function Initialize() + addSprite(16, "dlangman", 0, 0, 0, 0, 255, 1024, 1024) end --Make D man bounce on the screen function UpdateFunc() - local sprtLayer = getLayer(16) - relMoveSprite(sprtLayer, 0, MoveX, MoveY) - local spritePos = getSpriteCoordinate(sprtLayer, 0) + relMoveSprite(16, 0, MoveX, MoveY) + local spritePos = getSpriteCoordinate(16, 0) + --test sprite if it touched the edges if spritePos.left <= 0 then MoveX = 1 end