aka gravity ninja golf

initial commit

moth11.net 7ac511f6

+300
+4
.editorconfig
··· 1 + root = true 2 + 3 + [*] 4 + charset = utf-8
+2
.gitattributes
··· 1 + # Normalize EOL for all files that Git considers text files. 2 + * text=auto eol=lf
+3
.gitignore
··· 1 + # Godot 4+ specific ignores 2 + .godot/ 3 + /android/
InterDisplay-Regular.otf

This is a binary file and will not be displayed.

+35
InterDisplay-Regular.otf.import
··· 1 + [remap] 2 + 3 + importer="font_data_dynamic" 4 + type="FontFile" 5 + uid="uid://de0xvnawt57vs" 6 + path="res://.godot/imported/InterDisplay-Regular.otf-5b97aa42f9cafcf09014b0a1606c3b80.fontdata" 7 + 8 + [deps] 9 + 10 + source_file="res://InterDisplay-Regular.otf" 11 + dest_files=["res://.godot/imported/InterDisplay-Regular.otf-5b97aa42f9cafcf09014b0a1606c3b80.fontdata"] 12 + 13 + [params] 14 + 15 + Rendering=null 16 + antialiasing=1 17 + generate_mipmaps=false 18 + disable_embedded_bitmaps=true 19 + multichannel_signed_distance_field=false 20 + msdf_pixel_range=8 21 + msdf_size=48 22 + allow_system_fallback=true 23 + force_autohinter=false 24 + hinting=1 25 + subpixel_positioning=4 26 + keep_rounding_remainders=true 27 + oversampling=0.0 28 + Fallbacks=null 29 + fallbacks=[] 30 + Compress=null 31 + compress=true 32 + preload=[] 33 + language_support={} 34 + script_support={} 35 + opentype_features={}
+124
game.gd
··· 1 + extends Node2D 2 + 3 + var font = load("res://InterDisplay-Regular.otf") 4 + var ff = [] 5 + var pp = [] 6 + var vv = [] 7 + var start 8 + var heading 9 + var end 10 + var mp 11 + var t = 0 12 + 13 + const N_FIELDS = 32 14 + const N_POINTS = 30 15 + const BOUNDS = Rect2(0,0,1152,648) 16 + const SAFEBOUNDS = Rect2(648*.1, 648 *.1, 1152 - 648*.1, 648*.9) 17 + 18 + func _init(): 19 + ff.resize(N_FIELDS) 20 + for i in range(N_FIELDS): 21 + ff[i] = genfield() 22 + 23 + pp.resize(N_POINTS) 24 + for i in range(N_POINTS): 25 + pp[i] = genpoint() 26 + 27 + vv.resize(N_POINTS) 28 + vv.fill(Vector2.ZERO) 29 + 30 + var sne = genpoints(500, SAFEBOUNDS) 31 + start = Vector2(sne.x, sne.y) 32 + end = Vector2(sne.z, sne.w) 33 + heading = Vector2(1,0) 34 + mp = Vector2.ZERO 35 + 36 + func genpoints(target: float, within: Rect2 = BOUNDS, maxtries: int = 20) -> Vector4: 37 + var b1 = Vector2.ZERO 38 + var b2 = Vector2.ZERO 39 + var bd = 0 40 + for i in range(maxtries): 41 + var p1 = genpoint(within) 42 + var p2 = genpoint(within) 43 + var d = tDist(p1,p2).length() 44 + if d > bd: 45 + bd = d 46 + b1 = p1 47 + b2 = p2 48 + if d > target: 49 + break 50 + return Vector4(b1.x, b1.y, b2.x, b2.y) 51 + 52 + func _process(delta: float): 53 + t += delta 54 + if t > .24: 55 + $Mouse.sketch() 56 + t = 0 57 + 58 + mp = get_viewport().get_mouse_position() 59 + $Mouse.set_target(mp, delta) 60 + 61 + for i in range(N_POINTS): 62 + if randf() > vv[i].length(): 63 + pp[i]=genpoint() 64 + for f in ff: 65 + vv[i] += delta*force(pp[i],f) 66 + pp[i] = tNorm(pp[i] + delta*vv[i]) 67 + vv[i] *= .99 68 + queue_redraw() 69 + 70 + func _draw(): 71 + draw_string(font, start, "here", HORIZONTAL_ALIGNMENT_CENTER, -1, 16) 72 + draw_string(font, end, "there", HORIZONTAL_ALIGNMENT_CENTER, -1, 16) 73 + draw_line(start - heading.normalized()*4, start + heading.normalized()*4, Color.WHITE, 8) 74 + draw_line(end - heading.normalized()*4, end + heading.normalized()*4, Color.WHITE, 8) 75 + 76 + for i in range(N_POINTS): 77 + draw_line(pp[i], pp[i] + vv[i].normalized()*2, Color.WHITE, 2) 78 + 79 + 80 + 81 + 82 + func gencolor(p: Vector2, v: Vector2): 83 + var s = Vector2.ZERO 84 + for f in ff: 85 + s += force(p, f) 86 + var h = s.angle()/TAU 87 + 88 + return Color.from_ok_hsl(h, s.length()/100, .7) 89 + 90 + func genpoint(within: Rect2 = BOUNDS): 91 + return within.position + Vector2(randf()*within.size.x, randf()*within.size.y) 92 + 93 + func genfield(): 94 + var o = genpoint() 95 + var r = randfn(0,1000.0) 96 + var t = randf() * TAU 97 + return Vector4(o.x, o.y, r, t) 98 + 99 + func force(x: Vector2, f: Vector4): 100 + var o = Vector2(f.x,f.y) 101 + var r = f.z 102 + var t = f.w 103 + var dist = tDist(x, o) 104 + return dist.rotated(t)*r/dist.length_squared() 105 + 106 + func tDist(from: Vector2, to: Vector2): 107 + var dx = abs(to.x - from.x) 108 + var dy = abs(to.y - from.y) 109 + if dx > 0.5 * BOUNDS.size.x: 110 + dx = BOUNDS.size.x - dx 111 + if dy > 0.5 * BOUNDS.size.y: 112 + dy = BOUNDS.size.y - dy 113 + return Vector2(dx,dy) 114 + 115 + func tNorm(p: Vector2): 116 + if p.x < 0: 117 + p.x += BOUNDS.size.x 118 + if p.x > BOUNDS.size.x: 119 + p.x -= BOUNDS.size.x 120 + if p.y < 0: 121 + p.y += BOUNDS.size.y 122 + if p.y > BOUNDS.size.y: 123 + p.y -= BOUNDS.size.y 124 + return p
+1
game.gd.uid
··· 1 + uid://dynw8lf5xoin1
+14
game.tscn
··· 1 + [gd_scene load_steps=4 format=3 uid="uid://b2knoqyv0re16"] 2 + 3 + [ext_resource type="Script" uid="uid://dynw8lf5xoin1" path="res://game.gd" id="1_80nbo"] 4 + [ext_resource type="Script" uid="uid://bylorvm6k6ce7" path="res://mouse.gd" id="2_e2o6t"] 5 + [ext_resource type="Script" uid="uid://cvixjye57xwtt" path="res://here.gd" id="3_feb5d"] 6 + 7 + [node name="Node2D" type="Node2D"] 8 + script = ExtResource("1_80nbo") 9 + 10 + [node name="Mouse" type="Node2D" parent="."] 11 + script = ExtResource("2_e2o6t") 12 + 13 + [node name="Here" type="Node2D" parent="."] 14 + script = ExtResource("3_feb5d")
+1
here.gd
··· 1 + extends Node2D
+1
here.gd.uid
··· 1 + uid://cvixjye57xwtt
+1
icon.svg
··· 1 + <svg xmlns="http://www.w3.org/2000/svg" width="128" height="128"><rect width="124" height="124" x="2" y="2" fill="#363d52" stroke="#212532" stroke-width="4" rx="14"/><g fill="#fff" transform="translate(12.322 12.322)scale(.101)"><path d="M105 673v33q407 354 814 0v-33z"/><path fill="#478cbf" d="m105 673 152 14q12 1 15 14l4 67 132 10 8-61q2-11 15-15h162q13 4 15 15l8 61 132-10 4-67q3-13 15-14l152-14V427q30-39 56-81-35-59-83-108-43 20-82 47-40-37-88-64 7-51 8-102-59-28-123-42-26 43-46 89-49-7-98 0-20-46-46-89-64 14-123 42 1 51 8 102-48 27-88 64-39-27-82-47-48 49-83 108 26 42 56 81zm0 33v39c0 276 813 276 814 0v-39l-134 12-5 69q-2 10-14 13l-162 11q-12 0-16-11l-10-65H446l-10 65q-4 11-16 11l-162-11q-12-3-14-13l-5-69z"/><path d="M483 600c0 34 58 34 58 0v-86c0-34-58-34-58 0z"/><circle cx="725" cy="526" r="90"/><circle cx="299" cy="526" r="90"/></g><g fill="#414042" transform="translate(12.322 12.322)scale(.101)"><circle cx="307" cy="532" r="60"/><circle cx="717" cy="532" r="60"/></g></svg>
+37
icon.svg.import
··· 1 + [remap] 2 + 3 + importer="texture" 4 + type="CompressedTexture2D" 5 + uid="uid://djknq15wu1vnj" 6 + path="res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex" 7 + metadata={ 8 + "vram_texture": false 9 + } 10 + 11 + [deps] 12 + 13 + source_file="res://icon.svg" 14 + dest_files=["res://.godot/imported/icon.svg-218a8f2b3041327d8a5756f3a245f83b.ctex"] 15 + 16 + [params] 17 + 18 + compress/mode=0 19 + compress/high_quality=false 20 + compress/lossy_quality=0.7 21 + compress/hdr_compression=1 22 + compress/normal_map=0 23 + compress/channel_pack=0 24 + mipmaps/generate=false 25 + mipmaps/limit=-1 26 + roughness/mode=0 27 + roughness/src_normal="" 28 + process/fix_alpha_border=true 29 + process/premult_alpha=false 30 + process/normal_map_invert_y=false 31 + process/hdr_as_srgb=false 32 + process/hdr_clamp_exposure=false 33 + process/size_limit=0 34 + detect_3d/compress_to=1 35 + svg/scale=1.0 36 + editor/scale_with_editor_scale=false 37 + editor/convert_colors_with_editor_theme=false
+52
mouse.gd
··· 1 + extends Node2D 2 + 3 + var mousepoly: PackedVector2Array 4 + var mousecolors: PackedColorArray 5 + var basescale = 1.0 6 + var targetscale = Vector2.ONE 7 + 8 + func _process(delta: float): 9 + if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT): 10 + basescale = lerp(basescale, .8, delta*20) 11 + else: 12 + basescale = lerp(basescale, 1.0, delta*20) 13 + scale = targetscale * basescale 14 + pass 15 + 16 + func set_target(to: Vector2, delta: float): 17 + var diff = to - position 18 + rotation = diff.angle() 19 + targetscale = Vector2(1.0 + diff.length()/100, max(1.0 - diff.length()/400,.17)) 20 + 21 + position = lerp(position, to, delta * 17.0) 22 + pass 23 + 24 + func sketch(): 25 + mousepoly = genpolygon(11, 14.0, 1.0) 26 + queue_redraw() 27 + 28 + func _init(): 29 + mousepoly = genpolygon(11, 14.0, 1.0) 30 + mousecolors = PackedColorArray() 31 + mousecolors.resize(11) 32 + mousecolors.fill(Color.WHITE) 33 + 34 + func _draw(): 35 + draw_polygon(mousepoly, mousecolors) 36 + 37 + func genpolygon(n: int, radius: float, deviation: float): 38 + var rads = [] 39 + rads.resize(n) 40 + var rots = [] 41 + rots.resize(n) 42 + var rsum = 0 43 + for i in range(n): 44 + rads[i] = randfn(radius, deviation) 45 + rots[i] = rsum + randf() 46 + rsum = rots[i] 47 + var poly = PackedVector2Array() 48 + poly.resize(n) 49 + var randrot = randf() * TAU 50 + for i in range(n): 51 + poly[i] = Vector2(rads[i], 0).rotated(rots[i] / rsum * TAU + randrot) 52 + return poly
+1
mouse.gd.uid
··· 1 + uid://bylorvm6k6ce7
+24
project.godot
··· 1 + ; Engine configuration file. 2 + ; It's best edited using the editor UI and not directly, 3 + ; since the parameters that go here are not all obvious. 4 + ; 5 + ; Format: 6 + ; [section] ; section goes between [] 7 + ; param=value ; assign values to parameters 8 + 9 + config_version=5 10 + 11 + [application] 12 + 13 + config/name="momentoso" 14 + run/main_scene="uid://b2knoqyv0re16" 15 + config/features=PackedStringArray("4.4", "Forward Plus") 16 + config/icon="res://icon.svg" 17 + 18 + [display] 19 + 20 + window/stretch/mode="canvas_items" 21 + 22 + [rendering] 23 + 24 + environment/defaults/default_clear_color=Color(0, 0, 0, 1)