kaboom icon indicating copy to clipboard operation
kaboom copied to clipboard

Tileset support?

Open zachcowell opened this issue 4 years ago • 3 comments

Is there support for tilesets? I would like to create levels using a single tileset image and pass in indices of tile objects (instead of separate sprite images individually).

Great project btw! Very simple and fun to play with

zachcowell avatar Apr 10 '21 19:04 zachcowell

Not yet but definitely, I'll look into this next week!

slmjkdbtl avatar Apr 11 '21 20:04 slmjkdbtl

so right now the tileset related supports are:

  1. you can slice images into frames by sliceX and sliceY field in loadSprite()
// slice the image into 12 x 3 = 36 frames with equal sizes
loadSprite("tileset", "path_to_image.png", {
    sliceX: 12,
    sliceY: 3,
});

// later in code...

add([
    sprite("tileset", { frame: 12, }),
]);
  1. manually pass in a quad field to sprite() component conf (just introduced to master in https://github.com/replit/kaboom/commit/e480fb5bf5c252b36e7325e79f83dc9c2f8d8c38)
// will only draw the rectangle area of x: 0, y: 0, w: 0.2, h: 0.2 of the image
add([
    sprite("tileset", { quad: quad(0, 0, 0.2, 0.2), }),
]);

i don't have a lot of experience using tilemaps, curious to know if you have any ideal API in mind for a code-only solution

slmjkdbtl avatar Apr 12 '21 22:04 slmjkdbtl

does the slicer also support gaps between images? Sometimes free tilesets have:

  • margin around entire tileset
  • padding between tiles opengameart and itch.io are a great place to check out free tilesets https://opengameart.org/art-search-advanced?keys=tile&title=&field_art_tags_tid_op=or&field_art_tags_tid=&name=&field_art_type_tid%5B%5D=9&sort_by=count&sort_order=DESC&items_per_page=24&Collection= https://limezu.itch.io/moderninteriors

Another exciting one to get would be animated tiles :)

they are fantastic for quick prototyping and gamejams btw. This capability will make kaboom the bomb on gamejam imo

blurymind avatar Jun 08 '21 12:06 blurymind