64 lines
2.5 KiB
JavaScript
64 lines
2.5 KiB
JavaScript
import { Tile, TileMap } from './tiles'
|
|
import { ItemPlaceable, ItemMiningTool } from './items'
|
|
|
|
const map = new TileMap('assets/ground.png', 32)
|
|
|
|
const dirtStrength = 2
|
|
|
|
// Basic tiles
|
|
const dirtTile = new Tile('DIRT', 33, true, null, dirtStrength)
|
|
const grassTile = new Tile('GRASS_TOP', 6, true, null, dirtStrength)
|
|
const stoneTile = new Tile('STONE', 10, true, null, 10)
|
|
|
|
// Items for basic tiles
|
|
const dirtItem = new ItemPlaceable(dirtTile, 'dirt', 'assets/item_dirt.png')
|
|
const grassItem = new ItemPlaceable(grassTile, 'dirt_with_grass', 'assets/item_grass.png')
|
|
const stoneItem = new ItemPlaceable(stoneTile, 'stone', 'assets/item_stone.png')
|
|
const drill = new ItemMiningTool('drill', 'assets/item_drill.png', 0.5)
|
|
|
|
// Set the items
|
|
dirtTile.item = dirtItem
|
|
grassTile.item = grassItem
|
|
stoneTile.item = stoneItem
|
|
|
|
// Register dirt tiles
|
|
map.register([
|
|
new Tile('DIRT_CORNER_TOP_LEFT', 0, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_TOP', 1, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_CORNER_TOP_RIGHT', 2, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_INNER_BOTTOM_RIGHT', 3, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_INNER_BOTTOM_LEFT', 4, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_LEFT', 32, true, dirtItem, dirtStrength),
|
|
dirtTile,
|
|
new Tile('DIRT_RIGHT', 34, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_INNER_TOP_RIGHT', 35, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_INNER_TOP_LEFT', 36, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_CORNER_BOTTOM_LEFT', 64, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_BOTTOM', 65, true, dirtItem, dirtStrength),
|
|
new Tile('DIRT_CORNER_BOTTOM_RIGHT', 66, true, dirtItem, dirtStrength)
|
|
])
|
|
|
|
// Register grass tiles
|
|
map.register([
|
|
new Tile('GRASS_CORNER_TOP_LEFT', 5, true, grassItem, dirtStrength),
|
|
grassTile,
|
|
new Tile('GRASS_CORNER_TOP_RIGHT', 7, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_INNER_BOTTOM_RIGHT', 8, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_INNER_BOTTOM_LEFT', 9, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_LEFT', 37, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_RIGHT', 39, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_INNER_TOP_RIGHT', 40, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_INNER_TOP_LEFT', 41, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_CORNER_BOTTOM_LEFT', 69, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_BOTTOM', 70, true, grassItem, dirtStrength),
|
|
new Tile('GRASS_CORNER_BOTTOM_RIGHT', 71, true, grassItem, dirtStrength)
|
|
])
|
|
|
|
// Register other tiles
|
|
map.register([
|
|
new Tile('AIR', -1, false),
|
|
stoneTile
|
|
])
|
|
|
|
export default map
|