diff --git a/a_pleasant_stroll.p8 b/a_pleasant_stroll.p8 index 3f9c12c..12a4711 100644 --- a/a_pleasant_stroll.p8 +++ b/a_pleasant_stroll.p8 @@ -7,38 +7,38 @@ __lua__ #include player.lua #include main.lua __gfx__ -000000000000000033333333335555333344443338333333333333e3383333833333333399999999999899999994999499999999999999993333333399999999 -00000000000000003333333335554553344444438a833383333e3e9e888338883333333399999999998a89999499949999999999999999993333333399999999 -0070070000000000333333335555555534444443383338a833e9e3e33733337333333333999999999998b9b99949994999944999999bb9b93333333399999999 -000770000000000033333333554554553344443333333383333e33333333333333378333999999999b9bb9b999994999994444999b9bb9b93333333399999999 -000770000000000033333333555555553335533333338333333333333333383333888733999999999b9bbbb999499994944444499b9bbbb93333333399999999 -00700700000000003333333355545555333553333338a8333e333e333333888338788883999999999bbbb99999994999944444499bbbb99933355333999bb999 -000000000000000033333333355555533335533333338333e9e3e9e3333337333337733399999999999bb9999499994999444499999bb99933355333999bb999 -0000000000000000333333333355553333555533333333333e333e33333333333337733399999999999bb9999999999999944999999bb99933555533999bb999 -3333333333555533b333333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -3333333335555553b333b3b300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -333333335555555533b3b3b300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -333333335555555533b3333300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -3333333355555555b3333b3300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -3333333355555555b33b3b3300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -33377333355555533b3b33b300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -33377333335555333b3333b300000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008800000000000000000000000000000 +00000000000000000000000000000000000000000bbbb000000000000bbbb0000000000000500050500000000050005058800000000000000000000000000000 +00700700000bbbbbbbb0000000000000000000000b8b8b00000000000bbbbb00000000000bb000bbb00000000bb000b88aa88000000000000000000000000000 +0007700000bbbb3bbbbbb0000000000000000000bbbbbb00bbbb0000bbbbbb00bbbb00005bb50bbbbb0000005bb50bb88aa88000000000000000000000000000 +000770000bb34b3b3b4bbb000000000000000000bb8bbb0bbb8bb000bbbbbb0bbbbbb0000bb05b3b3b5050000bb05b3b38805000000000000000000000000000 +007007000bb3b3bb3bb3bb000000000000000000bbb8b00bb8b8b000bbbbb00bbbbbb0000bb00bbbbb00bb500bb00bbbb880bb50000000000000000000000000 +000000000bbbb3b3bbb3bb0000000000000000000bbbb000bbbbb0000bbbb000bbbbb0005bbbbb333b05bb005bbbbb333b05bb00000000000000000000000000 +000000000bbbbbb3bb3bbb000000000000000000000000000bbb0000000000000bbb000000bbbbbbbb50bb5000bbbbbbbb50bb50000000000000000000000000 +000000000bb3b4444b3b3b0000000000000000000000000000000000000000000000000000500bbbbb00bb0000500bbbbb00bb00000000000000000000000000 +000000000bb3bb3bb3bb3b00000000000000000000bbb0000000000000bbb0000000000000005bbbbbbbbb0000005bbbbbbbbb00000000000000000000000000 +000000000bbbbb3bb3bbbb0000000000000000000bb8bb0000bbb0000bbbbb0000bbb00000000bbbbbbbb00000000bbbbbbbb000000000000000000000000000 +0000000000bbbbbbbbbbb00000000000000000000bbb8b000b8bbb000bbbbb000bbbbb0000005bbbbb00000000005bbbbb000000000000000000000000000000 +00000000000bbbbbbbbb000000000000000000000b8bbb00bbb8bb000bbbbb00bbbbbb0000000bbbbb50000000000bbbbb50000000000bbbbb50000000000000 +000000000000004440000000000000444000000000bbb000bbbb8b0000bbb000bbbbbb0000005bbbbb00000000005bbbbb00000000005bbbbb00000000000000 +0000000000000044400000000000004440000000000000000b8bbb00000000000bbbbb0000000bbbbb50000000000bbbbb50000000000bbbbb50000000000000 +0000000000000044400000000000004440000000000000000bbbb000000000000bbbb00000000bbbbb00000000000bbbbb00000000000bbbbb00000000000000 +00000000000000000000000000000000000000005000000000000000000000000800000000000000000000e00000000000000800080000000000000000000000 +00000000000000000000000000000000050000000005000000000000b000b0008a8000000000080000000e7e00000e0000008880888000000000000000000000 +00000000000000000000000000000000000505000000050000000000b000b0b00800800008008a8000e000e00000e7e000000700070000000000555555555500 +0000000000000000000000000000000000000005050000000b000b00b000b0b00008a8008a8008000e7e00000e000e0000800000000080000005555555555550 +0000000880000000000000000000000005000000000005000b000b0000b000b0000080000800000000e00000e7e0000008880000000888000055555555555555 +0000008878000000000000000000000000005000500000000b000b0000b00000008000800000000000000e000e00000000700000000070000d55555444455555 +00000788887000000000000000000000005005000005050000b0000000b0000008a808a8000008000000e7e00000000000000000000000000d55544555555555 +00008878888800000000000000000000000000000050000000b0000b0000000b0080008000008a8000000e00000000e008000000000000800d55545555555445 +00088888878880000000000000000000050000050000005000b0000b000b000b000000000000080000e000000e000e7e88800000000008880d55555555544455 +00887888888788000000000000000000000050000050000000000b0b000b000b00000008000000000e7e0000e7e000e007000000000000700d55555555555555 +08788887888887800000000000000000050005000000000000000b00000b00000000008a8000000000e000000e00000000000000000000000d55555445555555 +08888888887888800000000000000000000000005000050000b00b000b000b0000000008000000000000000000000000000800000008000000d5555544455555 +00000077770000000000007777000000000500500050500000b0000b0b000b000080000000008000000000000000e000008880000088800000d5555555555550 +00000077770000000000007777000000000000000000005000b0000b0b000b0008a800800008a8000e000000e00e7e00000700080007000000d5555555555550 +0000007777000000000000777700000005000050050500000000000b00000000008008a800008000e7e0000e7e00e000000000888000000000d5555555555000 +000000777700000000000077770000000000000000000000000000000000000000000080000000000e000000e00000000000000700000000000dddddddd00000 ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 fffffffffffffffffffffffffff88fffff8fffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 fffffffffff78fffffbbbbfffff88fffffff8fff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -47,14 +47,14 @@ fffffffff878888fffbccbfff88aa88ff8ff8fff0000000000000000000000000000000000000000 fffffffffff77fffffbbbbfffff88fffff8ff8ff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 fffffffffff77ffffffffffffff88fffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 -00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +00000000000000000038333333333333e33833338333333333999999999998999999949994999999900000000000000000000000000000000000000000000000 +0000000000000000008a833383333e3e9e888338883333333399999999998a899994999499999999900000000000000000000000000000000000000000000000 +000000000000000000383338a833e9e3e33733337333333333999999999998b9b999499949999449900000000000000000000000000000000000000000000000 +00000000000000000033333383333e33333333333333378333999999999b9bb9b999994999994444900000000000000000000000000000000000000000000000 +00000000000000000033338333333333333333383333888733999999999b9bbbb999499994944444400000000000000000000000000000000000000000000000 +0000000000000000003338a8333e333e333333888338788883999999999bbbb99999994999944444400000000000000000000000000000000000000000000000 +00000000000000000033338333e9e3e9e3333337333337733399999999999bb99994999949994444900000000000000000000000000000000000000000000000 +000000000000000000333333333e333e33333333333337733399999999999bb99999999999999449900000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 @@ -72,7 +72,7 @@ ffffffffffffffffffffffffffffffffffffffff0000000000000000000000000000000000000000 00000000000000000000000000000000000000000000000000000000000880000008800000088000000880000008800000088000000880000008800000088000 00000000000000000000000000000000000000000000000000000000000880000001100000011000001110000001110000011000000110000001100000011000 __gff__ -0000000303000000020003000103000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 +0003030000030301030303030300000000030300000303010103030303000000030300000000000000000000000001010303000000000000000000000000010100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 __sfx__ 012000000961009610096100961007600096000a6000b6000c6000e6000f60010600116001260013600146001560017600196001b6001d6001f6002160024600276002a6002d6003060034600396003c6003e600 diff --git a/index_map.md b/index_map.md index e50c87b..cfaa16f 100644 --- a/index_map.md +++ b/index_map.md @@ -1,24 +1,21 @@ ### sprites --- ### map tiles -2 - grass -3 - bush -4 - tree -5 - red flowers -6 - pink flowers -7 - mushrooms -8 - big mushroom -9 - sand -10 - cactus with flower -11 - pebbles -12 - rock -13 - cactus -14 - tree stump -15 - cactus stump -16 - mushroom stump -17 - empty bush -18 - long grass - +1 - tree +3 - tree stump +5 - bush +7 - empty bush +9 - cactus +11 - cactus with flower +13 - cactus stump +32 - big mushroom +34 - mushroom stump +36 - pebbles +38 - long grass +40 - red flowers +42 - pink flowers +44 - fairy ring +46 - rock ### inventory icons 64 - wood diff --git a/world.lua b/world.lua index 4e6df71..7d4ff42 100644 --- a/world.lua +++ b/world.lua @@ -2,6 +2,24 @@ --- environment function init_world() + -- constants for map tiles' sprite locations, as long as we have the + -- tokens + tile_tree = 1 + tile_tree_stump = 3 + tile_bush = 5 + tile_empty_bush = 7 + tile_cactus = 9 + tile_flowering_cactus = 11 + tile_cactus_stump = 13 + tile_big_mushroom = 32 + tile_mushroom_stump = 34 + tile_pebbles = 36 + tile_long_grass = 38 + tile_red_flowers = 40 + tile_pink_flowers = 42 + tile_fairy_ring = 44 + tile_rock = 46 + -- Metadata for different biomes -- tile_frequencies tuples are {frequency, sprite_index}, see index_map.md -- frequencies by convention add up to 1000, but this is arbitrary, the @@ -9,19 +27,51 @@ function init_world() biome_data = { meadow = { biome_frequency = 20, - tile_frequencies = { {525, 2}, {200, 5}, {200, 6}, {55, 18}, {19, 3}, {1, 4} } + base_color = 3, + tile_frequencies = { + {525, 0}, + {200, tile_red_flowers}, + {200, tile_pink_flowers}, + {55, tile_long_grass}, + {19, tile_bush}, + {1, tile_tree} + } }, grassland = { biome_frequency = 55, - tile_frequencies = { {500, 2}, {345, 18}, {4, 3}, {1, 4}, {100, 5}, {50, 6} } + base_color = 3, + tile_frequencies = { + {500, 0}, + {345, tile_long_grass}, + {4, tile_bush}, + {1, tile_tree}, + {100, tile_red_flowers}, + {50, tile_pink_flowers} + } }, forest = { biome_frequency = 20, - tile_frequencies = { {600, 2}, {200, 4}, {50, 3}, {50, 5}, {40, 7}, {59, 6}, {1, 8} } + base_color = 3, + tile_frequencies = { + {600, 0}, + {200, tile_tree}, + {50, tile_bush}, + {50, tile_red_flowers}, + {40, tile_mushrooms}, + {59, tile_pink_flowers}, + {1, tile_big_mushroom} + } }, desert = { biome_frequency = 5, - tile_frequencies = { {800, 9}, {109, 11}, {60, 13}, {30, 12}, {1, 10} }, + base_color = 9, + tile_frequencies = { + {800, 0}, + {109, tile_pebbles}, + {60, tile_cactus}, + {30, tile_rock}, + {1, tile_flowering_cactus} + } } } @@ -45,39 +95,35 @@ function init_world() build_biome(biome, biome_data[biome]) end - -- the indices here are sprite numbers. object_interaction_map = { - -- bush - [3] = { - replacement = 17, + [tile_bush] = { + replacement = tile_empty_bush, sfx = 13, drop = 68 }, - -- tree - [4] = { - replacement = 14, + [tile_tree] = { + replacement = tile_tree_stump, sfx = 11, drop = 64 }, - -- big mushroom - [8] = { - replacement = 16, + [tile_big_mushroom] = { + replacement = tile_mushroom_stump, sfx = 12, drop = 65 }, -- cactus w/ flower - [10] = { - replacement = 15, + [tile_flowering_cactus] = { + replacement = tile_cactus_stump, sfx = 12, drop = 67 }, -- cactus - [13] = { - replacement = 15, + [tile_cactus] = { + replacement = tile_cactus_stump, sfx = 12, drop = 66 } @@ -95,9 +141,17 @@ end -- this calculates everything about the world fresh every frame, -- but pico-8 handles this just fine! function draw_world(start_x, start_y) - for x=0,15 do - for y=0,15 do - spr(get_tile(start_x-8+x, start_y-8+y), x*8, y*8) + for x=0,7 do + for y=0,7 do + -- color the background for this segment + rectfill(x*16, y*16, x*16+16, y*16+16, + get_base_color(start_x-4+x, start_y-4+y)) + + -- now get the sprite, and render as long as it isn't 0 + local sprite = get_tile(start_x-4+x, start_y-4+y) + if sprite ~= 0 then + spr(sprite, x*16, y*16, 2, 2) + end end end end @@ -141,8 +195,13 @@ function get_biome_name(pos_x, pos_y) return biome_metadata[(uid % #biome_metadata) + 1] end +-- get the background color for the current biome +function get_base_color(x, y) + local biome = get_biome_name(x, y) + return biome_data[biome].base_color +end + -- determine what sprite to render for a given position. --- pos_x and pos_y are global coordinates. function get_tile(pos_x, pos_y) -- lookup changes in the change buffer local modded_sprite = mod_buffer[get_mod_key(pos_x, pos_y)]