Change trackgen to blending between single-octave and multi-octave noise, for variable bendiness. Offset track brush trigger value to create looping tracks
This commit is contained in:
parent
9828a843b6
commit
34d3d6eb45
@ -1,4 +1,4 @@
|
|||||||
driftgame 0.1.1 by paramat
|
driftgame 0.1.2 by paramat
|
||||||
A game for Minetest Engine 5.2.0 and later
|
A game for Minetest Engine 5.2.0 and later
|
||||||
Built on the 'minipeli' game by paramat
|
Built on the 'minipeli' game by paramat
|
||||||
|
|
||||||
@ -12,7 +12,6 @@ Using this game
|
|||||||
---------------
|
---------------
|
||||||
Due to client->server->client control delay it is recommended that this game is used in singleplayer or in local multiplayer.
|
Due to client->server->client control delay it is recommended that this game is used in singleplayer or in local multiplayer.
|
||||||
Generation of new areas of world may slightly affect the control response of the vehicle, the best control response will occur in previously generated areas.
|
Generation of new areas of world may slightly affect the control response of the vehicle, the best control response will occur in previously generated areas.
|
||||||
Left arrow and right arrow blocks are given to a new player to mark out a race track.
|
|
||||||
Third-person camera mode is recommended when driving for a better view.
|
Third-person camera mode is recommended when driving for a better view.
|
||||||
|
|
||||||
How to start playing this game
|
How to start playing this game
|
||||||
|
@ -206,7 +206,7 @@ minetest.register_biome({
|
|||||||
node_top = "mapgen:grass",
|
node_top = "mapgen:grass",
|
||||||
depth_top = 1,
|
depth_top = 1,
|
||||||
node_filler = "mapgen:dirt",
|
node_filler = "mapgen:dirt",
|
||||||
depth_filler = 1,
|
depth_filler = 2,
|
||||||
node_riverbed = "mapgen:sand",
|
node_riverbed = "mapgen:sand",
|
||||||
depth_riverbed = 2,
|
depth_riverbed = 2,
|
||||||
node_cave_liquid = "mapgen:water_source",
|
node_cave_liquid = "mapgen:water_source",
|
||||||
|
@ -3,20 +3,29 @@
|
|||||||
local pathy = 8
|
local pathy = 8
|
||||||
|
|
||||||
local np_patha = {
|
local np_patha = {
|
||||||
offset = 0,
|
offset = -0.2,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x = 256, y = 256, z = 256},
|
spread = {x = 384, y = 384, z = 384},
|
||||||
seed = 11711,
|
seed = 11711,
|
||||||
octaves = 3,
|
octaves = 4,
|
||||||
persist = 0.5
|
persist = 0.6
|
||||||
}
|
}
|
||||||
|
|
||||||
local np_pathb = {
|
local np_pathb = {
|
||||||
offset = 0,
|
offset = -0.2,
|
||||||
scale = 1,
|
scale = 1,
|
||||||
spread = {x = 256, y = 256, z = 256},
|
spread = {x = 384, y = 384, z = 384},
|
||||||
seed = 303,
|
seed = 303,
|
||||||
octaves = 3,
|
octaves = 1,
|
||||||
|
persist = 0.5
|
||||||
|
}
|
||||||
|
|
||||||
|
local np_blend = {
|
||||||
|
offset = 0.0,
|
||||||
|
scale = 6.0,
|
||||||
|
spread = {x = 192, y = 192, z = 192},
|
||||||
|
seed = 95059,
|
||||||
|
octaves = 1,
|
||||||
persist = 0.5
|
persist = 0.5
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +51,7 @@ minetest.register_node("track:road_white", {
|
|||||||
minetest.register_node("track:arrow_left", {
|
minetest.register_node("track:arrow_left", {
|
||||||
description = "Arrow Block Left",
|
description = "Arrow Block Left",
|
||||||
tiles = {"track_red.png", "track_red.png",
|
tiles = {"track_red.png", "track_red.png",
|
||||||
"track_red.png", "track_red.png",
|
"track_arrow_left.png", "track_red.png",
|
||||||
"track_red.png", "track_arrow_left.png"},
|
"track_red.png", "track_arrow_left.png"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
@ -53,7 +62,7 @@ minetest.register_node("track:arrow_left", {
|
|||||||
minetest.register_node("track:arrow_right", {
|
minetest.register_node("track:arrow_right", {
|
||||||
description = "Arrow Block Right",
|
description = "Arrow Block Right",
|
||||||
tiles = {"track_red.png", "track_red.png",
|
tiles = {"track_red.png", "track_red.png",
|
||||||
"track_red.png", "track_red.png",
|
"track_arrow_left.png^[transformFX", "track_red.png",
|
||||||
"track_red.png", "track_arrow_left.png^[transformFX"},
|
"track_red.png", "track_arrow_left.png^[transformFX"},
|
||||||
paramtype = "light",
|
paramtype = "light",
|
||||||
light_source = 14,
|
light_source = 14,
|
||||||
@ -81,8 +90,10 @@ local c_roadwhite = minetest.get_content_id("track:road_white")
|
|||||||
|
|
||||||
local nobj_patha = nil
|
local nobj_patha = nil
|
||||||
local nobj_pathb = nil
|
local nobj_pathb = nil
|
||||||
|
local nobj_blend = nil
|
||||||
local nvals_patha = {}
|
local nvals_patha = {}
|
||||||
local nvals_pathb = {}
|
local nvals_pathb = {}
|
||||||
|
local nvals_blend = {}
|
||||||
local data = {}
|
local data = {}
|
||||||
|
|
||||||
|
|
||||||
@ -112,8 +123,10 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
|
|
||||||
nobj_patha = nobj_patha or minetest.get_perlin_map(np_patha, pmapdims)
|
nobj_patha = nobj_patha or minetest.get_perlin_map(np_patha, pmapdims)
|
||||||
nobj_pathb = nobj_pathb or minetest.get_perlin_map(np_pathb, pmapdims)
|
nobj_pathb = nobj_pathb or minetest.get_perlin_map(np_pathb, pmapdims)
|
||||||
|
nobj_blend = nobj_blend or minetest.get_perlin_map(np_blend, pmapdims)
|
||||||
nobj_patha:get2dMap_flat(pmapminp, nvals_patha)
|
nobj_patha:get2dMap_flat(pmapminp, nvals_patha)
|
||||||
nobj_pathb:get2dMap_flat(pmapminp, nvals_pathb)
|
nobj_pathb:get2dMap_flat(pmapminp, nvals_pathb)
|
||||||
|
nobj_blend:get2dMap_flat(pmapminp, nvals_blend)
|
||||||
|
|
||||||
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
local vm, emin, emax = minetest.get_mapgen_object("voxelmanip")
|
||||||
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
local area = VoxelArea:new{MinEdge = emin, MaxEdge = emax}
|
||||||
@ -123,26 +136,39 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
for z = z0 - 4, z1 + 4 do
|
for z = z0 - 4, z1 + 4 do
|
||||||
-- Initial noise index at x0 - 4 for this z
|
-- Initial noise index at x0 - 4 for this z
|
||||||
local ni = 1 + (z - (z0 - 5)) * pmapdim + 1
|
local ni = 1 + (z - (z0 - 5)) * pmapdim + 1
|
||||||
local n_xprepatha = nvals_patha[(ni - 1)]
|
local xpreblend = (math.tanh(nvals_blend[(ni - 1)]) + 1) / 2
|
||||||
local n_xprepathb = nvals_pathb[(ni - 1)]
|
local n_xprepath = (1 - xpreblend) * nvals_patha[(ni - 1)] +
|
||||||
|
xpreblend * nvals_pathb[(ni - 1)]
|
||||||
|
--local n_xprepatha = nvals_patha[(ni - 1)]
|
||||||
|
--local n_xprepathb = nvals_pathb[(ni - 1)]
|
||||||
for x = x0 - 4, x1 + 4 do
|
for x = x0 - 4, x1 + 4 do
|
||||||
local n_patha = nvals_patha[ni]
|
local blend = (math.tanh(nvals_blend[ni]) + 1) / 2
|
||||||
local n_pathb = nvals_pathb[ni]
|
local n_path = (1 - blend) * nvals_patha[ni] + blend * nvals_pathb[ni]
|
||||||
local n_zprepatha = nvals_patha[(ni - pmapdim)]
|
--local n_patha = nvals_patha[ni]
|
||||||
local n_zprepathb = nvals_pathb[(ni - pmapdim)]
|
--local n_pathb = nvals_pathb[ni]
|
||||||
|
local zpreblend = (math.tanh(nvals_blend[(ni - pmapdim)]) + 1) / 2
|
||||||
|
local n_zprepath = (1 - zpreblend) * nvals_patha[(ni - pmapdim)] +
|
||||||
|
zpreblend * nvals_pathb[(ni - pmapdim)]
|
||||||
|
--local n_zprepatha = nvals_patha[(ni - pmapdim)]
|
||||||
|
--local n_zprepathb = nvals_pathb[(ni - pmapdim)]
|
||||||
-- Detect sign change of noise
|
-- Detect sign change of noise
|
||||||
if (n_patha >= 0 and n_xprepatha < 0)
|
if (n_path >= 0 and n_xprepath < 0)
|
||||||
or (n_patha < 0 and n_xprepatha >= 0)
|
or (n_path < 0 and n_xprepath >= 0)
|
||||||
or (n_patha >= 0 and n_zprepatha < 0)
|
or (n_path >= 0 and n_zprepath < 0)
|
||||||
or (n_patha < 0 and n_zprepatha >= 0)
|
or (n_path < 0 and n_zprepath >= 0) then
|
||||||
|
|
||||||
or (n_pathb >= 0 and n_xprepathb < 0)
|
--(n_patha >= 0 and n_xprepatha < 0)
|
||||||
or (n_pathb < 0 and n_xprepathb >= 0)
|
--or (n_patha < 0 and n_xprepatha >= 0)
|
||||||
or (n_pathb >= 0 and n_zprepathb < 0)
|
--or (n_patha >= 0 and n_zprepatha < 0)
|
||||||
or (n_pathb < 0 and n_zprepathb >= 0)-- then
|
--or (n_patha < 0 and n_zprepatha >= 0)
|
||||||
|
|
||||||
|
--or (n_pathb >= 0 and n_xprepathb < 0)
|
||||||
|
--or (n_pathb < 0 and n_xprepathb >= 0)
|
||||||
|
--or (n_pathb >= 0 and n_zprepathb < 0)
|
||||||
|
--or (n_pathb < 0 and n_zprepathb >= 0)
|
||||||
-- Smooth corners of junctions
|
-- Smooth corners of junctions
|
||||||
or math.pow(math.abs(n_patha), 0.1) *
|
--or math.pow(math.abs(n_patha), 0.1) *
|
||||||
math.pow(math.abs(n_pathb), 0.1) < 0.5 then
|
--math.pow(math.abs(n_pathb), 0.1) < 0.5 then
|
||||||
-- Place track brush of radius 4
|
-- Place track brush of radius 4
|
||||||
for k = -4, 4 do
|
for k = -4, 4 do
|
||||||
local vi = area:index(x - 4, pathy, z + k)
|
local vi = area:index(x - 4, pathy, z + k)
|
||||||
@ -162,8 +188,9 @@ minetest.register_on_generated(function(minp, maxp, seed)
|
|||||||
end
|
end
|
||||||
|
|
||||||
ni = ni + 1
|
ni = ni + 1
|
||||||
n_xprepatha = n_patha
|
n_xprepath = n_path
|
||||||
n_xprepathb = n_pathb
|
--n_xprepatha = n_patha
|
||||||
|
--n_xprepathb = n_pathb
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user