Mercurial > games > semicongine
comparison tests/test_collision.nim @ 1135:74957cbf589b
fix: update tests according to some API renaming
author | sam <sam@basx.dev> |
---|---|
date | Mon, 03 Jun 2024 16:05:17 +0700 |
parents | 73b572f82a1f |
children | 71315636ba82 |
comparison
equal
deleted
inserted
replaced
1134:055eb17ce31e | 1135:74957cbf589b |
---|---|
31 var engine = initEngine("Test collisions") | 31 var engine = initEngine("Test collisions") |
32 | 32 |
33 engine.initRenderer({VERTEX_COLORED_MATERIAL: shaderConfiguration}) | 33 engine.initRenderer({VERTEX_COLORED_MATERIAL: shaderConfiguration}) |
34 engine.loadScene(scene) | 34 engine.loadScene(scene) |
35 | 35 |
36 while engine.updateInputs() and not keyIsDown(Escape): | 36 while engine.UpdateInputs() and not KeyIsDown(Escape): |
37 if windowWasResized(): | 37 if WindowWasResized(): |
38 var winSize = engine.getWindow().size | 38 var winSize = engine.GetWindow().size |
39 scene.setShaderGlobal("perspective", orthoWindowAspect(winSize[0] / winSize[1])) | 39 scene.setShaderGlobal("perspective", orthoWindowAspect(winSize[0] / winSize[1])) |
40 if keyIsDown(A): scene.meshes[0].transform = scene.meshes[0].transform * translate(-0.001, 0, 0) | 40 if KeyIsDown(A): scene.meshes[0].transform = scene.meshes[0].transform * translate(-0.001, 0, 0) |
41 if keyIsDown(D): scene.meshes[0].transform = scene.meshes[0].transform * translate(0.001, 0, 0) | 41 if KeyIsDown(D): scene.meshes[0].transform = scene.meshes[0].transform * translate(0.001, 0, 0) |
42 if keyIsDown(W): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, -0.001, 0) | 42 if KeyIsDown(W): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, -0.001, 0) |
43 if keyIsDown(S): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, 0.001, 0) | 43 if KeyIsDown(S): scene.meshes[0].transform = scene.meshes[0].transform * translate(0, 0.001, 0) |
44 if keyIsDown(Q): scene.meshes[0].transform = scene.meshes[0].transform * rotate(-0.001, Z) | 44 if KeyIsDown(Q): scene.meshes[0].transform = scene.meshes[0].transform * rotate(-0.001, Z) |
45 if keyIsDown(Key.E): scene.meshes[0].transform = scene.meshes[0].transform * rotate(0.001, Z) | 45 if KeyIsDown(Key.E): scene.meshes[0].transform = scene.meshes[0].transform * rotate(0.001, Z) |
46 | 46 |
47 if keyIsDown(Key.Z): scene.meshes[1].transform = scene.meshes[1].transform * rotate(-0.001, Z) | 47 if KeyIsDown(Key.Z): scene.meshes[1].transform = scene.meshes[1].transform * rotate(-0.001, Z) |
48 if keyIsDown(Key.X): scene.meshes[1].transform = scene.meshes[1].transform * rotate(0.001, Z) | 48 if KeyIsDown(Key.X): scene.meshes[1].transform = scene.meshes[1].transform * rotate(0.001, Z) |
49 if keyIsDown(Key.C): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, -0.001, 0) | 49 if KeyIsDown(Key.C): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, -0.001, 0) |
50 if keyIsDown(Key.V): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, 0.001, 0) | 50 if KeyIsDown(Key.V): scene.meshes[1].transform = scene.meshes[1].transform * translate(0, 0.001, 0) |
51 let hitbox = Collider(theType: Box, transform: scene.meshes[0].transform * translate(-0.5, -0.5)) | 51 let hitbox = Collider(theType: Box, transform: scene.meshes[0].transform * translate(-0.5, -0.5)) |
52 let hitsphere = Collider(theType: Sphere, transform: scene.meshes[2].transform, radius: 0.5) | 52 let hitsphere = Collider(theType: Sphere, transform: scene.meshes[2].transform, radius: 0.5) |
53 echo intersects(hitbox, hitsphere) | 53 echo intersects(hitbox, hitsphere) |
54 engine.renderScene(scene) | 54 engine.renderScene(scene) |
55 engine.destroy() | 55 engine.destroy() |