comparison tests/test_collision.nim @ 1136:71315636ba82

did: refactor naming in tons of places
author sam <sam@basx.dev>
date Tue, 04 Jun 2024 16:51:50 +0700
parents 74957cbf589b
children a4aa9f374d44
comparison
equal deleted inserted replaced
1135:74957cbf589b 1136:71315636ba82
7 scene.add rect() 7 scene.add rect()
8 scene.add circle(color = "0f0f") 8 scene.add circle(color = "0f0f")
9 scene.meshes[0].material = VERTEX_COLORED_MATERIAL.initMaterialData() 9 scene.meshes[0].material = VERTEX_COLORED_MATERIAL.initMaterialData()
10 scene.meshes[1].material = VERTEX_COLORED_MATERIAL.initMaterialData() 10 scene.meshes[1].material = VERTEX_COLORED_MATERIAL.initMaterialData()
11 scene.meshes[2].material = VERTEX_COLORED_MATERIAL.initMaterialData() 11 scene.meshes[2].material = VERTEX_COLORED_MATERIAL.initMaterialData()
12 scene.meshes[1].transform = scale(0.8, 0.8) 12 scene.meshes[1].transform = Scale(0.8, 0.8)
13 scene.meshes[2].transform = scale(0.1, 0.1) 13 scene.meshes[2].transform = Scale(0.1, 0.1)
14 scene.addShaderGlobal("perspective", Unit4F32) 14 scene.addShaderGlobal("perspective", Unit4F32)
15 15
16 const 16 const
17 shaderConfiguration = createShaderConfiguration( 17 shaderConfiguration = createShaderConfiguration(
18 name = "default shader", 18 name = "default shader",
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()
56 56