Added road map generation

This commit is contained in:
Segey Lapin
2019-08-18 01:30:06 +03:00
parent 22987eab72
commit f037043ca9
3 changed files with 1202 additions and 0 deletions

1153
proto2/autoloads/roadmap.gd Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,42 @@
extends Reference
class_name GridRule
func new_vertex(pos):
var v = {
"pos": pos,
"neighbors": [],
"seed": false
}
return v
func get_suggestion(rdata, v, b):
var pforward = 1.0
var pturn = 0.09
var lmin = 20.0
var lmax = 20.0
var suggestion = []
var wait = true
var prev = v.pos - v.neighbors[v.neighbors.size() - 1].pos
prev - prev.normalized()
var n = prev.tangent()
if n.length() < lmin:
n = n.normalized() * lmin
var vp = prev.normalized() * rand_range(lmin, lmax)
var rnd = rdata.randf()
if rnd <= pforward:
var sv = new_vertex(v.pos + vp)
sv.seed = true
suggestion.append(new_vertex(v.pos + vp))
wait = false
rnd = rdata.randf()
if rnd <= pturn * b * b:
suggestion.append(new_vertex(v.pos + n))
wait = true
rnd = rdata.randf()
if rnd <= pturn * b * b:
suggestion.append(new_vertex(v.pos - n))
wait = true
return suggestion

View File

@@ -19,6 +19,11 @@ _global_script_classes=[ {
"language": "GDScript",
"path": "res://ai/ball_game_ai3d.gd"
}, {
"base": "Reference",
"class": "GridRule",
"language": "GDScript",
"path": "res://growth_rules/grid.gd"
}, {
"base": "RigidBody",
"class": "Item",
"language": "GDScript",
@@ -47,6 +52,7 @@ _global_script_classes=[ {
_global_script_class_icons={
"BallGameAI": "",
"BallGameAI3D": "",
"GridRule": "",
"Item": "",
"Quest": "",
"QuestObjective": "",
@@ -64,6 +70,7 @@ world="*res://autoloads/world.gd"
controls="*res://autoloads/controls.gd"
characters="*res://autoloads/characters.gd"
notifications="*res://autoloads/notifications.gd"
roadmap="*res://autoloads/roadmap.gd"
[input]