New road generation: 2 networks with smoothly blended junctions, each nework a blend between low and high octave noises, for variable bendiness. Remove arrow block nodes. Remove unused river water nodes. Add detail to road texture. Improve tree textures. New screenshot

This commit is contained in:
paramat 2020-09-15 19:01:33 +01:00
parent f9f9458048
commit 313525f916
22 changed files with 136 additions and 147 deletions

View File

@ -1,6 +1,6 @@
driftgame 0.1.3 by paramat driftgame 0.1.4 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 Derived from the 'minipeli' game by paramat
Authors of media Authors of media
---------------- ----------------
@ -12,32 +12,30 @@ Description
----------- -----------
This game uses a simple road generating mapgen to provide a suitable demonstration environment for my vehicle mod 'driftcar'. This game uses a simple road generating mapgen to provide a suitable demonstration environment for my vehicle mod 'driftcar'.
The vehicle uses some physics modelling to create semi-realistic skidding and drifting behaviour. The vehicle uses some physics modelling to create semi-realistic skidding and drifting behaviour.
Many existing games are not suitable for 'driftcar' as they use intensive ABMs or other intensive code that interferes with the control response of the vehicle. Tyre grip is reduced on the grass nodes (nodes with the 'crumbly' group).
Smoke particles are emitted from each tyre when skidding.
Many existing games are not suitable as a demonstration environment for 'driftcar' as they use intensive ABMs or other intensive code that interferes with the control response of the vehicle.
Earlier versions of 'driftcar' mod Earlier versions of 'driftcar' mod
---------------------------------- ----------------------------------
'Driftcar' mod was previously released as a mod for 'Minetest Game' game. 'Driftcar' mod was previously released as a mod for 'Minetest Game' game.
The version in 'driftgame' game is an improved version and development of 'driftcar' will now continue in 'driftgame'. The version in 'driftgame' game is an improved version and development of 'driftcar' will now continue in 'driftgame'.
My GitHub repository for the 'Minetest Game' mod version will soon be deleted.
Using 'driftcar' mod outside this game Using 'driftcar' mod outside this game
-------------------------------------- --------------------------------------
This mod can be used in other Minetest games. This mod can be used in other Minetest games.
Keep in mind that the vehicle's tyre grip is reduced on nodes with the 'crumbly' group, so it is a good idea for road nodes to belong to the 'cracky' group. The vehicle's tyre grip is reduced on nodes with the 'crumbly' group, so it is a good idea for road nodes to belong to the 'cracky' group.
As mentioned earlier, the vehicle responds best when used in games that do not run intensive code while the vehicle is being driven. If a non-lightweght Lua mapgen is used it is best to pre-generate an area before driving in that area. The vehicle responds best when used in games that do not run intensive code while the vehicle is being driven. If a non-lightweght Lua mapgen is used it is best to pre-generate an area before driving in that area.
Using this game 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.
Third-person camera mode is recommended when driving for a better view. Third-person camera mode is recommended when driving for a better view.
Arrow blocks are provided to mark out courses if desired.
How to start playing this game How to start playing this game
------------------------------ ------------------------------
Core mapgen decoration placement must be disabled (because the registered decorations are placed by Lua code in the 'track' mod instead). This can be done in the 'All Settings' menu (Settings tab -> All Settings -> Mapgen -> Mapgen flags) or by adding the line below to your minetet.conf file:
mg_flags = caves,dungeons,light,nodecorations,biomes
Start a new world, the game will only allow 'Mapgen Flat' to be selected. Start a new world, the game will only allow 'Mapgen Flat' to be selected.
The optional features of Mapgen Flat: lakes and hills, should be left disabled. The optional features of Mapgen Flat: lakes and hills, should be left disabled.
@ -47,9 +45,9 @@ Type '/grantme all' to obtain all privileges.
Press 'K' to enable fly mode, and 'J' to enable fast mode. Press 'K' to enable fly mode, and 'J' to enable fast mode.
Fly fast to find some track. Fly fast to find a road.
Place the car on the track, enter it. Press 'F7' to use third-person camera mode. Place the car on the road, enter it. Press 'F7' to use third-person camera mode.
Car controls Car controls
------------ ------------
@ -61,3 +59,17 @@ Backward = Slow down.
Speed up when moving backwards. Speed up when moving backwards.
Left = Rotate anticlockwise. Left = Rotate anticlockwise.
Right = Rotate clockwise. Right = Rotate clockwise.
How this game was created
-------------------------
This game is derived from my 'minipeli' game.
Minipeli mods used unaltered:
gui
hand
light
player_api
Minipeli mods used and altered:
mapgen (Remove sounds folder. Remove sounds tables. Remove river water nodes as mapgen valleys is unused. Alias "mapgen_river_water_source" to "mapgen:water_source" to avoid warnings)
media (remove sounds folder)

View File

View File

@ -98,13 +98,13 @@ end
local car = { local car = {
initial_properties = { initial_properties = {
visual = "wielditem",
wield_item = "driftcar:blue_nodebox",
visual_size = {x = 1.667, y = 1.667}, -- Scale-up of nodebox is these * 1.5
collisionbox = {-0.53, -0.75, -0.53, 0.53, 0.75, 0.53},
stepheight = 0.6,
physical = true, physical = true,
collide_with_objects = false, collide_with_objects = false,
collisionbox = {-0.53, -0.75, -0.53, 0.53, 0.75, 0.53},
visual = "wielditem",
visual_size = {x = 1.667, y = 1.667}, -- Scale-up of nodebox is these * 1.5
textures = {"driftcar:blue_nodebox"},
stepheight = 0.6,
}, },
-- Custom fields -- Custom fields
@ -446,13 +446,19 @@ minetest.register_on_newplayer(function(player)
end) end)
-- Nodeboxes -- Nodebox
-- Smart Fortwo dim: L 2.695 W 1.663 H 1.555 -- If a nodebox exceeds {-0.5, -0.5, -0.5, 0.5, 0.5, 0.5}, the textures repeat and tile,
-- Size in pixels L 21.56 W 13.304 H 12.44 -- so the nodebox is defined within that volume and scaled-up using 'visual_size'.
-- Alter to L 20 W 12 H 12
-- 20 = full cube of unscaled nodebox, 1 pixel = 0.05 -- Smart Fortwo dimensions: L 2.695 W 1.663 H 1.555.
-- Required nodebox scale up 2.5, visual_size = 2.5 / 1.5 = 1.667 -- Size in world pixels (with 8px textures) L 21.56 W 13.304 H 12.44.
-- Alter to L 20 W 12 H 12 (2.5 nodes long).
-- 20 = full cube of unscaled nodebox, 1 pixel = 0.05.
-- Required nodebox scale-up 2.5.
-- 'wielditem'-visual entity 'visual_size' = 2.5 / 1.5 = 1.667, because a
-- 'wielditem'-visual entity is automatically scaled up by 1.5.
minetest.register_node("driftcar:blue_nodebox", { minetest.register_node("driftcar:blue_nodebox", {
description = "Drift Car Blue Nodebox", description = "Drift Car Blue Nodebox",

View File

@ -9,10 +9,4 @@ Various Minetest developers and contributors (LGPL 2.1)
Authors of media Authors of media
---------------- ----------------
BlockMen (CC BY-SA 3.0): All textures by paramat (CC BY-SA 3.0)
gui_formbg.png
gui_hb_bg.png
Paramat (CC BY-SA 3.0):
bubble.png
heart.png

View File

@ -1,21 +1,10 @@
-- Set formspec prepend and hotbar textures -- Set formspec prepended string, used for theming
minetest.register_on_joinplayer(function(player) minetest.register_on_joinplayer(function(player)
local formspec = [[ local formspec = [[
bgcolor[#080808BB;true] bgcolor[#080808BB;true]
listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF] ]] listcolors[#00000069;#5A5A5A;#141318;#30434C;#FFF]
local name = player:get_player_name() background[5,5;1,1;gui_formbg.png;true]
local info = minetest.get_player_information(name) ]]
if info.formspec_version > 1 then
formspec = formspec .. "background9[5,5;1,1;gui_formbg.png;true;10]"
else
formspec = formspec .. "background[5,5;1,1;gui_formbg.png;true]"
end
-- Set the string to be added to every mainmenu formspec, used for theming
player:set_formspec_prepend(formspec) player:set_formspec_prepend(formspec)
-- Set hotbar textures.
-- To use, uncomment these 2 lines and add textures to the textures folder.
--player:hud_set_hotbar_image("gui_hotbar.png")
--player:hud_set_hotbar_selected_image("gui_hotbar_selected.png")
end) end)

View File

@ -2,8 +2,8 @@ License of source code
---------------------- ----------------------
GNU Lesser General Public License, version 2.1 GNU Lesser General Public License, version 2.1
Copyright (C) 2019 celeron55, Perttu Ahola <celeron55@gmail.com> Copyright (C) 2011-2020 celeron55, Perttu Ahola <celeron55@gmail.com>
Copyright (C) 2019 Various Minetest developers and contributors Copyright (C) 2011-2020 Various Minetest developers and contributors
This program is free software; you can redistribute it and/or modify it under This program is free software; you can redistribute it and/or modify it under
the terms of the GNU Lesser General Public License as published by the Free the terms of the GNU Lesser General Public License as published by the Free
@ -21,8 +21,7 @@ License of media
---------------- ----------------
Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0) Attribution-ShareAlike 3.0 Unported (CC BY-SA 3.0)
Copyright (C) 2019 paramat Copyright (C) 2020 paramat
Copyright (C) 2019 BlockMen
You are free to: You are free to:
Share — copy and redistribute the material in any medium or format. Share — copy and redistribute the material in any medium or format.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 971 B

After

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 98 B

View File

@ -2,4 +2,4 @@ Minipeli mod: light
=================== ===================
Source code by paramat (MIT). Source code by paramat (MIT).
Media by paramat (CC BY-SA 3.0). Textures by paramat (CC BY-SA 3.0).

Binary file not shown.

Before

Width:  |  Height:  |  Size: 99 B

View File

@ -1,10 +1,4 @@
Minipeli mod: media Minipeli mod: media
=================== ===================
Authors of media
----------------
All textures by paramat (CC BY-SA 3.0). All textures by paramat (CC BY-SA 3.0).
sonictechtonic (CC BY 3.0):
https://www.freesound.org/people/sonictechtonic/sounds/241872/
player_damage.ogg

View File

@ -35,33 +35,3 @@ privacy, or moral rights may limit how you use the material.
For more details: For more details:
http://creativecommons.org/licenses/by-sa/3.0/ http://creativecommons.org/licenses/by-sa/3.0/
-----------------------
Attribution 3.0 Unported (CC BY 3.0)
Copyright (C) 2014 sonictechtonic
You are free to:
Share — copy and redistribute the material in any medium or format.
Adapt — remix, transform, and build upon the material for any purpose, even commercially.
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following terms:
Attribution — You must give appropriate credit, provide a link to the license, and
indicate if changes were made. You may do so in any reasonable manner, but not in any way
that suggests the licensor endorses you or your use.
No additional restrictions — You may not apply legal terms or technological measures that
legally restrict others from doing anything the license permits.
Notices:
You do not have to comply with the license for elements of the material in the public
domain or where your use is permitted by an applicable exception or limitation.
No warranties are given. The license may not give you all of the permissions necessary
for your intended use. For example, other rights such as publicity, privacy, or moral
rights may limit how you use the material.
For more details:
http://creativecommons.org/licenses/by/3.0/

Binary file not shown.

View File

@ -2,21 +2,54 @@
local pathy = 8 local pathy = 8
-- Noises blended to create 'path'
local np_patha = { local np_patha = {
offset = 0, offset = 0.0,
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.0,
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
}
-- Noises blended to create 'path2'
local np_pathc = {
offset = 0.0,
scale = 1,
spread = {x = 512, y = 512, z = 512},
seed = 7755,
octaves = 4,
persist = 0.6
}
local np_pathd = {
offset = 0.0,
scale = 1,
spread = {x = 512, y = 512, z = 512},
seed = 1001,
octaves = 1,
persist = 0.5
}
-- Blend between low and high octave noises
local np_blend = {
offset = 0.0,
scale = 6.0,
spread = {x = 256, y = 256, z = 256},
seed = 95059,
octaves = 1,
persist = 0.5 persist = 0.5
} }
@ -39,36 +72,12 @@ minetest.register_node("track:road_white", {
groups = {cracky = 3}, groups = {cracky = 3},
}) })
minetest.register_node("track:arrow_left", {
description = "Arrow Block Left",
tiles = {"track_red.png", "track_red.png",
"track_arrow_left.png", "track_red.png",
"track_red.png", "track_arrow_left.png"},
paramtype = "light",
light_source = 14,
paramtype2 = "facedir",
groups = {dig_immediate = 2},
})
minetest.register_node("track:arrow_right", { -- Set mapgen flags to disable core mapgen decoration placement.
description = "Arrow Block Right", -- Tree decorations are placed using the Lua Voxel Manipulator after track generation
tiles = {"track_red.png", "track_red.png", -- to avoid trees on track.
"track_arrow_left.png^[transformFX", "track_red.png",
"track_red.png", "track_arrow_left.png^[transformFX"},
paramtype = "light",
light_source = 14,
paramtype2 = "facedir",
groups = {dig_immediate = 2},
})
minetest.set_mapgen_setting("mg_flags", "caves,dungeons,light,nodecorations,biomes", true)
-- Give initial items
minetest.register_on_newplayer(function(player)
local inv = player:get_inventory()
inv:add_item("main", "track:arrow_left 512")
inv:add_item("main", "track:arrow_right 512")
end)
-- Constants -- Constants
@ -81,8 +90,14 @@ 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_pathc = nil
local nobj_pathd = nil
local nobj_blend = nil
local nvals_patha = {} local nvals_patha = {}
local nvals_pathb = {} local nvals_pathb = {}
local nvals_pathc = {}
local nvals_pathd = {}
local nvals_blend = {}
local data = {} local data = {}
@ -112,8 +127,14 @@ 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_pathc = nobj_pathc or minetest.get_perlin_map(np_pathc, pmapdims)
nobj_pathd = nobj_pathd or minetest.get_perlin_map(np_pathd, 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_pathc:get2dMap_flat(pmapminp, nvals_pathc)
nobj_pathd:get2dMap_flat(pmapminp, nvals_pathd)
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}
@ -121,28 +142,33 @@ minetest.register_on_generated(function(minp, maxp, seed)
-- Track brush centre generation area extends from x0/z0 - 4 to x1/z1 + 4 -- Track brush centre generation area extends from x0/z0 - 4 to x1/z1 + 4
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
local ni = 1 + (z - (z0 - 5)) * pmapdim + 1 local ni = 1 + (z - (z0 - 5)) * pmapdim + 1
local n_xprepatha = nvals_patha[(ni - 1)] -- Initial blend, n_path and n_path2 values for adjacent node at x0 - 5
local n_xprepathb = nvals_pathb[(ni - 1)] local xpreblend = (math.tanh(nvals_blend[(ni - 1)]) + 1) / 2
local n_xprepath = (1 - xpreblend) * nvals_patha[(ni - 1)] +
xpreblend * nvals_pathb[(ni - 1)]
local n_xprepath2 = (1 - xpreblend) * nvals_pathc[(ni - 1)] +
xpreblend * nvals_pathd[(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_path2 = (1 - blend) * nvals_pathc[ni] + blend * nvals_pathd[ni]
local n_zprepathb = nvals_pathb[(ni - pmapdim)] -- blend, n_path and n_path2 values for adjacent node at z - 1
-- Detect sign change of noise local zpreblend = (math.tanh(nvals_blend[(ni - pmapdim)]) + 1) / 2
if (n_patha >= 0 and n_xprepatha < 0) local n_zprepath = (1 - zpreblend) * nvals_patha[(ni - pmapdim)] +
or (n_patha < 0 and n_xprepatha >= 0) zpreblend * nvals_pathb[(ni - pmapdim)]
or (n_patha >= 0 and n_zprepatha < 0) local n_zprepath2 = (1 - zpreblend) * nvals_pathc[(ni - pmapdim)] +
or (n_patha < 0 and n_zprepatha >= 0) zpreblend * nvals_pathd[(ni - pmapdim)]
-- Detect sign change of n_path and n_path2 in x, z directions
or (n_pathb >= 0 and n_xprepathb < 0) if (n_path * n_xprepath < 0)
or (n_pathb < 0 and n_xprepathb >= 0) or (n_path * n_zprepath < 0)
or (n_pathb >= 0 and n_zprepathb < 0) or (n_path2 * n_xprepath2 < 0)
or (n_pathb < 0 and n_zprepathb >= 0) or (n_path2 * n_zprepath2 < 0)
-- Smooth corners of junctions -- Detect when n_path and n_path2 are simultaneously
or math.pow(math.abs(n_patha), 0.1) * -- very small, to smooth corners of junctions
math.pow(math.abs(n_pathb), 0.1) < 0.5 then or math.pow(math.abs(n_path), 0.1) *
math.pow(math.abs(n_path2), 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 -- Set adjacent node values to current values
n_xprepathb = n_pathb n_xprepath = n_path
n_xprepath2 = n_path2
end end
end end

Binary file not shown.

Before

Width:  |  Height:  |  Size: 96 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

After

Width:  |  Height:  |  Size: 124 B

View File

@ -2,7 +2,4 @@ driftgame mod: trees
==================== ====================
Source code by paramat (MIT). Source code by paramat (MIT).
Schematics by paramat (CC BY-SA 3.0). Textures and schematics by paramat (CC BY-SA 3.0).
All textures by paramat (CC BY-SA 3.0) and derived from Minetest Game textures by
paramat (CC BY-SA 3.0), except:
trees_pine_needles.png is derived from a Minetest Game texture by Splizard (CC BY-SA 3.0).

View File

@ -34,6 +34,7 @@ minetest.register_decoration({
octaves = 3, octaves = 3,
persist = 0.7 persist = 0.7
}, },
biomes = {"grassland"},
y_min = -31000, y_min = -31000,
y_max = 31000, y_max = 31000,
schematic = minetest.get_modpath("trees").."/schematics/trees_pine_tree.mts", schematic = minetest.get_modpath("trees").."/schematics/trees_pine_tree.mts",

Binary file not shown.

Before

Width:  |  Height:  |  Size: 506 B

After

Width:  |  Height:  |  Size: 102 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 161 B

After

Width:  |  Height:  |  Size: 103 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 30 KiB

After

Width:  |  Height:  |  Size: 18 KiB