Skip to content

Commit

Permalink
Some fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
soywiz committed Jul 3, 2024
1 parent 2490bc4 commit ffd7d56
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
8 changes: 6 additions & 2 deletions korge-sandbox/src/samples/MainTiledBackground.kt
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,14 @@ class MainTiledBackground : Scene() {
override suspend fun SContainer.sceneMain() {

val tileset = TileSet(
TileSetTileInfo(0, bitmap("korge.png").toBMP32().scaleLinear(0.5, 0.5).slice()),
TileSetTileInfo(1, bitmap("korim.png").toBMP32().scaleLinear(0.5, 0.5).slice()),
listOf(
TileSetTileInfo(0, bitmap("korge.png").toBMP32().scaleLinear(0.5, 0.5).slice()),
TileSetTileInfo(1, bitmap("korim.png").toBMP32().scaleLinear(0.5, 0.5).slice()),
),
//TileSetTileInfo(1, Bitmap32(256, 256, Colors.MEDIUMAQUAMARINE).premultipliedIfRequired().slice())
)
println(tileset.get(0))
println(tileset.get(1))
val tileMapData = TileMapData(2, 2, tileset, repeatX = TileMapRepeat.REPEAT, repeatY = TileMapRepeat.REPEAT)
tileMapData[0, 0] = Tile(0)
tileMapData[1, 0] = Tile(1)
Expand Down
6 changes: 3 additions & 3 deletions korge/test/korlibs/korge/view/tiles/TileMapTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ class TileMapTest {
fun testHitTest() {
val tileSet = TileSet(intMapOf(
0 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.NONE, Rectangle(0, 0, 16, 16).toShape2D(), Matrix())),
1 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.NONE, EmptyShape2D, Matrix())),
2 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, EmptyShape2D, Matrix())),
3 to TileSetTileInfo(0, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, Rectangle(0, 0, 16, 16).toShape2D(), Matrix())),
1 to TileSetTileInfo(1, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.NONE, EmptyShape2D, Matrix())),
2 to TileSetTileInfo(2, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, EmptyShape2D, Matrix())),
3 to TileSetTileInfo(3, Bitmap32(16, 16, premultiplied = true).slice(), collision = TileShapeInfoImpl(HitTestDirectionFlags.ALL, Rectangle(0, 0, 16, 16).toShape2D(), Matrix())),
))
val map = TileMap(TileMapData(SparseChunkedStackedInt53Array2(StackedInt53Array2(Int53Array2(2, 2, int53ArrayOf(0, 1, 2, 3)))), tileSet))
assertEquals(false, map.pixelHitTest(5, 5, HitTestDirection.DOWN))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import korlibs.korge.view.*
import korlibs.math.geom.*
import korlibs.math.geom.slice.*
import korlibs.memory.*
import korlibs.number.*
import kotlin.test.*

class TileMapViewScreenshotTest {
Expand Down

0 comments on commit ffd7d56

Please sign in to comment.