Skip to content
Snippets Groups Projects
Commit 66374520 authored by dg's avatar dg
Browse files

water <-> grass tiles

git-svn-id: http://svn.net-core.org/repos/t-engine4@2335 51575b47-30f0-44d4-a5cc-537603b46e54
parent bd64a487
No related branches found
No related tags found
No related merge requests found
Showing
with 108 additions and 19 deletions
......@@ -48,9 +48,11 @@ end
function _M:addPond(x, y, spots)
local noise = core.noise.new(2, self.do_ponds.size.w, self.do_ponds.size.h)
local nmap = {}
local pmap = {}
local lowest = {v=100, x=nil, y=nil}
for i = 1, self.do_ponds.size.w do
nmap[i] = {}
pmap[i] = {}
for j = 1, self.do_ponds.size.h do
nmap[i][j] = noise:fbm_simplex(self.do_ponds.zoom * i / self.do_ponds.size.w, self.do_ponds.zoom * j / self.do_ponds.size.h, self.do_ponds.octave)
if nmap[i][j] < lowest.v then lowest.v = nmap[i][j]; lowest.x = i; lowest.y = j end
......@@ -76,7 +78,7 @@ function _M:addPond(x, y, spots)
local stop = true
for _ = 1, #self.do_ponds.pond do
if nmap[lx][ly] < split * self.do_ponds.pond[_][1] then
self.map(lx-1+x, ly-1+y, Map.TERRAIN, self:resolve(self.do_ponds.pond[_][2], self.grid_list, true))
pmap[lx][ly] = self.do_ponds.pond[_][2]
stop = false
break
end
......@@ -85,7 +87,6 @@ function _M:addPond(x, y, spots)
lx, ly = l()
end
end
for i = 1, self.do_ponds.size.w do
quadrant(i, 1)
quadrant(i, self.do_ponds.size.h)
......@@ -95,6 +96,39 @@ function _M:addPond(x, y, spots)
quadrant(self.do_ponds.size.w, i)
end
-- Smooth the pond
for i = 1, self.do_ponds.size.w do
for j = 1, self.do_ponds.size.h do
if not pmap[i][j] then
local nb = 0
for ii = -1, 1 do for jj = -1, 1 do if (ii ~= 0 or jj ~= 0) and pmap[i+ii] then
if pmap[i+ii][j+jj] then nb = nb + 1 end
end end end
if nb >= 4 then pmap[i][j] = self.do_ponds.pond[1][2] end
end
end
end
for i = 1, self.do_ponds.size.w do
for j = 1, self.do_ponds.size.h do
if pmap[i][j] then
local nb = 0
for ii = -1, 1 do for jj = -1, 1 do if (ii ~= 0 or jj ~= 0) and pmap[i+ii] then
if pmap[i+ii][j+jj] then nb = nb + 1 end
end end end
if nb <= 3 then pmap[i][j] = nil end
end
end
end
-- Draw the pond
for i = 1, self.do_ponds.size.w do
for j = 1, self.do_ponds.size.h do
if pmap[i][j] then
self.map(i-1+x, j-1+y, Map.TERRAIN, self:resolve(pmap[i][j], self.grid_list, true))
end
end
end
spots[#spots+1] = {x=x, y=y, type="pond", subtype="pond"}
end
......
......@@ -41,7 +41,7 @@ return {
do_ponds = {
nb = {1, 2},
size = {w=25, h=25},
pond = {{0.6, "DEEP_WATER"}, {0.8, "SHALLOW_WATER"}},
pond = {{0.6, "DEEP_WATER"}, {0.8, "DEEP_WATER"}},
},
},
actor = {
......
......@@ -102,3 +102,34 @@ end
function _M:niceTileReplace(level, i, j, g, nt)
self:replace(i, j, self:getTile(nt.base))
end
--- Make water have nice transition to other stuff
function _M:niceTileWater(level, i, j, g, nt)
local g8 = level.map:checkEntity(i, j-1, Map.TERRAIN, "subtype") or "water"
local g2 = level.map:checkEntity(i, j+1, Map.TERRAIN, "subtype") or "water"
local g4 = level.map:checkEntity(i-1, j, Map.TERRAIN, "subtype") or "water"
local g6 = level.map:checkEntity(i+1, j, Map.TERRAIN, "subtype") or "water"
local g7 = level.map:checkEntity(i-1, j-1, Map.TERRAIN, "subtype") or "water"
local g9 = level.map:checkEntity(i+1, j-1, Map.TERRAIN, "subtype") or "water"
local g1 = level.map:checkEntity(i-1, j+1, Map.TERRAIN, "subtype") or "water"
local g3 = level.map:checkEntity(i+1, j+1, Map.TERRAIN, "subtype") or "water"
-- Sides
if g4=="water" and g6=="water" and g8=="grass" then self:replace(i, j, self:getTile(nt.grass8))
elseif g4=="water" and g6=="water" and g2=="grass" then self:replace(i, j, self:getTile(nt.grass2))
elseif g8=="water" and g2=="water" and g4=="grass" then self:replace(i, j, self:getTile(nt.grass4))
elseif g8=="water" and g2=="water" and g6=="grass" then self:replace(i, j, self:getTile(nt.grass6))
-- Corners
elseif g4=="grass" and g7=="grass" and g8=="grass" then self:replace(i, j, self:getTile(nt.grass7))
elseif g4=="grass" and g1=="grass" and g2=="grass" then self:replace(i, j, self:getTile(nt.grass1))
elseif g2=="grass" and g3=="grass" and g6=="grass" then self:replace(i, j, self:getTile(nt.grass3))
elseif g6=="grass" and g9=="grass" and g8=="grass" then self:replace(i, j, self:getTile(nt.grass9))
-- Inner corners
elseif g4=="water" and g7=="grass" and g8=="water" then self:replace(i, j, self:getTile(nt.inner_grass3))
elseif g4=="water" and g1=="grass" and g2=="water" then self:replace(i, j, self:getTile(nt.inner_grass9))
elseif g2=="water" and g3=="grass" and g6=="water" then self:replace(i, j, self:getTile(nt.inner_grass7))
elseif g6=="water" and g9=="grass" and g8=="water" then self:replace(i, j, self:getTile(nt.inner_grass1))
-- Full
elseif g1=="water" and g2=="water" and g3=="water" and g4=="water" and g6=="water" and g7=="water" and g8=="water" and g9=="water" then self:replace(i, j, self:getTile(nt.water))
end
end
......@@ -19,6 +19,7 @@
newEntity{
define_as = "GRASS",
type = "floor", subtype = "grass",
name = "grass", image = "terrain/grass.png",
display = '.', color=colors.LIGHT_GREEN, back_color={r=44,g=95,b=43},
grow = "TREE",
......@@ -27,6 +28,7 @@ newEntity{
for i = 1, 20 do
newEntity{
define_as = "TREE"..(i > 1 and i or ""),
type = "wall", subtype = "grass",
name = "tree",
image = "terrain/grass.png",
add_displays = class:makeTrees("terrain/tree_alpha"),
......@@ -42,6 +44,7 @@ end
for i = 1, 20 do
newEntity{
define_as = "HARDTREE"..(i > 1 and i or ""),
type = "wall", subtype = "grass",
name = "tall thick tree",
image = "terrain/grass.png",
add_displays = class:makeTrees("terrain/tree_alpha"),
......@@ -56,6 +59,7 @@ end
newEntity{
define_as = "GRASS_DARK1",
type = "floor", subtype = "grass",
name = "grass", image = "terrain/grass_dark1.png",
display = '.', color=colors.GREEN, back_color={r=44,g=95,b=43},
grow = "TREE_DARK",
......@@ -64,6 +68,7 @@ newEntity{
for i = 1, 20 do
newEntity{
define_as = "TREE_DARK"..i,
type = "wall", subtype = "grass",
name = "tree", image = "terrain/grass_dark1.png",
force_clone = true,
add_displays = class:makeTrees("terrain/tree_dark_alpha"),
......@@ -79,6 +84,7 @@ end
for i = 1, 20 do
newEntity{
define_as = "HARDTREE_DARK"..i,
type = "wall", subtype = "grass",
name = "tall thick tree", image = "terrain/grass_dark1.png",
force_clone = true,
add_displays = class:makeTrees("terrain/tree_dark_alpha"),
......@@ -93,6 +99,7 @@ end
newEntity{
define_as = "FLOWER",
type = "floor", subtype = "grass",
name = "flower", image = "terrain/grass_flower3.png",
display = ';', color=colors.YELLOW, back_color={r=44,g=95,b=43},
grow = "TREE"
......@@ -100,6 +107,7 @@ newEntity{
newEntity{
define_as = "ROCK_VAULT",
type = "wall", subtype = "grass",
name = "huge lose rock", image = "terrain/grass.png", add_displays = {class.new{image="terrain/rock_grass.png"}},
display = '+', color=colors.GREY, back_color={r=44,g=95,b=43},
notice = true,
......@@ -114,6 +122,7 @@ newEntity{
newEntity{
define_as = "ROCK_VAULT_DARK",
type = "wall", subtype = "grass",
name = "huge loose rock", image = "terrain/rock_grass_dark.png",
display = '+', color=colors.GREY, back_color={r=44,g=95,b=43},
notice = true,
......@@ -131,6 +140,7 @@ newEntity{
-----------------------------------------
newEntity{
define_as = "GRASS_UP_WILDERNESS",
type = "floor", subtype = "grass",
name = "exit to the worldmap", image = "terrain/grass.png", add_displays = {class.new{image="terrain/worldmap.png"}},
display = '<', color_r=255, color_g=0, color_b=255,
always_remember = true,
......@@ -141,6 +151,7 @@ newEntity{
newEntity{
define_as = "GRASS_UP8",
type = "floor", subtype = "grass",
name = "way to the previous level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_8.png"}},
display = '<', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -149,6 +160,7 @@ newEntity{
}
newEntity{
define_as = "GRASS_UP2",
type = "floor", subtype = "grass",
name = "way to the previous level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_2.png"}},
display = '<', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -157,6 +169,7 @@ newEntity{
}
newEntity{
define_as = "GRASS_UP4",
type = "floor", subtype = "grass",
name = "way to the previous level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_4.png"}},
display = '<', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -165,6 +178,7 @@ newEntity{
}
newEntity{
define_as = "GRASS_UP6",
type = "floor", subtype = "grass",
name = "way to the previous level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_6.png"}},
display = '<', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -174,6 +188,7 @@ newEntity{
newEntity{
define_as = "GRASS_DOWN8",
type = "floor", subtype = "grass",
name = "way to the next level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_8.png"}},
display = '>', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -182,6 +197,7 @@ newEntity{
}
newEntity{
define_as = "GRASS_DOWN2",
type = "floor", subtype = "grass",
name = "way to the next level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_2.png"}},
display = '>', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -190,6 +206,7 @@ newEntity{
}
newEntity{
define_as = "GRASS_DOWN4",
type = "floor", subtype = "grass",
name = "way to the next level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_4.png"}},
display = '>', color_r=255, color_g=255, color_b=0,
notice = true,
......@@ -198,6 +215,7 @@ newEntity{
}
newEntity{
define_as = "GRASS_DOWN6",
type = "floor", subtype = "grass",
name = "way to the next level", image = "terrain/grass.png", add_displays = {class.new{image="terrain/way_next_6.png"}},
display = '>', color_r=255, color_g=255, color_b=0,
notice = true,
......
......@@ -76,30 +76,31 @@ newEntity{
------------------------------------------------------------
newEntity{
define_as = "SHALLOW_WATER",
name = "shallow water", image = "terrain/water_floor.png",
display = '~', color=colors.LIGHT_BLUE, back_color=colors.DARK_BLUE,
add_displays = class:makeWater(false),
always_remember = true,
}
newEntity{
define_as = "DEEP_WATER",
define_as = "WATER_BASE",
type = "floor", subtype = "water",
name = "deep water", image = "terrain/water_floor.png",
display = '~', color=colors.AQUAMARINE, back_color=colors.DARK_BLUE,
add_displays = class:makeWater(true),
always_remember = true,
air_level = -5, air_condition="water",
}
newEntity{
define_as = "POISON_SHALLOW_WATER",
name = "poisoned shallow water", image = "terrain/water_floor.png",
display = '~', color=colors.LIGHT_GREEN, back_color=colors.DARK_GREEN,
add_displays = class:makeWater(false, "poison_"),
always_remember = true,
newEntity{ base="WATER_BASE",
define_as = "DEEP_WATER",
add_displays = class:makeWater(true),
nice_tiler = { method="water",
water="WATER_GRASS_5", grass8={"WATER_GRASS_8", 100, 1, 2}, grass2={"WATER_GRASS_2", 100, 1, 2}, grass4={"WATER_GRASS_4", 100, 1, 2}, grass6={"WATER_GRASS_6", 100, 1, 2}, grass1={"WATER_GRASS_1", 100, 1, 2}, grass3={"WATER_GRASS_3", 100, 1, 2}, grass7={"WATER_GRASS_7", 100, 1, 2}, grass9={"WATER_GRASS_9", 100, 1, 2}, inner_grass1="WATER_GRASS_1I", inner_grass3="WATER_GRASS_3I", inner_grass7="WATER_GRASS_7I", inner_grass9="WATER_GRASS_9I"
},
}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_5", image="terrain/water_grass_5_1.png"}
for i = 1, 9 do for j = 1, 2 do
if i ~= 5 then newEntity{base="WATER_BASE", define_as = "WATER_GRASS_"..i..j, image="terrain/water_grass_"..i.."_"..j..".png"} end
end end
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_1I", image="terrain/water_grass_1i_1.png"}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_3I", image="terrain/water_grass_3i_1.png"}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_7I", image="terrain/water_grass_7i_1.png"}
newEntity{base="WATER_BASE", define_as = "WATER_GRASS_9I", image="terrain/water_grass_9i_1.png"}
newEntity{
define_as = "POISON_DEEP_WATER",
name = "poisoned deep water", image = "terrain/water_floor.png",
......@@ -109,6 +110,11 @@ newEntity{
air_level = -5, air_condition="water",
}
-----------------------------------------
-- Water/grass
-----------------------------------------
-----------------------------------------
-- Dungeony exits
-----------------------------------------
......
game/modules/tome/data/gfx/shockbolt/terrain/water_grass_1_1.png

9.02 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_1_2.png

8.86 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_1i_1.png

6.33 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_2_1.png

6.77 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_2_2.png

6.5 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_3_1.png

9.39 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_3_2.png

9.06 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_3i_1.png

5.91 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_4_1.png

6.87 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_4_2.png

6.71 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_5_1.png

2.83 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_6_1.png

7.71 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_6_2.png

7.57 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_7_1.png

9.31 KiB

game/modules/tome/data/gfx/shockbolt/terrain/water_grass_7_2.png

8.94 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment