Refactored a bit, add Globals class and isolate some things better
This commit is contained in:
parent
ae9ac2ac59
commit
8ac387076a
17
README.md
17
README.md
@ -1,3 +1,16 @@
|
||||
# gmtk-2025-loop
|
||||
# doodle game concept
|
||||
A game about using your finger/mouse to draw circles around moving game objects.
|
||||
It works by instantiating an `Area2D` node with a polygon collision shape, and can probably
|
||||
also be mildly modified to draw level geometry dynamically.
|
||||
|
||||
GMTK game jam, 2025. Theme: Loop
|
||||
In either case, the challenge is taming an otherwise automatic system.
|
||||
Objects move on their own. You only control the pencil.
|
||||
|
||||
## Current questions
|
||||
* Should it be about capturing only the correct game entities?
|
||||
* Should it be about drawing level geometry to guide game entities to a goal?
|
||||
|
||||
## Current definites
|
||||
* Doodles-in-the-margins lined paper aesthetic
|
||||
* 2px outlines, simple colors
|
||||
* Can likely use shaders to make it appear slightly sketchy and animated
|
||||
|
||||
BIN
assets/sprites/pencil.png
Normal file
BIN
assets/sprites/pencil.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 781 B |
34
assets/sprites/pencil.png.import
Normal file
34
assets/sprites/pencil.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://ds5ybi21d52yw"
|
||||
path="res://.godot/imported/pencil.png-1694d319d2e5ca8709382e64ef0add14.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/pencil.png"
|
||||
dest_files=["res://.godot/imported/pencil.png-1694d319d2e5ca8709382e64ef0add14.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/textures/lined-paper.png
Normal file
BIN
assets/textures/lined-paper.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 91 KiB |
34
assets/textures/lined-paper.png.import
Normal file
34
assets/textures/lined-paper.png.import
Normal file
@ -0,0 +1,34 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c7en2ehk2mvk0"
|
||||
path="res://.godot/imported/lined-paper.png-89bb2c80a7f89cfdfb7c268868425ebe.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/textures/lined-paper.png"
|
||||
dest_files=["res://.godot/imported/lined-paper.png-89bb2c80a7f89cfdfb7c268868425ebe.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/hdr_compression=1
|
||||
compress/normal_map=0
|
||||
compress/channel_pack=0
|
||||
mipmaps/generate=false
|
||||
mipmaps/limit=-1
|
||||
roughness/mode=0
|
||||
roughness/src_normal=""
|
||||
process/fix_alpha_border=true
|
||||
process/premult_alpha=false
|
||||
process/normal_map_invert_y=false
|
||||
process/hdr_as_srgb=false
|
||||
process/hdr_clamp_exposure=false
|
||||
process/size_limit=0
|
||||
detect_3d/compress_to=1
|
||||
BIN
assets/textures/lined-paper.xcf
Normal file
BIN
assets/textures/lined-paper.xcf
Normal file
Binary file not shown.
@ -11,10 +11,27 @@ config_version=5
|
||||
[application]
|
||||
|
||||
config/name="GMTK 2025 Loop"
|
||||
run/main_scene="uid://by78isronsqtp"
|
||||
config/features=PackedStringArray("4.4", "GL Compatibility")
|
||||
config/icon="res://icon.svg"
|
||||
|
||||
[autoload]
|
||||
|
||||
SceneManager="*res://scripts/SceneManager.gd"
|
||||
Globals="*res://scripts/Globals.gd"
|
||||
|
||||
[display]
|
||||
|
||||
window/size/viewport_width=960
|
||||
window/size/viewport_height=540
|
||||
window/stretch/mode="viewport"
|
||||
|
||||
[global_group]
|
||||
|
||||
collectable=""
|
||||
|
||||
[rendering]
|
||||
|
||||
renderer/rendering_method="gl_compatibility"
|
||||
renderer/rendering_method.mobile="gl_compatibility"
|
||||
environment/defaults/default_clear_color=Color(0.12549, 0.12549, 0.12549, 1)
|
||||
|
||||
45
scenes/debug.tscn
Normal file
45
scenes/debug.tscn
Normal file
@ -0,0 +1,45 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c1w3l5dyo0mrk"]
|
||||
|
||||
[sub_resource type="GDScript" id="GDScript_8neu0"]
|
||||
script/source = "extends VBoxContainer
|
||||
|
||||
@onready var mouse_loop_button = $ScrollContainer/VBoxContainer/MouseLoop
|
||||
@onready var mouse_fling_button = $ScrollContainer/VBoxContainer/MouseFling
|
||||
|
||||
const SCENE_MOUSE_LOOP = preload(\"res://scenes/debug/MouseLoop.tscn\")
|
||||
const SCENE_MOUSE_FLING = preload(\"res://scenes/debug/MouseFling.tscn\")
|
||||
|
||||
func _on_mouse_loop_pressed() -> void:
|
||||
SceneManager.change_scene(SCENE_MOUSE_LOOP)
|
||||
|
||||
func _on_mouse_fling_pressed() -> void:
|
||||
SceneManager.change_scene(SCENE_MOUSE_FLING)
|
||||
"
|
||||
|
||||
[node name="Debug" type="VBoxContainer"]
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
script = SubResource("GDScript_8neu0")
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label" type="Label" parent="CenterContainer"]
|
||||
layout_mode = 2
|
||||
text = "Debug Menu"
|
||||
|
||||
[node name="ScrollContainer" type="ScrollContainer" parent="."]
|
||||
layout_mode = 2
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="ScrollContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="MouseLoop" type="Button" parent="ScrollContainer/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
text = "Mouse Loop"
|
||||
|
||||
[connection signal="pressed" from="ScrollContainer/VBoxContainer/MouseLoop" to="." method="_on_mouse_loop_pressed"]
|
||||
3
scenes/debug/MouseFling.tscn
Normal file
3
scenes/debug/MouseFling.tscn
Normal file
@ -0,0 +1,3 @@
|
||||
[gd_scene format=3 uid="uid://cp2qdqu5ti42c"]
|
||||
|
||||
[node name="MouseFling" type="Node2D"]
|
||||
70
scenes/debug/MouseLoop.gd
Normal file
70
scenes/debug/MouseLoop.gd
Normal file
@ -0,0 +1,70 @@
|
||||
extends Node2D
|
||||
|
||||
@onready var CURSOR = $Cursor
|
||||
|
||||
func _ready() -> void:
|
||||
for x in range(64, get_viewport_rect().size.x, 96):
|
||||
for y in range(64, get_viewport_rect().size.y, 96):
|
||||
var c = Globals.SCENE_COLLECTABLE.instantiate()
|
||||
c.global_position = Vector2(x, y)
|
||||
if randf() < .2:
|
||||
c.is_bad = true
|
||||
add_child(c)
|
||||
$Camera2D.position = get_viewport_rect().size / 2
|
||||
|
||||
func _draw() -> void:
|
||||
var trail = CURSOR.get_tail(Globals.HISTORY_LENGTH)
|
||||
|
||||
if trail.size() <= 0:
|
||||
return
|
||||
|
||||
for i in range(trail.size() - 1):
|
||||
var color
|
||||
if trail.size() > Globals.HISTORY_LENGTH * .66:
|
||||
color = Color(.5,0,0,1)
|
||||
elif trail.size() > Globals.HISTORY_LENGTH * .33:
|
||||
color = Color(.5,.5,0,1)
|
||||
else:
|
||||
color = Color(0,.5,0,1)
|
||||
draw_line(trail[i], trail[i + 1], color , Globals.LINE_THICC, false)
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
queue_redraw()
|
||||
|
||||
while CURSOR.loop_stack.size() > 0:
|
||||
var loop = CURSOR.loop_stack.pop_back()
|
||||
create_loop_object(loop)
|
||||
|
||||
func create_loop_object(loop:Array):
|
||||
var scene = Globals.SCENE_LOOP.instantiate()
|
||||
var polygon_collider = scene.get_node("PolygonCollision") as CollisionPolygon2D
|
||||
polygon_collider.polygon = PackedVector2Array(loop)
|
||||
add_child(scene)
|
||||
await get_tree().create_timer(.2).timeout
|
||||
var contents = scene.get_contained_nodes()
|
||||
get_tree().queue_delete(scene)
|
||||
print(contents)
|
||||
var collectables = get_tree().get_nodes_in_group("collectable")
|
||||
for i in contents:
|
||||
if not (i in collectables):
|
||||
continue
|
||||
if i.is_bad:
|
||||
print("ouch")
|
||||
i.remove()
|
||||
else:
|
||||
i.remove()
|
||||
|
||||
func _on_cursor_started_drawing(pos:Vector2) -> void:
|
||||
print("started drawing")
|
||||
var cam = get_viewport().get_camera_2d()
|
||||
var t = get_tree().create_tween()
|
||||
t.tween_property(Engine, "time_scale", 0.2, .2)
|
||||
$StartMarker.global_position = pos
|
||||
$StartMarker.visible = true
|
||||
|
||||
func _on_cursor_stopped_drawing() -> void:
|
||||
print("stopped drawing")
|
||||
var cam = get_viewport().get_camera_2d()
|
||||
var t = get_tree().create_tween()
|
||||
t.tween_property(Engine, "time_scale", 1.0, .2)
|
||||
$StartMarker.visible = false
|
||||
1
scenes/debug/MouseLoop.gd.uid
Normal file
1
scenes/debug/MouseLoop.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b1ddnopgn4scy
|
||||
63
scenes/debug/MouseLoop.tscn
Normal file
63
scenes/debug/MouseLoop.tscn
Normal file
@ -0,0 +1,63 @@
|
||||
[gd_scene load_steps=9 format=3 uid="uid://d1bduqxqx10jb"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b1ddnopgn4scy" path="res://scenes/debug/MouseLoop.gd" id="1_x04i4"]
|
||||
[ext_resource type="PackedScene" uid="uid://byipv4uqxdtfk" path="res://scenes/objects/Cursor.tscn" id="3_aaj44"]
|
||||
[ext_resource type="Texture2D" uid="uid://c7en2ehk2mvk0" path="res://assets/textures/lined-paper.png" id="3_u4ca0"]
|
||||
[ext_resource type="PackedScene" uid="uid://dnr505je252gd" path="res://scenes/objects/StartMarker.tscn" id="4_u4ca0"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_va2mg"]
|
||||
size = Vector2(100, 591)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_aaj44"]
|
||||
size = Vector2(1025, 219.5)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_u4ca0"]
|
||||
size = Vector2(152.5, 717.75)
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_olkr6"]
|
||||
size = Vector2(1263.25, 220.875)
|
||||
|
||||
[node name="MouseLoop" type="Node2D"]
|
||||
script = ExtResource("1_x04i4")
|
||||
|
||||
[node name="Cursor" parent="." instance=ExtResource("3_aaj44")]
|
||||
z_index = 1
|
||||
|
||||
[node name="Walls" type="StaticBody2D" parent="."]
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Walls"]
|
||||
position = Vector2(-51, 289)
|
||||
shape = SubResource("RectangleShape2D_va2mg")
|
||||
|
||||
[node name="CollisionShape2D2" type="CollisionShape2D" parent="Walls"]
|
||||
position = Vector2(449.5, 650.75)
|
||||
shape = SubResource("RectangleShape2D_aaj44")
|
||||
|
||||
[node name="CollisionShape2D3" type="CollisionShape2D" parent="Walls"]
|
||||
position = Vector2(1034.75, 338.125)
|
||||
shape = SubResource("RectangleShape2D_u4ca0")
|
||||
|
||||
[node name="CollisionShape2D4" type="CollisionShape2D" parent="Walls"]
|
||||
position = Vector2(500.375, -109.438)
|
||||
shape = SubResource("RectangleShape2D_olkr6")
|
||||
|
||||
[node name="Camera2D" type="Camera2D" parent="."]
|
||||
|
||||
[node name="TextureRect" type="TextureRect" parent="."]
|
||||
z_index = -1
|
||||
custom_minimum_size = Vector2(960, 540)
|
||||
anchors_preset = 15
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
offset_right = 960.0
|
||||
offset_bottom = 540.0
|
||||
grow_horizontal = 2
|
||||
grow_vertical = 2
|
||||
texture = ExtResource("3_u4ca0")
|
||||
stretch_mode = 1
|
||||
|
||||
[node name="StartMarker" parent="." instance=ExtResource("4_u4ca0")]
|
||||
visible = false
|
||||
|
||||
[connection signal="started_drawing" from="Cursor" to="." method="_on_cursor_started_drawing"]
|
||||
[connection signal="stopped_drawing" from="Cursor" to="." method="_on_cursor_stopped_drawing"]
|
||||
7
scenes/main.gd
Normal file
7
scenes/main.gd
Normal file
@ -0,0 +1,7 @@
|
||||
extends Node2D
|
||||
|
||||
const PRIMARY_GAME = preload("res://scenes/debug/MouseLoop.tscn")
|
||||
|
||||
func _ready () -> void:
|
||||
await get_tree().create_timer(.2).timeout
|
||||
SceneManager.change_scene(PRIMARY_GAME)
|
||||
1
scenes/main.gd.uid
Normal file
1
scenes/main.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://xv5ex4y3tndf
|
||||
6
scenes/main.tscn
Normal file
6
scenes/main.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://by78isronsqtp"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://xv5ex4y3tndf" path="res://scenes/main.gd" id="1_o5qli"]
|
||||
|
||||
[node name="Main" type="Node2D"]
|
||||
script = ExtResource("1_o5qli")
|
||||
16
scenes/objects/Collectable.tscn
Normal file
16
scenes/objects/Collectable.tscn
Normal file
@ -0,0 +1,16 @@
|
||||
[gd_scene load_steps=4 format=3 uid="uid://c0srxosarykx7"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bmke2komimx40" path="res://scenes/objects/collectable.gd" id="1_dtuyt"]
|
||||
[ext_resource type="Texture2D" uid="uid://b5s8fiaschsvs" path="res://icon.svg" id="1_raufp"]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id="RectangleShape2D_aaj44"]
|
||||
|
||||
[node name="Collectable" type="CharacterBody2D" groups=["collectable"]]
|
||||
script = ExtResource("1_dtuyt")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("RectangleShape2D_aaj44")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
scale = Vector2(0.25, 0.25)
|
||||
texture = ExtResource("1_raufp")
|
||||
12
scenes/objects/Cursor.tscn
Normal file
12
scenes/objects/Cursor.tscn
Normal file
@ -0,0 +1,12 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://byipv4uqxdtfk"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://b37llyj4cny7w" path="res://scenes/objects/cursor.gd" id="1_6xvnr"]
|
||||
[ext_resource type="Texture2D" uid="uid://ds5ybi21d52yw" path="res://assets/sprites/pencil.png" id="1_erapf"]
|
||||
|
||||
[node name="Cursor" type="Node2D"]
|
||||
script = ExtResource("1_6xvnr")
|
||||
|
||||
[node name="IconNormal" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_erapf")
|
||||
centered = false
|
||||
offset = Vector2(0, -32)
|
||||
10
scenes/objects/Loop.tscn
Normal file
10
scenes/objects/Loop.tscn
Normal file
@ -0,0 +1,10 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://c3qo6pmowd5en"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bi2yo4l1m60iu" path="res://scenes/objects/loop.gd" id="1_vv7t2"]
|
||||
|
||||
[node name="Loop" type="Area2D"]
|
||||
script = ExtResource("1_vv7t2")
|
||||
|
||||
[node name="PolygonCollision" type="CollisionPolygon2D" parent="."]
|
||||
|
||||
[connection signal="body_entered" from="." to="." method="_on_body_entered"]
|
||||
6
scenes/objects/StartMarker.tscn
Normal file
6
scenes/objects/StartMarker.tscn
Normal file
@ -0,0 +1,6 @@
|
||||
[gd_scene load_steps=2 format=3 uid="uid://dnr505je252gd"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://bwut7fxknsnos" path="res://scenes/objects/start_marker.gd" id="1_u6erm"]
|
||||
|
||||
[node name="StartMarker" type="Node2D"]
|
||||
script = ExtResource("1_u6erm")
|
||||
19
scenes/objects/collectable.gd
Normal file
19
scenes/objects/collectable.gd
Normal file
@ -0,0 +1,19 @@
|
||||
extends CharacterBody2D
|
||||
|
||||
@export var is_bad : bool = false
|
||||
|
||||
func _ready() -> void:
|
||||
velocity = Vector2.from_angle(randf() * PI * 2) * 50
|
||||
if is_bad:
|
||||
modulate = Color.RED
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
var results = move_and_collide(velocity * delta, false)
|
||||
if results != null:
|
||||
velocity = velocity.reflect(Vector2.from_angle(results.get_angle()))
|
||||
|
||||
func remove() -> void:
|
||||
if is_bad:
|
||||
velocity = Vector2(0,0)
|
||||
await get_tree().create_tween().tween_property(self, "scale", Vector2(2,2), 1.0).finished
|
||||
get_tree().queue_delete(self)
|
||||
1
scenes/objects/collectable.gd.uid
Normal file
1
scenes/objects/collectable.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bmke2komimx40
|
||||
97
scenes/objects/cursor.gd
Normal file
97
scenes/objects/cursor.gd
Normal file
@ -0,0 +1,97 @@
|
||||
extends Node2D
|
||||
|
||||
var positions_history : Array
|
||||
var loop_stack : Array
|
||||
|
||||
signal started_drawing(pos:Vector2)
|
||||
signal stopped_drawing
|
||||
|
||||
var is_drawing = false
|
||||
|
||||
func _ready() -> void:
|
||||
init_history_stack()
|
||||
loop_stack = []
|
||||
Input.mouse_mode = Input.MOUSE_MODE_CAPTURED
|
||||
global_position = get_viewport_rect().size / 2
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if global_position.y < 32:
|
||||
$IconNormal.scale.y = -1.0
|
||||
else:
|
||||
$IconNormal.scale.y = 1.0
|
||||
if global_position.x > get_viewport_rect().size.x - 32:
|
||||
$IconNormal.scale.x = -1.0
|
||||
else:
|
||||
$IconNormal.scale.x = 1.0
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if event is InputEventMouseMotion:
|
||||
var direction = event.relative.normalized()
|
||||
# truthfully should calibrate by mouse
|
||||
# need a max speed for fair gameplay
|
||||
# var speed = clamp(event.relative.length(), 0.0, 128.0)
|
||||
var speed = event.relative.length()
|
||||
global_position += direction * speed
|
||||
restrict_cursor()
|
||||
if Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT):
|
||||
if not is_drawing:
|
||||
emit_signal("started_drawing", global_position)
|
||||
is_drawing = true
|
||||
push_history_stack(global_position)
|
||||
else:
|
||||
if is_close_to_loop():
|
||||
create_valid_loop()
|
||||
init_history_stack()
|
||||
if is_drawing:
|
||||
emit_signal("stopped_drawing")
|
||||
is_drawing = false
|
||||
|
||||
func get_tail(max_length: int = 32) -> Array:
|
||||
var tail_length = min(positions_history.size(), max_length)
|
||||
var output = positions_history.slice(positions_history.size() - tail_length, positions_history.size())
|
||||
return output
|
||||
|
||||
func is_close_to_loop () -> bool:
|
||||
if positions_history.size() < 4:
|
||||
return false
|
||||
|
||||
var to = positions_history[positions_history.size() - 1]
|
||||
var from = positions_history[0]
|
||||
var distance = (to - from).length()
|
||||
print(distance)
|
||||
|
||||
if distance < Globals.SNAP_DISTANCE:
|
||||
print((to - from).length())
|
||||
return true
|
||||
return false
|
||||
|
||||
func init_history_stack() -> void:
|
||||
positions_history = []
|
||||
|
||||
func create_valid_loop() -> void:
|
||||
var smoothed_loop = positions_history
|
||||
var last = 0
|
||||
|
||||
# simplify
|
||||
for j in range(1):
|
||||
var new_loop = []
|
||||
for i in range(0, smoothed_loop.size(), 2):
|
||||
new_loop.append(smoothed_loop[i])
|
||||
smoothed_loop = new_loop
|
||||
|
||||
loop_stack.append(smoothed_loop)
|
||||
|
||||
func push_history_stack(value : Vector2) -> void:
|
||||
positions_history.append(value)
|
||||
if positions_history.size() > Globals.HISTORY_LENGTH:
|
||||
positions_history.pop_front()
|
||||
|
||||
func restrict_cursor() -> void:
|
||||
if global_position.x < 0:
|
||||
global_position.x = 0
|
||||
if global_position.y < 0:
|
||||
global_position.y = 0
|
||||
if global_position.x > get_viewport_rect().size.x:
|
||||
global_position.x = get_viewport_rect().size.x
|
||||
if global_position.y > get_viewport_rect().size.y:
|
||||
global_position.y = get_viewport_rect().size.y
|
||||
1
scenes/objects/cursor.gd.uid
Normal file
1
scenes/objects/cursor.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://b37llyj4cny7w
|
||||
22
scenes/objects/loop.gd
Normal file
22
scenes/objects/loop.gd
Normal file
@ -0,0 +1,22 @@
|
||||
extends Area2D
|
||||
|
||||
var contents : Array = []
|
||||
const LINE_THICC = 6.0
|
||||
|
||||
func _ready() -> void:
|
||||
await get_tree().create_timer(.2).timeout
|
||||
$PolygonCollision.disabled = true
|
||||
|
||||
func _draw() -> void:
|
||||
draw_polyline(
|
||||
$PolygonCollision.polygon,
|
||||
Color.BLACK, LINE_THICC, false)
|
||||
draw_line(
|
||||
$PolygonCollision.polygon[0], $PolygonCollision.polygon[$PolygonCollision.polygon.size() - 1],
|
||||
Color.BLACK, LINE_THICC, false)
|
||||
|
||||
func _on_body_entered(body: Node2D) -> void:
|
||||
contents.append(body)
|
||||
|
||||
func get_contained_nodes() -> Array:
|
||||
return contents
|
||||
1
scenes/objects/loop.gd.uid
Normal file
1
scenes/objects/loop.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bi2yo4l1m60iu
|
||||
4
scenes/objects/start_marker.gd
Normal file
4
scenes/objects/start_marker.gd
Normal file
@ -0,0 +1,4 @@
|
||||
extends Node2D
|
||||
|
||||
func _draw() -> void:
|
||||
draw_circle(Vector2(), 32, Color.GREEN, true, 0, false)
|
||||
1
scenes/objects/start_marker.gd.uid
Normal file
1
scenes/objects/start_marker.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://bwut7fxknsnos
|
||||
9
scripts/Globals.gd
Normal file
9
scripts/Globals.gd
Normal file
@ -0,0 +1,9 @@
|
||||
extends Node
|
||||
|
||||
const SCENE_LOOP = preload("res://scenes/objects/Loop.tscn")
|
||||
const SCENE_COLLECTABLE = preload("res://scenes/objects/Collectable.tscn")
|
||||
const SCENE_START_MARKER = preload("res://scenes/objects/StartMarker.tscn")
|
||||
|
||||
const LINE_THICC = 4.0
|
||||
const HISTORY_LENGTH = 196
|
||||
const SNAP_DISTANCE = 32
|
||||
1
scripts/Globals.gd.uid
Normal file
1
scripts/Globals.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://ch2ayhum8jm28
|
||||
8
scripts/SceneManager.gd
Normal file
8
scripts/SceneManager.gd
Normal file
@ -0,0 +1,8 @@
|
||||
extends Node
|
||||
|
||||
func change_scene(scene):
|
||||
var current = get_tree().current_scene
|
||||
get_tree().root.remove_child(current)
|
||||
var next = scene.instantiate()
|
||||
get_tree().root.add_child(next)
|
||||
get_tree().current_scene = next
|
||||
1
scripts/SceneManager.gd.uid
Normal file
1
scripts/SceneManager.gd.uid
Normal file
@ -0,0 +1 @@
|
||||
uid://dd13tvd0buvta
|
||||
Loading…
x
Reference in New Issue
Block a user