Clean up a few functions and get ready for new features.
This commit is contained in:
parent
15c76c3884
commit
753700c144
38
index_map.md
Normal file
38
index_map.md
Normal file
|
@ -0,0 +1,38 @@
|
||||||
|
### 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 - long grass
|
||||||
|
|
||||||
|
### inventory icons
|
||||||
|
65 - wood
|
||||||
|
66 - mushroom
|
||||||
|
67 - cactus meat
|
||||||
|
|
||||||
|
### sfx
|
||||||
|
---
|
||||||
|
0 - noise effect for wind track (sfx 9)
|
||||||
|
1 - little bell
|
||||||
|
8 - desert music 1
|
||||||
|
9 - desert wind
|
||||||
|
10 - desert music 2
|
||||||
|
11 - chopping wood
|
||||||
|
12 - chopping vegetation
|
||||||
|
|
||||||
|
### patterns
|
||||||
|
---
|
||||||
|
0-1 - desert bgm (loops on 1)
|
23
mapgen.lua
23
mapgen.lua
|
@ -7,20 +7,7 @@ function init_mapgen()
|
||||||
|
|
||||||
-- Metadata for different biomes
|
-- Metadata for different biomes
|
||||||
-- frequencies don't have to add up to 100, but they should by convention
|
-- frequencies don't have to add up to 100, but they should by convention
|
||||||
--
|
-- tile_frequencies tuples are {frequency, sprite_index}, see index_map.md
|
||||||
-- Sprites are:
|
|
||||||
-- * 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
|
|
||||||
biome_data = {
|
biome_data = {
|
||||||
grassland = {
|
grassland = {
|
||||||
biome_frequency = 75,
|
biome_frequency = 75,
|
||||||
|
@ -92,17 +79,17 @@ end
|
||||||
|
|
||||||
-- determines which biome a given world map position should be,
|
-- determines which biome a given world map position should be,
|
||||||
-- returns the object out of the biome_data table
|
-- returns the object out of the biome_data table
|
||||||
function get_biome(pos)
|
function get_biome_name(pos)
|
||||||
local biome_pos = calculate_biome_pos(pos)
|
local biome_pos = calculate_biome_pos(pos)
|
||||||
local uid = generate_uid(biome_pos)
|
local uid = generate_uid(biome_pos)
|
||||||
local biome_name = biome_metadata[(uid % #biome_metadata) + 1]
|
return biome_metadata[(uid % #biome_metadata) + 1]
|
||||||
return biome_data[biome_name]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- determine what sprite to render for a given position.
|
-- determine what sprite to render for a given position.
|
||||||
-- todo: this needs the ability to have a list of 'changed' tiles to check against.
|
-- todo: this needs the ability to have a list of 'changed' tiles to check against.
|
||||||
function get_tile(pos)
|
function get_tile(pos)
|
||||||
local biome = get_biome(pos)
|
local biome_name = get_biome_name(pos)
|
||||||
|
local biome = biome_data[biome_name]
|
||||||
local uid = generate_uid(pos)
|
local uid = generate_uid(pos)
|
||||||
|
|
||||||
return biome["tile_lookup"][(uid % #biome["tile_lookup"]) + 1]
|
return biome["tile_lookup"][(uid % #biome["tile_lookup"]) + 1]
|
||||||
|
|
|
@ -88,6 +88,15 @@ end
|
||||||
function draw_player()
|
function draw_player()
|
||||||
spr(player_lookup[facing[1]][facing[2]], 64, 64)
|
spr(player_lookup[facing[1]][facing[2]], 64, 64)
|
||||||
-- todo: animate the character on move
|
-- todo: animate the character on move
|
||||||
|
|
||||||
|
-- draw the player's HUD
|
||||||
|
if fget(mget(player_pos[1], player_pos[2]), 1) then
|
||||||
|
-- flag 1 represents an interactable (read: destructible) sprite.
|
||||||
|
-- need a map of destructible map objects, appropriate sfx, replacement
|
||||||
|
-- sprites.
|
||||||
|
end
|
||||||
|
|
||||||
|
-- todo: introduce the concept of an inventory here
|
||||||
end
|
end
|
||||||
|
|
||||||
-- pos is camera position, meaning the map-relative player
|
-- pos is camera position, meaning the map-relative player
|
||||||
|
|
12
sfx_map.md
12
sfx_map.md
|
@ -1,12 +0,0 @@
|
||||||
### sfx
|
|
||||||
---
|
|
||||||
0 - noise effect for wind track (sfx 9)
|
|
||||||
1 - little bell
|
|
||||||
|
|
||||||
8 - desert music 1
|
|
||||||
9 - desert wind
|
|
||||||
10 - desert music 2
|
|
||||||
|
|
||||||
### patterns
|
|
||||||
---
|
|
||||||
0-1 - desert bgm (loops on 1)
|
|
Loading…
Reference in New Issue
Block a user