Skip to content

Commit

Permalink
v0.4
Browse files Browse the repository at this point in the history
  • Loading branch information
garhow committed Sep 7, 2023
1 parent 16a610a commit ff33d14
Show file tree
Hide file tree
Showing 50 changed files with 801 additions and 75 deletions.
79 changes: 47 additions & 32 deletions Player.tscn
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
[gd_scene load_steps=10 format=3 uid="uid://ce0v4imrrwj0o"]
[gd_scene load_steps=12 format=3 uid="uid://ce0v4imrrwj0o"]

[ext_resource type="Script" path="res://scripts/Player.gd" id="1_0b2wf"]
[ext_resource type="Script" path="res://scripts/Camera.gd" id="1_dxxau"]
[ext_resource type="Script" path="res://scripts/UI.gd" id="3_f4pju"]
[ext_resource type="Script" path="res://scripts/Pause Menu.gd" id="4_ap2el"]
[ext_resource type="AudioStream" uid="uid://dw6f1c0wbarj5" path="res://sounds/undo.ogg" id="6_xja1s"]
[ext_resource type="AudioStream" uid="uid://bib27i3cog6sx" path="res://sounds/error.ogg" id="7_oh653"]

[sub_resource type="StyleBoxFlat" id="StyleBoxFlat_esew8"]

Expand Down Expand Up @@ -157,61 +159,64 @@ layout_mode = 2
text = "· Press G to slow down physics"
autowrap_mode = 2

[node name="Tools" type="PanelContainer" parent="Camera/User Interface"]
custom_minimum_size = Vector2(86.22, 0)
[node name="TabContainer" type="TabContainer" parent="Camera/User Interface"]
anchors_preset = 6
anchor_left = 1.0
anchor_top = 0.5
anchor_right = 1.0
anchor_bottom = 0.5
offset_left = -86.22
offset_top = -60.0
offset_bottom = 60.0
offset_left = -138.0
offset_top = -101.0
offset_bottom = 101.0
grow_horizontal = 0
grow_vertical = 2
size_flags_horizontal = 0
size_flags_vertical = 4
tab_alignment = 1
clip_tabs = false

[node name="MarginContainer" type="MarginContainer" parent="Camera/User Interface/Tools"]
[node name="Tools" type="VSplitContainer" parent="Camera/User Interface/TabContainer"]
layout_mode = 2
theme_override_constants/margin_left = 8
theme_override_constants/margin_top = 8
theme_override_constants/margin_right = 8
theme_override_constants/margin_bottom = 8

[node name="VSplitContainer" type="VSplitContainer" parent="Camera/User Interface/Tools/MarginContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="Camera/User Interface/TabContainer/Tools"]
layout_mode = 2

[node name="Label" type="Label" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer"]
[node name="Drag" type="Button" parent="Camera/User Interface/TabContainer/Tools/VBoxContainer"]
layout_mode = 2
text = "Tools"
horizontal_alignment = 1
vertical_alignment = 1
tooltip_text = "Drag objects around."
text = "Drag"

[node name="VBoxContainer" type="VBoxContainer" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer"]
[node name="Antigrav" type="Button" parent="Camera/User Interface/TabContainer/Tools/VBoxContainer"]
layout_mode = 2
tooltip_text = "Toggle gravity on an object"
text = "Anti-gravity"

[node name="Drag" type="Button" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer"]
[node name="Pin" type="Button" parent="Camera/User Interface/TabContainer/Tools/VBoxContainer"]
layout_mode = 2
tooltip_text = "Drag objects around."
text = "Drag"
tooltip_text = "Pin objects to the background."
text = "Pin"

[node name="Pin" type="Button" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer"]
[node name="Weld" type="Button" parent="Camera/User Interface/TabContainer/Tools/VBoxContainer"]
layout_mode = 2
tooltip_text = "Pin objects to the background."
text = "Pin"
text = "Weld"

[node name="Powers" type="VSplitContainer" parent="Camera/User Interface/TabContainer"]
visible = false
layout_mode = 2

[node name="Pull" type="Button" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer"]
[node name="VBoxContainer" type="VBoxContainer" parent="Camera/User Interface/TabContainer/Powers"]
layout_mode = 2

[node name="Pull" type="Button" parent="Camera/User Interface/TabContainer/Powers/VBoxContainer"]
layout_mode = 2
tooltip_text = "Pin objects to the background."
text = "Pull"

[node name="Push" type="Button" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer"]
[node name="Push" type="Button" parent="Camera/User Interface/TabContainer/Powers/VBoxContainer"]
layout_mode = 2
tooltip_text = "Pin objects to the background."
text = "Push"

[node name="Lift" type="Button" parent="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer"]
[node name="Lift" type="Button" parent="Camera/User Interface/TabContainer/Powers/VBoxContainer"]
layout_mode = 2
tooltip_text = "Pin objects to the background."
text = "Lift"
Expand Down Expand Up @@ -328,11 +333,21 @@ linear_damp = 1.0
shape = SubResource("CircleShape2D_sysie")
debug_color = Color(0, 0.6, 0, 0.419608)

[connection signal="pressed" from="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer/Drag" to="Camera/User Interface" method="_on_tool_picked" binds= [0]]
[connection signal="pressed" from="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer/Pin" to="Camera/User Interface" method="_on_tool_picked" binds= [1]]
[connection signal="pressed" from="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer/Pull" to="Camera/User Interface" method="_on_tool_picked" binds= [2]]
[connection signal="pressed" from="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer/Push" to="Camera/User Interface" method="_on_tool_picked" binds= [3]]
[connection signal="pressed" from="Camera/User Interface/Tools/MarginContainer/VSplitContainer/VBoxContainer/Lift" to="Camera/User Interface" method="_on_tool_picked" binds= [4]]
[node name="Sounds" type="Node" parent="."]

[node name="Undo" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource("6_xja1s")

[node name="Error" type="AudioStreamPlayer" parent="Sounds"]
stream = ExtResource("7_oh653")

[connection signal="pressed" from="Camera/User Interface/TabContainer/Tools/VBoxContainer/Drag" to="Camera/User Interface" method="_on_tool_picked" binds= [0]]
[connection signal="pressed" from="Camera/User Interface/TabContainer/Tools/VBoxContainer/Antigrav" to="Camera/User Interface" method="_on_tool_picked" binds= [6]]
[connection signal="pressed" from="Camera/User Interface/TabContainer/Tools/VBoxContainer/Pin" to="Camera/User Interface" method="_on_tool_picked" binds= [1]]
[connection signal="pressed" from="Camera/User Interface/TabContainer/Tools/VBoxContainer/Weld" to="Camera/User Interface" method="_on_tool_picked" binds= [5]]
[connection signal="pressed" from="Camera/User Interface/TabContainer/Powers/VBoxContainer/Pull" to="Camera/User Interface" method="_on_tool_picked" binds= [2]]
[connection signal="pressed" from="Camera/User Interface/TabContainer/Powers/VBoxContainer/Push" to="Camera/User Interface" method="_on_tool_picked" binds= [3]]
[connection signal="pressed" from="Camera/User Interface/TabContainer/Powers/VBoxContainer/Lift" to="Camera/User Interface" method="_on_tool_picked" binds= [4]]
[connection signal="pressed" from="Camera/User Interface/Pause Menu/MarginContainer/VSplitContainer/VBoxContainer/Resume" to="Camera/User Interface/Pause Menu" method="_resume"]
[connection signal="pressed" from="Camera/User Interface/Pause Menu/MarginContainer/VSplitContainer/VBoxContainer/Return to Title" to="Camera/User Interface/Pause Menu" method="_return_to_title"]
[connection signal="pressed" from="Camera/User Interface/Pause Menu/MarginContainer/VSplitContainer/VBoxContainer/Quit Game" to="Camera/User Interface/Pause Menu" method="_quit_game"]
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@

### Action

* `E` - spawn object
* `E/Q` - spawn object
* `F` - freeze selected object
* `R` - interact with selected object
* `G` - slow down time
* `D/DEL` - delete object
* `P` - pause game

### Camera
Expand Down
67 changes: 45 additions & 22 deletions classes/Draggable.gd
Original file line number Diff line number Diff line change
@@ -1,44 +1,59 @@
class_name Draggable
extends RigidBody2D
class_name Draggable extends RigidBody2D

@export var flippable := true
@export var flippable := false

@onready var default_gravity = self.gravity_scale

var dragging := false
var hovering := false

var current_joint : PinJoint2D
var current_pivot : PhysicsBody2D

func play_sound(path: Resource):
var sound = AudioStreamPlayer2D.new()
sound.stream = path
sound.global_position = global_position
add_child(sound)
sound.play()

func _ready():
input_pickable = true
mouse_entered.connect(_on_mouse_entered)
mouse_exited.connect(_on_mouse_exited)
play_sound(preload("res://sounds/spawn.ogg"))

func _interact():
pass

func _flip():
pass
#if flippable:
# for child in get_children():
# child.scale.x = -1
if flippable:
for child in get_children():
child.scale.x = -1

func _antigravity():
play_sound(load("res://sounds/gravity.ogg"))
if gravity_scale == default_gravity:
gravity_scale = -1
else:
gravity_scale = default_gravity

func _pin():
var target = StaticBody2D.new()
target.position = get_local_mouse_position()
get_tree().current_scene.add_child(target)

var pin = PinJoint2D.new()
pin.position = get_local_mouse_position()
pin.node_a = target.get_path()
pin.node_b = self.get_path()

var sprite = Sprite2D.new()
sprite.texture = load("res://objects/misc/peg.png")
sprite.texture_filter = TEXTURE_FILTER_NEAREST
pin.add_child(sprite)

add_child(pin)
Game.spawn(Pin.new(self))

func _weld():
if Game.buffer_tool != Game.Tools.WELD:
Game.buffer_tool = Game.Tools.WELD
Game.buffer.clear()
if Game.buffer.size() == 0:
Game.buffer.append([self.get_path(), get_global_mouse_position()])
play_sound(load("res://sounds/weld1.ogg"))
else:
Game.buffer.append([self.get_path(), get_global_mouse_position()])
play_sound(load("res://sounds/weld2.ogg"))
Game.spawn(Weld.new())
Game.buffer.clear()

func _handle_dragging():
if Game.tool == Game.Tools.DRAG:
Expand Down Expand Up @@ -75,7 +90,9 @@ func _process(_delta):
if Input.is_action_just_pressed("interact"): _interact()
if Input.is_action_just_pressed("delete"): queue_free()
if Input.is_action_just_pressed("flip"): _flip()
if Input.is_action_just_pressed("click") and Game.tool == Game.Tools.ANTIGRAVITY: _antigravity()
if Input.is_action_just_pressed("click") and Game.tool == Game.Tools.PIN: _pin()
if Input.is_action_just_pressed("click") and Game.tool == Game.Tools.WELD: _weld()

# Handle modulation
if hovering:
Expand All @@ -86,6 +103,12 @@ func _process(_delta):

func _physics_process(_delta):
_handle_dragging()
_custom_physics_process(_delta)
if global_position.x < -Game.world_size or global_position.x > Game.world_size or global_position.y < -Game.world_size or global_position.y > Game.world_size:
queue_free()

func _custom_physics_process(_delta):
pass

func _on_mouse_entered(): hovering = true
func _on_mouse_exited(): hovering = false
21 changes: 21 additions & 0 deletions classes/Pin.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class_name Pin extends StaticBody2D

var parent : PhysicsBody2D

func _init(new_parent: PhysicsBody2D):
parent = new_parent

func _ready():
position = get_local_mouse_position()

var sprite = Sprite2D.new()
sprite.texture = load("res://objects/misc/peg.png")
sprite.texture_filter = TEXTURE_FILTER_NEAREST

var pin = PinJoint2D.new()
pin.position = get_local_mouse_position()
pin.node_a = get_path()
pin.node_b = parent.get_path()
pin.add_child(sprite)

add_child(pin)
15 changes: 15 additions & 0 deletions classes/Weld.gd
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
class_name Weld extends Node2D

func _ready():
var joint1 = PinJoint2D.new()
joint1.node_a = Game.buffer[0][0]
joint1.node_b = Game.buffer[1][0]
joint1.global_position = Game.buffer[0][1]

var joint2 = PinJoint2D.new()
joint2.node_a = Game.buffer[1][0]
joint2.node_b = Game.buffer[0][0]
joint2.global_position = Game.buffer[1][1]

add_child(joint1)
add_child(joint2)
12 changes: 6 additions & 6 deletions objects/creatures/human/Human.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ size = Vector2(8, 24)
position = Vector2(0, -24)
mass = 0.1
script = ExtResource("2_w4d4i")
flippable = false
flippable = null

[node name="Collision" type="CollisionShape2D" parent="Head"]
shape = SubResource("CircleShape2D_5vyh5")
Expand All @@ -34,7 +34,7 @@ disable_collision = false
[node name="Torso" type="RigidBody2D" parent="."]
mass = 0.1
script = ExtResource("2_w4d4i")
flippable = false
flippable = null

[node name="Collision" type="CollisionShape2D" parent="Torso"]
shape = SubResource("RectangleShape2D_mwmk1")
Expand All @@ -48,7 +48,7 @@ position = Vector2(-5, 26)
rotation = 0.0698132
mass = 0.1
script = ExtResource("2_w4d4i")
flippable = false
flippable = null

[node name="Collision" type="CollisionShape2D" parent="Left Leg"]
shape = SubResource("RectangleShape2D_mwmk1")
Expand All @@ -69,7 +69,7 @@ position = Vector2(6, 26)
rotation = -0.0698132
mass = 0.1
script = ExtResource("2_w4d4i")
flippable = false
flippable = null

[node name="Collision" type="CollisionShape2D" parent="Right Leg"]
shape = SubResource("RectangleShape2D_mwmk1")
Expand All @@ -89,7 +89,7 @@ position = Vector2(-20, -10)
rotation = 1.5708
mass = 0.1
script = ExtResource("2_w4d4i")
flippable = false
flippable = null

[node name="Collision" type="CollisionShape2D" parent="Left Arm"]
shape = SubResource("RectangleShape2D_mwmk1")
Expand All @@ -111,7 +111,7 @@ position = Vector2(20, -10)
rotation = -1.5708
mass = 0.1
script = ExtResource("2_w4d4i")
flippable = false
flippable = null

[node name="Collision" type="CollisionShape2D" parent="Right Arm"]
shape = SubResource("RectangleShape2D_mwmk1")
Expand Down
1 change: 1 addition & 0 deletions objects/misc/Boulder/Boulder.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
mass = 80.0
can_sleep = false
script = ExtResource("1_vbk4j")
flippable = null

[node name="Sprite" type="Sprite2D" parent="."]
texture_filter = 1
Expand Down
Binary file added objects/misc/Ramp/Ramp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
34 changes: 34 additions & 0 deletions objects/misc/Ramp/Ramp.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://be0ix6l3exjnr"
path="res://.godot/imported/Ramp.png-34138c3c9e4abc56f8d236c0e5eb7ffd.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://objects/misc/Ramp/Ramp.png"
dest_files=["res://.godot/imported/Ramp.png-34138c3c9e4abc56f8d236c0e5eb7ffd.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
Loading

0 comments on commit ff33d14

Please sign in to comment.