Added test case for terrain and fixed player box size

This commit is contained in:
Ziver Koc 2020-04-21 00:35:11 +02:00
parent 003e885cf7
commit 85ffe136d3
5 changed files with 97 additions and 39 deletions

View file

@ -12,8 +12,8 @@ class BlockTest {
Block block = new Block(0, 0);
assertEquals(0, block.getBlockStartX());
assertEquals(0, block.getBlockStartY());
assertEquals(19, block.getBlockEndX());
assertEquals(19, block.getBlockEndY());
assertEquals(Block.BLOCK_SIZE-1, block.getBlockEndX());
assertEquals(Block.BLOCK_SIZE-1, block.getBlockEndY());
}
@Test

View file

@ -0,0 +1,36 @@
package se.cookery.gfx.terrain;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;
class TerrainMeshTest {
@Test
public void singleSquareTerrain(){
TerrainMesh terrain = new TerrainMesh(1, 1, 1 ,1);
float[] index = terrain.generateVertexBuffer();
assertEquals(3*4, index.length);
assertArrayEquals(new float[]{
0, 0, 0,
0, 0, 1,
1, 0, 1,
1, 0, 0,
}, index);
}
@Test
public void fourSquareTerrain(){
TerrainMesh terrain = new TerrainMesh(1, 1, 2 ,2);
float[] index = terrain.generateVertexBuffer();
assertEquals(3*9, index.length);
assertArrayEquals(new float[]{
0, 0, 0,
0, 0, 1,
1, 0, 1,
1, 0, 0,
}, index);
}
}