Mercurial > games > semicongine
diff examples/E04_input.nim @ 302:da0bd61abe91
did: change API for ECS
author | Sam <sam@basx.dev> |
---|---|
date | Tue, 27 Jun 2023 00:17:40 +0700 |
parents | 95281f2db400 |
children | b145a05c2459 |
line wrap: on
line diff
--- a/examples/E04_input.nim Tue Jun 27 00:01:36 2023 +0700 +++ b/examples/E04_input.nim Tue Jun 27 00:17:40 2023 +0700 @@ -135,15 +135,15 @@ # define mesh objects scene = newScene("scene", newEntity("scene")) - scene.root.add newEntity("background", backgroundmesh) - let keyboard = newEntity("keyboard", keyboardmesh) + scene.root.add newEntity("background", {"mesh": Component(backgroundmesh)}) + let keyboard = newEntity("keyboard", {"mesh": Component(keyboardmesh)}) keyboard.transform = translate3d( -float32(rowWidth) / 2'f32, -float32(tupleLen(keyRows) * (keyDimension + keyGap) - keyGap) / 2'f32, 0'f32 ) - scene.root.add newEntity("keyboard-center", keyboard) - scene.root.add newEntity("cursor", cursormesh) + scene.root.add newEntity("keyboard-center", [], keyboard) + scene.root.add newEntity("cursor", {"mesh": Component(cursormesh)}) # shaders const @@ -194,7 +194,7 @@ let mousePos = translate3d(myengine.mousePosition().x + 20, myengine.mousePosition().y + 20, 0'f32) scene.root.firstWithName("cursor").transform = mousePos - var mesh = Mesh(scene.root.firstWithName("keyboard").components[0]) + var mesh = Mesh(scene.root.firstWithName("keyboard")["mesh"]) for (index, key) in enumerate(keyIndices): if myengine.keyWasPressed(key): let baseIndex = uint32(index * 4)