init tilemap work

This commit is contained in:
Tangent 2020-05-21 22:26:23 -07:00
commit 36e02f0be4
3 changed files with 43 additions and 0 deletions

BIN
src/1bit_kenny.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 26 KiB

4
src/main.moon Normal file
View File

@ -0,0 +1,4 @@
map = require "map"
love.draw = ->
map.draw "stone", 8, 8 -- simple test, top left corner

39
src/map.moon Normal file
View File

@ -0,0 +1,39 @@
image = love.graphics.newImage "1bit_kenny.png"
w, h = image\getDimensions!
tile_coordinates = {
dirt: {1, 1} --
stone: {6, 3} -- harvest: stone
tall_gress: {1, 3} -- harvest: grain + plant_fibre
grass: {6, 1} -- harvest: seeds
tree: {5, 3} -- harvest: wood + seeds|fruit + plant_fibre
cactus: {7, 2} -- harvest: cactus (food)
path: {5, 1} -- make: tools
stone_wall: {11, 18} -- make: stone & tools
wooden_mineshaft: {8, 7} -- make: wood & tools
farmland: {13, 7} -- make: tools on grass or dirt
chest: {9, 7} -- make: wood & tools
wooden_fence: {14, 17} -- make: wood & tools
wooden_well: {11, 9} -- make: wood & tools
wooden_door: {4, 10} -- make: wood & tools
bed: {6, 9} -- make: wood + textile & tools
cooking_pot: {6, 15} -- make: metal & forge
wooden_table: {2, 9} -- make: wood & tools
wooden_boat: {12, 20} -- make: wood & tools
campfire: {15, 11} -- make: wood
brick_wall: {8, 16} -- make:
stone_table: {15, 10} -- make: stone & tools
}
quads = {}
for name, coords in pairs tile_coordinates
x = coords[1] - 1
y = coords[2] - 1
quads[name] = love.graphics.newQuad x * 16 + x, y * 16 + y, 16, 16, w, h
draw = (name, x, y) ->
love.graphics.draw image, quads[name], x, y, 0, 1, 1, 8, 8
return {
:draw
}