diff --git a/Game.gd b/Game.gd index aab5069..8a949c9 100644 --- a/Game.gd +++ b/Game.gd @@ -1,8 +1,8 @@ extends Node2D -onready var SimpleEntity = preload("res://Entities/SimpleEntity.tscn") -onready var WanderingEntity = preload("res://Entities/WanderingEntity.tscn") +onready var SimpleEntity = preload("res://entities/SimpleEntity.tscn") +onready var WanderingEntity = preload("res://entities/WanderingEntity.tscn") onready var player_movable_target_label = $UI/PlayerMovableTarget onready var player = $PlayerEntity onready var entities = $Entities diff --git a/Game.tscn b/Game.tscn index f5c4a8f..bf64dd0 100644 --- a/Game.tscn +++ b/Game.tscn @@ -1,9 +1,10 @@ -[gd_scene load_steps=8 format=2] +[gd_scene load_steps=10 format=2] -[ext_resource path="res://Entities/SimpleEntity.tscn" type="PackedScene" id=1] -[ext_resource path="res://Entities/PlayerEntity.tscn" type="PackedScene" id=2] -[ext_resource path="res://Assets/white.png" type="Texture" id=3] -[ext_resource path="res://Materials/PhysicsObjects.tres" type="Material" id=4] +[ext_resource path="res://entities/SimpleEntity.tscn" type="PackedScene" id=1] +[ext_resource path="res://entities/PlayerEntity.tscn" type="PackedScene" id=2] +[ext_resource path="res://assets/white.png" type="Texture" id=3] +[ext_resource path="res://materials/PhysicsObjects.tres" type="Material" id=4] +[ext_resource path="res://utils/CollisionLine.gd" type="Script" id=5] [ext_resource path="res://Game.gd" type="Script" id=6] [sub_resource type="RectangleShape2D" id=1] @@ -11,6 +12,10 @@ extents = Vector2( 57.5347, 51.5794 ) [sub_resource type="RectangleShape2D" id=2] +[sub_resource type="SegmentShape2D" id=3] +a = Vector2( 37, 302 ) +b = Vector2( 34, 570 ) + [node name="Game" type="Node2D"] script = ExtResource( 6 ) @@ -102,6 +107,13 @@ position = Vector2( 0.465286, 0.57938 ) z_as_relative = false shape = SubResource( 1 ) +[node name="CollisionLine" type="KinematicBody2D" parent="World"] +position = Vector2( 221, 205 ) +script = ExtResource( 5 ) + +[node name="CollisionShape2D" type="CollisionShape2D" parent="World/CollisionLine"] +shape = SubResource( 3 ) + [node name="UI" type="CanvasLayer" parent="."] [node name="PlayerMovableTarget" type="Label" parent="UI"] diff --git a/Assets/pirate.svg b/assets/pirate.svg similarity index 100% rename from Assets/pirate.svg rename to assets/pirate.svg diff --git a/Assets/pirate.svg.import b/assets/pirate.svg.import similarity index 73% rename from Assets/pirate.svg.import rename to assets/pirate.svg.import index 39a60b1..14925e2 100644 --- a/Assets/pirate.svg.import +++ b/assets/pirate.svg.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/pirate.svg-3b2dea93c8f9ecaa3dd364c5dc991522.stex" +path="res://.import/pirate.svg-b5137b2528ef058c6c14f8ea13b79308.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/pirate.svg" -dest_files=[ "res://.import/pirate.svg-3b2dea93c8f9ecaa3dd364c5dc991522.stex" ] +source_file="res://assets/pirate.svg" +dest_files=[ "res://.import/pirate.svg-b5137b2528ef058c6c14f8ea13b79308.stex" ] [params] diff --git a/Assets/white.png b/assets/white.png similarity index 100% rename from Assets/white.png rename to assets/white.png diff --git a/Assets/white.png.import b/assets/white.png.import similarity index 73% rename from Assets/white.png.import rename to assets/white.png.import index ac960b4..4e8d93c 100644 --- a/Assets/white.png.import +++ b/assets/white.png.import @@ -2,15 +2,15 @@ importer="texture" type="StreamTexture" -path="res://.import/white.png-63bf30d1e697e9c6c58b33e6327f2179.stex" +path="res://.import/white.png-936ea7d0834e1e21adf362ba74ff2135.stex" metadata={ "vram_texture": false } [deps] -source_file="res://Assets/white.png" -dest_files=[ "res://.import/white.png-63bf30d1e697e9c6c58b33e6327f2179.stex" ] +source_file="res://assets/white.png" +dest_files=[ "res://.import/white.png-936ea7d0834e1e21adf362ba74ff2135.stex" ] [params] diff --git a/Components/ClickableComponent.gd b/components/ClickableComponent.gd similarity index 100% rename from Components/ClickableComponent.gd rename to components/ClickableComponent.gd diff --git a/Components/ClickableComponent.tscn b/components/ClickableComponent.tscn similarity index 88% rename from Components/ClickableComponent.tscn rename to components/ClickableComponent.tscn index 48b6235..74645a6 100644 --- a/Components/ClickableComponent.tscn +++ b/components/ClickableComponent.tscn @@ -1,6 +1,6 @@ [gd_scene load_steps=3 format=2] -[ext_resource path="res://Components/ClickableComponent.gd" type="Script" id=1] +[ext_resource path="res://components/ClickableComponent.gd" type="Script" id=1] [sub_resource type="CircleShape2D" id=1] radius = 31.4006 diff --git a/Components/CollisionComponent.gd b/components/CollisionComponent.gd similarity index 100% rename from Components/CollisionComponent.gd rename to components/CollisionComponent.gd diff --git a/Components/ColorComponent.gd b/components/ColorComponent.gd similarity index 100% rename from Components/ColorComponent.gd rename to components/ColorComponent.gd diff --git a/Components/MovableComponent.gd b/components/MovableComponent.gd similarity index 93% rename from Components/MovableComponent.gd rename to components/MovableComponent.gd index babc213..916da1e 100644 --- a/Components/MovableComponent.gd +++ b/components/MovableComponent.gd @@ -1,6 +1,6 @@ extends Node2D -var SpringDamper = preload("res://Utils/SpringDamper.gd") +var SpringDamper = preload("res://utils/SpringDamper.gd") export var target = Vector2 (0, 0) export var pos = Vector2 (0, 0) diff --git a/Components/TintedSpriteComponent.gd b/components/TintedSpriteComponent.gd similarity index 100% rename from Components/TintedSpriteComponent.gd rename to components/TintedSpriteComponent.gd diff --git a/Entities/PlayerEntity.gd b/entities/PlayerEntity.gd similarity index 100% rename from Entities/PlayerEntity.gd rename to entities/PlayerEntity.gd diff --git a/Entities/PlayerEntity.tscn b/entities/PlayerEntity.tscn similarity index 71% rename from Entities/PlayerEntity.tscn rename to entities/PlayerEntity.tscn index 807b6da..1796f03 100644 --- a/Entities/PlayerEntity.tscn +++ b/entities/PlayerEntity.tscn @@ -1,12 +1,12 @@ [gd_scene load_steps=10 format=2] -[ext_resource path="res://Entities/PlayerEntity.gd" type="Script" id=1] -[ext_resource path="res://Components/TintedSpriteComponent.gd" type="Script" id=2] -[ext_resource path="res://Components/ColorComponent.gd" type="Script" id=3] -[ext_resource path="res://Components/ClickableComponent.tscn" type="PackedScene" id=4] -[ext_resource path="res://Components/MovableComponent.gd" type="Script" id=5] -[ext_resource path="res://Assets/pirate.svg" type="Texture" id=6] -[ext_resource path="res://Assets/white.png" type="Texture" id=8] +[ext_resource path="res://entities/PlayerEntity.gd" type="Script" id=1] +[ext_resource path="res://components/TintedSpriteComponent.gd" type="Script" id=2] +[ext_resource path="res://components/ColorComponent.gd" type="Script" id=3] +[ext_resource path="res://components/ClickableComponent.tscn" type="PackedScene" id=4] +[ext_resource path="res://components/MovableComponent.gd" type="Script" id=5] +[ext_resource path="res://assets/pirate.svg" type="Texture" id=6] +[ext_resource path="res://assets/white.png" type="Texture" id=8] [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 40, 103 ) diff --git a/Entities/SimpleEntity.gd b/entities/SimpleEntity.gd similarity index 100% rename from Entities/SimpleEntity.gd rename to entities/SimpleEntity.gd diff --git a/Entities/SimpleEntity.tscn b/entities/SimpleEntity.tscn similarity index 65% rename from Entities/SimpleEntity.tscn rename to entities/SimpleEntity.tscn index 882ce03..dd07a42 100644 --- a/Entities/SimpleEntity.tscn +++ b/entities/SimpleEntity.tscn @@ -1,9 +1,9 @@ [gd_scene load_steps=6 format=2] -[ext_resource path="res://Components/TintedSpriteComponent.gd" type="Script" id=1] -[ext_resource path="res://Entities/SimpleEntity.gd" type="Script" id=2] -[ext_resource path="res://Components/ColorComponent.gd" type="Script" id=3] -[ext_resource path="res://Components/ClickableComponent.tscn" type="PackedScene" id=4] +[ext_resource path="res://components/TintedSpriteComponent.gd" type="Script" id=1] +[ext_resource path="res://entities/SimpleEntity.gd" type="Script" id=2] +[ext_resource path="res://components/ColorComponent.gd" type="Script" id=3] +[ext_resource path="res://components/ClickableComponent.tscn" type="PackedScene" id=4] [ext_resource path="res://icon.png" type="Texture" id=5] [node name="SimpleEntity" type="Node2D"] diff --git a/Entities/WanderingEntity.gd b/entities/WanderingEntity.gd similarity index 100% rename from Entities/WanderingEntity.gd rename to entities/WanderingEntity.gd diff --git a/Entities/WanderingEntity.tscn b/entities/WanderingEntity.tscn similarity index 63% rename from Entities/WanderingEntity.tscn rename to entities/WanderingEntity.tscn index 4266ead..79f2b63 100644 --- a/Entities/WanderingEntity.tscn +++ b/entities/WanderingEntity.tscn @@ -1,11 +1,11 @@ [gd_scene load_steps=7 format=2] -[ext_resource path="res://Components/TintedSpriteComponent.gd" type="Script" id=1] -[ext_resource path="res://Entities/WanderingEntity.gd" type="Script" id=2] -[ext_resource path="res://Components/ColorComponent.gd" type="Script" id=3] -[ext_resource path="res://Components/ClickableComponent.tscn" type="PackedScene" id=4] +[ext_resource path="res://components/TintedSpriteComponent.gd" type="Script" id=1] +[ext_resource path="res://entities/WanderingEntity.gd" type="Script" id=2] +[ext_resource path="res://components/ColorComponent.gd" type="Script" id=3] +[ext_resource path="res://components/ClickableComponent.tscn" type="PackedScene" id=4] [ext_resource path="res://icon.png" type="Texture" id=5] -[ext_resource path="res://Components/MovableComponent.gd" type="Script" id=6] +[ext_resource path="res://components/MovableComponent.gd" type="Script" id=6] [node name="WanderingEntity" type="Node2D"] script = ExtResource( 2 ) diff --git a/Materials/PhysicsObjects.tres b/materials/PhysicsObjects.tres similarity index 100% rename from Materials/PhysicsObjects.tres rename to materials/PhysicsObjects.tres diff --git a/project.godot b/project.godot index 4a4cfac..e6a2450 100644 --- a/project.godot +++ b/project.godot @@ -9,28 +9,34 @@ config_version=4 _global_script_classes=[ { -"base": "Node", +"base": "Reference", "class": "ClickableComponent", "language": "GDScript", -"path": "res://Components/ClickableComponent.gd" +"path": "res://components/ClickableComponent.gd" }, { -"base": "Node", +"base": "Reference", +"class": "CollisionLine", +"language": "GDScript", +"path": "res://utils/CollisionLine.gd" +}, { +"base": "Reference", "class": "ColorComponent", "language": "GDScript", -"path": "res://Components/ColorComponent.gd" +"path": "res://components/ColorComponent.gd" }, { "base": "Object", "class": "SpringDamper", "language": "GDScript", -"path": "res://Utils/SpringDamper.gd" +"path": "res://utils/SpringDamper.gd" }, { -"base": "Sprite", +"base": "Reference", "class": "TintedSpriteComponent", "language": "GDScript", -"path": "res://Components/TintedSpriteComponent.gd" +"path": "res://components/TintedSpriteComponent.gd" } ] _global_script_class_icons={ "ClickableComponent": "", +"CollisionLine": "", "ColorComponent": "", "SpringDamper": "", "TintedSpriteComponent": "" diff --git a/utils/CollisionLine.gd b/utils/CollisionLine.gd new file mode 100644 index 0000000..63fd55d --- /dev/null +++ b/utils/CollisionLine.gd @@ -0,0 +1,13 @@ +class_name CollisionLine +extends KinematicBody2D + +onready var collision = $CollisionShape2D + +func _ready(): + pass + +func _draw(): + if collision.shape is SegmentShape2D: + var segment_shape = collision.shape + draw_line (segment_shape.get_a(), segment_shape.get_b(), Color(1, 1, 0)) + diff --git a/Utils/SpringDamper.gd b/utils/SpringDamper.gd similarity index 100% rename from Utils/SpringDamper.gd rename to utils/SpringDamper.gd