+59
-0
lines changedFilter options
+59
-0
lines changed Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
1
+
/*
2
+
* FXGL - JavaFX Game Library. The MIT License (MIT).
3
+
* Copyright (c) AlmasB (almaslvl@gmail.com).
4
+
* See LICENSE for details.
5
+
*/
6
+
7
+
package com.almasb.fxgl.physics.box2d.collision
8
+
9
+
import com.almasb.fxgl.core.math.Vec2
10
+
import com.almasb.fxgl.physics.box2d.collision.shapes.CircleShape
11
+
import com.almasb.fxgl.physics.box2d.collision.shapes.PolygonShape
12
+
import org.hamcrest.MatcherAssert.*
13
+
import org.hamcrest.Matchers.*
14
+
import org.junit.jupiter.api.BeforeEach
15
+
import org.junit.jupiter.api.Test
16
+
17
+
/**
18
+
*
19
+
* @author Almas Baimagambetov (almaslvl@gmail.com)
20
+
*/
21
+
class DistanceProxyTest {
22
+
23
+
private lateinit var proxy: DistanceProxy
24
+
25
+
@BeforeEach
26
+
fun `setUp`() {
27
+
proxy = DistanceProxy()
28
+
}
29
+
30
+
@Test
31
+
fun `distance proxy polygon shape`() {
32
+
val shape = PolygonShape()
33
+
shape.setAsBox(0.5f, 0.5f)
34
+
35
+
proxy.set(shape, 0)
36
+
37
+
assertThat(proxy.getVertex(0), `is`(Vec2(-0.5f, -0.5f)))
38
+
assertThat(proxy.radius, `is`(0.01f))
39
+
40
+
val support = proxy.getSupport(Vec2(1.0, 0.0))
41
+
42
+
assertThat(support, `is`(1))
43
+
}
44
+
45
+
@Test
46
+
fun `distance proxy circle shape`() {
47
+
val shape = CircleShape(2.5f)
48
+
shape.center.set(-2.5f, 3.2f)
49
+
50
+
proxy.set(shape, 0)
51
+
52
+
assertThat(proxy.getVertex(0), `is`(Vec2(-2.5f, 3.2f)))
53
+
assertThat(proxy.radius, `is`(2.5f))
54
+
55
+
val support = proxy.getSupport(Vec2(1.0, 0.0))
56
+
57
+
assertThat(support, `is`(0))
58
+
}
59
+
}
You can’t perform that action at this time.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4