Skip to content

Commit

Permalink
more like a game now
Browse files Browse the repository at this point in the history
  • Loading branch information
rosskarchner committed Aug 17, 2024
1 parent a65e0e0 commit e4b6b52
Show file tree
Hide file tree
Showing 17 changed files with 302 additions and 69 deletions.
18 changes: 7 additions & 11 deletions ATTRIBUTION.md
Original file line number Diff line number Diff line change
@@ -1,23 +1,19 @@
# Attribution
## Collaborators

Made by Ross Karchner in 2024


### Godot Game Template
Author: [Marek Belski and contributors](https://github.com/Maaack/Godot-Game-Template/graphs/contributors)
Source: [github: Godot-Game-Template](https://github.com/Maaack/Godot-Game-Template)
License: [MIT License](LICENSE.txt)

### "Quit" Font
Author: [somepx](https://somepx.itch.io/)
License: Purchased and use according to license.

## Tools
#### Godot
Author: [Juan Linietsky, Ariel Manzur, and contributors](https://godotengine.org/contact)
Source: [godotengine.org](https://godotengine.org/)
License: [MIT License](https://github.com/godotengine/godot/blob/master/LICENSE.txt)

#### Visual Studio Code
Author: [Microsoft](https://opensource.microsoft.com/)
Source: [github: vscode](https://github.com/microsoft/vscode)
License: [MIT License](https://github.com/microsoft/vscode/blob/main/LICENSE.txt)

#### Git
Author: [Linus Torvalds](https://github.com/torvalds)
Source: [git-scm.com](https://git-scm.com/downloads)
License: [GNU General Public License version 2](https://opensource.org/licenses/GPL-2.0)
Binary file added assets/fonts/Quit 13.ttf
Binary file not shown.
34 changes: 34 additions & 0 deletions assets/fonts/Quit 13.ttf.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="font_data_dynamic"
type="FontFile"
uid="uid://bgo6tp8of0gef"
path="res://.godot/imported/Quit 13.ttf-06997ae2f9cd9b4a4543265623a416ca.fontdata"

[deps]

source_file="res://assets/fonts/Quit 13.ttf"
dest_files=["res://.godot/imported/Quit 13.ttf-06997ae2f9cd9b4a4543265623a416ca.fontdata"]

[params]

Rendering=null
antialiasing=1
generate_mipmaps=false
disable_embedded_bitmaps=true
multichannel_signed_distance_field=false
msdf_pixel_range=8
msdf_size=48
allow_system_fallback=true
force_autohinter=false
hinting=1
subpixel_positioning=1
oversampling=0.0
Fallbacks=null
fallbacks=[]
Compress=null
compress=true
preload=[]
language_support={}
script_support={}
opentype_features={}
10 changes: 10 additions & 0 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,16 @@ click={
"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":1,"position":Vector2(82, 23),"global_position":Vector2(94, 80),"factor":1.0,"button_index":1,"canceled":false,"pressed":true,"double_click":false,"script":null)
]
}
skip_level={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":76,"key_label":0,"unicode":108,"location":0,"echo":false,"script":null)
]
}
cheat={
"deadzone": 0.5,
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":true,"ctrl_pressed":true,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":67,"key_label":0,"unicode":67,"location":0,"echo":false,"script":null)
]
}

[internationalization]

Expand Down
2 changes: 1 addition & 1 deletion scenes/Credits/Credits.tscn
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[gd_scene load_steps=3 format=3 uid="uid://diut1db2bsqla"]

[ext_resource type="PackedScene" path="res://addons/maaacks_game_template/base/scenes/Credits/Credits.tscn" id="1_s3dg4"]
[ext_resource type="PackedScene" uid="uid://t2dui8ppm3a4" path="res://addons/maaacks_game_template/base/scenes/Credits/Credits.tscn" id="1_s3dg4"]
[ext_resource type="Script" path="res://scenes/Credits/Credits.gd" id="2_lkit1"]

[node name="Credits" instance=ExtResource("1_s3dg4")]
Expand Down
32 changes: 31 additions & 1 deletion scenes/GameScene/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,25 @@ var current_level_instance = null

@onready var piece_spawner = $GamepieceSpawner
@onready var level_container = $LevelContainer
@onready var level_complete_scene = preload("res://scenes/dialog/level_complete_dialog.tscn")

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
NetworkEvents.circuit_complete.connect(advance_level)
NetworkEvents.circuit_complete.connect(level_complete)
load_current_level()

func level_complete():
var level_complete_dialog = level_complete_scene.instantiate()
var remaining_levels = 2 - current_level
level_complete_dialog.remaining_levels = remaining_levels
if remaining_levels > 0:
level_complete_dialog.clicked_next_level.connect(advance_level)
else:
level_complete_dialog.clicked_next_level.connect(func():
get_tree().change_scene_to_file("res://scenes/Credits/Credits.tscn")
)
$HUD.add_child(level_complete_dialog)

func advance_level():
current_level_instance.queue_free()
current_level +=1
Expand All @@ -26,6 +39,23 @@ func load_current_level():
piece_spawner.reveal_next_piece()


func _input(event: InputEvent) -> void:
if event.is_action_pressed("skip_level"):
advance_level()
if event.is_action_pressed("cheat"):
level_complete()

func _on_undo_button_pressed() -> void:
piece_spawner.undo()


func _on_gamepiece_spawner_piece_count_changed(history_depth: Variant, remaining_pices: Variant) -> void:
if history_depth == 0:
%UndoButton.disabled = true
else:
%UndoButton.disabled = false


func _on_start_over_button_pressed() -> void:
current_level_instance.queue_free()
load_current_level()
11 changes: 11 additions & 0 deletions scenes/GameScene/game.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,21 @@ position = Vector2(18, 123)
[node name="HUD" type="CanvasLayer" parent="."]

[node name="UndoButton" type="Button" parent="HUD"]
unique_name_in_owner = true
offset_left = 774.0
offset_top = 60.0
offset_right = 824.0
offset_bottom = 91.0
text = "Undo"

[node name="StartOverButton" type="Button" parent="HUD"]
unique_name_in_owner = true
offset_left = 844.0
offset_top = 60.0
offset_right = 894.0
offset_bottom = 91.0
text = "Start Over"

[connection signal="piece_count_changed" from="GamepieceSpawner" to="." method="_on_gamepiece_spawner_piece_count_changed"]
[connection signal="pressed" from="HUD/UndoButton" to="." method="_on_undo_button_pressed"]
[connection signal="pressed" from="HUD/StartOverButton" to="." method="_on_start_over_button_pressed"]
6 changes: 5 additions & 1 deletion scenes/GameScene/light.gd
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,17 @@
extends Node2D
class_name Light

var triggered = false

@onready var connection_point1 = $ConnectionPoint1
@onready var connection_point2 = $ConnectionPoint2

var is_on = false:
set(status):
is_on = status
if status and not triggered:
NetworkEvents.circuit_complete.emit()
triggered = true
update_display()


Expand All @@ -27,7 +31,7 @@ func update_display() -> void:
if is_on:
$OnSprite.show()
$OffSprite.hide()
NetworkEvents.circuit_complete.emit()

else:
$OnSprite.hide()
$OffSprite.show()
8 changes: 6 additions & 2 deletions scenes/GameScene/segment.gd
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ var dragStartPosition: Vector2
var dragging = false
var drop_target:Area2D

var wire_colors = [Color.BLACK, Color.CORAL, Color.DARK_GREEN]

var connection_point_scene=preload("res://scenes/GameScene/connection_point.tscn")
var connection_points = []

Expand Down Expand Up @@ -60,11 +62,13 @@ func create_connection_pair(position1, position2):
add_child(connector2)

func _draw() -> void:
var i = 0
for pair in connection_pairs:
var position1 = positions[pair[0]]
var position2 = positions[pair[1]]
draw_line(position1 - Vector2i(46,46),Vector2.ZERO,Color.BLACK,2.0)
draw_line(position2 - Vector2i(46,46),Vector2.ZERO,Color.BLACK,2.0)
draw_line(position1 - Vector2i(46,46),Vector2.ZERO,wire_colors[i],3.0)
draw_line(position2 - Vector2i(46,46),Vector2.ZERO,wire_colors[i],3.0)
i+=1

# Called when the node enters the scene tree for the first time.
func _ready() -> void:
Expand Down
47 changes: 19 additions & 28 deletions scenes/Levels/level_2.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -19,58 +19,49 @@ sources/0 = SubResource("TileSetScenesCollectionSource_ie45y")
[node name="Level2" type="Node2D"]

[node name="Tiles" type="TileMapLayer" parent="."]
position = Vector2(619, 3)
tile_map_data = PackedByteArray("AAD//wMAAAAAAAAAAQAAAAMAAAAAAAAAAQAAAAIAAAAAAAAAAQD+/wEAAAAAAAAAAQD+/wMAAAAAAAAAAQD//wQAAAAAAAAAAQAAAAQAAAAAAAAAAQABAAQAAAAAAAAAAQABAAMAAAAAAAAAAQAAAAEAAAAAAAAAAQD+/wIAAAAAAAAAAQD9/wMAAAAAAAAAAQD9/wQAAAAAAAAAAQD+/wQAAAAAAAAAAQD9/wUAAAAAAAAAAQD+/wUAAAAAAAAAAQD//wUAAAAAAAAAAQD9/wEAAAAAAAAAAQD//wEAAAAAAAAAAQACAAIAAAAAAAAAAQD8/wUAAAAAAAAAAgABAAEAAAAAAAAAAwABAAAAAAAAAAAAAQA=")
position = Vector2(637, -162)
tile_map_data = PackedByteArray("AAD//wQAAAAAAAAAAQD9/wQAAAAAAAAAAQD9/wUAAAAAAAAAAQD+/wUAAAAAAAAAAQD8/wUAAAAAAAAAAgD9/wYAAAAAAAAAAQD+/wYAAAAAAAAAAQABAAQAAAAAAAAAAwAAAAQAAAAAAAAAAQAAAAUAAAAAAAAAAQAAAAMAAAAAAAAAAQD//wUAAAAAAAAAAQA=")
tile_set = SubResource("TileSet_f5i1a")

[node name="PossibleSolution" type="Node2D" parent="."]
visible = false
position = Vector2(581, 178)
position = Vector2(599, 13)

[node name="Segment" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-316, 142)
connection_pairs = Array[Vector2i]([Vector2i(2, -2)])
position = Vector2(-197, 155)
connection_pairs = Array[Vector2i]([Vector2i(4, 3)])

[node name="Segment2" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-260, 28)
connection_pairs = Array[Vector2i]([Vector2i(5, 2)])

[node name="Segment11" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-188, 159)
connection_pairs = Array[Vector2i]([Vector2i(5, 2)])
position = Vector2(38, 225)
connection_pairs = Array[Vector2i]([Vector2i(5, 2), Vector2i(0, 1)])

[node name="Segment12" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-88, 334)
connection_pairs = Array[Vector2i]([Vector2i(5, 2)])
position = Vector2(-57, 226)
connection_pairs = Array[Vector2i]([Vector2i(5, 1), Vector2i(4, 2)])

[node name="Segment3" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(192, 11)
connection_pairs = Array[Vector2i]([Vector2i(5, 3)])
position = Vector2(132, 226)
connection_pairs = Array[Vector2i]([Vector2i(5, 1)])

[node name="Segment4" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-247, 297)
position = Vector2(-195, 295)
connection_pairs = Array[Vector2i]([Vector2i(0, 1)])

[node name="Segment10" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(291, 206)
position = Vector2(-102, 293)
connection_pairs = Array[Vector2i]([Vector2i(0, 1)])

[node name="Segment5" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(55, -24)
connection_pairs = Array[Vector2i]([Vector2i(4, 2)])
position = Vector2(85, 153)
connection_pairs = Array[Vector2i]([Vector2i(4, 1)])

[node name="Segment8" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(340, 106)
position = Vector2(133, 84)
connection_pairs = Array[Vector2i]([Vector2i(4, 3)])

[node name="Segment9" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(298, 334)
position = Vector2(-8, 154)
connection_pairs = Array[Vector2i]([Vector2i(4, 3)])

[node name="Segment6" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-91, -27)
connection_pairs = Array[Vector2i]([Vector2i(5, 3)])

[node name="Segment7" parent="PossibleSolution" instance=ExtResource("4_qc4sm")]
position = Vector2(-370, 253)
connection_pairs = Array[Vector2i]([Vector2i(1, 0)])
position = Vector2(-150, 224)
connection_pairs = Array[Vector2i]([Vector2i(3, 0), Vector2i(2, 4)])
Loading

0 comments on commit e4b6b52

Please sign in to comment.