diff --git a/assets/Bordered_Black_Square.png b/assets/Bordered_Black_Square.png new file mode 100644 index 0000000..3026d70 Binary files /dev/null and b/assets/Bordered_Black_Square.png differ diff --git a/assets/Bordered_Black_Square.png.import b/assets/Bordered_Black_Square.png.import new file mode 100644 index 0000000..e2df577 --- /dev/null +++ b/assets/Bordered_Black_Square.png.import @@ -0,0 +1,34 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://bhx36hs83ynqs" +path="res://.godot/imported/Bordered_Black_Square.png-ff534a515f4750944c45a40d35861714.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/Bordered_Black_Square.png" +dest_files=["res://.godot/imported/Bordered_Black_Square.png-ff534a515f4750944c45a40d35861714.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 diff --git a/assets/arrow.svg b/assets/arrow.svg new file mode 100644 index 0000000..58dbd41 --- /dev/null +++ b/assets/arrow.svg @@ -0,0 +1 @@ +Trade_Icons \ No newline at end of file diff --git a/assets/arrow.svg.import b/assets/arrow.svg.import new file mode 100644 index 0000000..12cfb7d --- /dev/null +++ b/assets/arrow.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://dprlu0x5gcgon" +path="res://.godot/imported/arrow.svg-a996b9f5a5e99d25f45d2c6cd1a7999b.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/arrow.svg" +dest_files=["res://.godot/imported/arrow.svg-a996b9f5a5e99d25f45d2c6cd1a7999b.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 +svg/scale=1.0 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/assets/triangle.svg b/assets/triangle.svg new file mode 100644 index 0000000..489d930 --- /dev/null +++ b/assets/triangle.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/assets/triangle.svg.import b/assets/triangle.svg.import new file mode 100644 index 0000000..0ac5f46 --- /dev/null +++ b/assets/triangle.svg.import @@ -0,0 +1,37 @@ +[remap] + +importer="texture" +type="CompressedTexture2D" +uid="uid://s4iiumvei5wc" +path="res://.godot/imported/triangle.svg-2246efe0f7e4fdb6705e62b9f62230d2.ctex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://assets/triangle.svg" +dest_files=["res://.godot/imported/triangle.svg-2246efe0f7e4fdb6705e62b9f62230d2.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 +svg/scale=8.071 +editor/scale_with_editor_scale=false +editor/convert_colors_with_editor_theme=false diff --git a/game.tscn b/game.tscn index afe29a3..7322001 100644 --- a/game.tscn +++ b/game.tscn @@ -1,8 +1,15 @@ -[gd_scene load_steps=2 format=3 uid="uid://c0s77m0ea3sey"] +[gd_scene load_steps=4 format=3 uid="uid://c0s77m0ea3sey"] +[ext_resource type="Script" path="res://scripts/game.gd" id="1_41a5u"] [ext_resource type="PackedScene" uid="uid://dy71gkll44btc" path="res://scenes/player.tscn" id="1_geqht"] +[ext_resource type="PackedScene" uid="uid://c7todenm3hn4d" path="res://scenes/boat.tscn" id="2_qmvsn"] [node name="Game" type="Node2D"] +position = Vector2(559, 282) +script = ExtResource("1_41a5u") [node name="Player" parent="." instance=ExtResource("1_geqht")] -position = Vector2(567, 297) +position = Vector2(-685, -433) + +[node name="Boat" parent="." instance=ExtResource("2_qmvsn")] +position = Vector2(-642, -351) diff --git a/project.godot b/project.godot index 37ebab5..7898742 100644 --- a/project.godot +++ b/project.godot @@ -14,3 +14,43 @@ config/name="BoatCoop" run/main_scene="res://game.tscn" config/features=PackedStringArray("4.3", "Forward Plus") config/icon="res://icon.svg" + +[editor] + +version_control/plugin_name="GitPlugin" +version_control/autoload_on_startup=true + +[input] + +ui_left={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194319,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":13,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":-1.0,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":65,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +ui_right={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194321,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":14,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":0,"axis_value":1.0,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":68,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +ui_up={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194320,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":11,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":-1.0,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":87,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} +ui_down={ +"deadzone": 0.5, +"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":4194322,"physical_keycode":0,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +, Object(InputEventJoypadButton,"resource_local_to_scene":false,"resource_name":"","device":0,"button_index":12,"pressure":0.0,"pressed":false,"script":null) +, Object(InputEventJoypadMotion,"resource_local_to_scene":false,"resource_name":"","device":0,"axis":1,"axis_value":1.0,"script":null) +, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":83,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null) +] +} diff --git a/scenes/barrier.tscn b/scenes/barrier.tscn new file mode 100644 index 0000000..6fa1c14 --- /dev/null +++ b/scenes/barrier.tscn @@ -0,0 +1,26 @@ +[gd_scene load_steps=4 format=3 uid="uid://crxp1lat0mj1n"] + +[sub_resource type="Gradient" id="Gradient_7c5k4"] +offsets = PackedFloat32Array(0, 0.00371747, 0.736059, 0.754647, 1) +colors = PackedColorArray(0, 0, 0, 1, 0.94902, 0.0509804, 0.0509804, 1, 0.15042, 0.503262, 0.834652, 1, 0.117488, 0.521912, 0.866968, 1, 0.94902, 0.0509804, 0.0509804, 1) + +[sub_resource type="GradientTexture2D" id="GradientTexture2D_eesv4"] +gradient = SubResource("Gradient_7c5k4") +fill_from = Vector2(1, 0) +fill_to = Vector2(0, 1) + +[sub_resource type="SegmentShape2D" id="SegmentShape2D_dliv6"] +b = Vector2(0, 27.7419) + +[node name="Barrier" type="StaticBody2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(5.96046e-08, 0) +scale = Vector2(0.203125, 2.01563) +texture = SubResource("GradientTexture2D_eesv4") + +[node name="CollisionShape2D" type="CollisionShape2D" parent="."] +position = Vector2(-3.8147e-06, -65) +scale = Vector2(4.65, 4.65) +shape = SubResource("SegmentShape2D_dliv6") +one_way_collision_margin = 66.3 diff --git a/scenes/boa1545.tmp b/scenes/boa1545.tmp new file mode 100644 index 0000000..0be8631 --- /dev/null +++ b/scenes/boa1545.tmp @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null +barrier_scene = null diff --git a/scenes/boa3EE7.tmp b/scenes/boa3EE7.tmp new file mode 100644 index 0000000..1d52096 --- /dev/null +++ b/scenes/boa3EE7.tmp @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null diff --git a/scenes/boa51BE.tmp b/scenes/boa51BE.tmp new file mode 100644 index 0000000..1d52096 --- /dev/null +++ b/scenes/boa51BE.tmp @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null diff --git a/scenes/boa68D0.tmp b/scenes/boa68D0.tmp new file mode 100644 index 0000000..1d52096 --- /dev/null +++ b/scenes/boa68D0.tmp @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null diff --git a/scenes/boa8867.tmp b/scenes/boa8867.tmp new file mode 100644 index 0000000..1d52096 --- /dev/null +++ b/scenes/boa8867.tmp @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null diff --git a/scenes/boa9849.tmp b/scenes/boa9849.tmp new file mode 100644 index 0000000..860dcd3 --- /dev/null +++ b/scenes/boa9849.tmp @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") diff --git a/scenes/boa99FC.tmp b/scenes/boa99FC.tmp new file mode 100644 index 0000000..0be8631 --- /dev/null +++ b/scenes/boa99FC.tmp @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null +barrier_scene = null diff --git a/scenes/boaB2D7.tmp b/scenes/boaB2D7.tmp new file mode 100644 index 0000000..860dcd3 --- /dev/null +++ b/scenes/boaB2D7.tmp @@ -0,0 +1,7 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") diff --git a/scenes/boaBB59.tmp b/scenes/boaBB59.tmp new file mode 100644 index 0000000..1d52096 --- /dev/null +++ b/scenes/boaBB59.tmp @@ -0,0 +1,8 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null diff --git a/scenes/boaCF4E.tmp b/scenes/boaCF4E.tmp new file mode 100644 index 0000000..0be8631 --- /dev/null +++ b/scenes/boaCF4E.tmp @@ -0,0 +1,9 @@ +[gd_scene load_steps=2 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") +tile_scene = null +barrier_scene = null diff --git a/scenes/boat.tscn b/scenes/boat.tscn new file mode 100644 index 0000000..a7769f4 --- /dev/null +++ b/scenes/boat.tscn @@ -0,0 +1,13 @@ +[gd_scene load_steps=4 format=3 uid="uid://c7todenm3hn4d"] + +[ext_resource type="Script" path="res://scripts/boat.gd" id="1_brclq"] +[ext_resource type="PackedScene" uid="uid://bmxg7u37aon0o" path="res://scenes/tile.tscn" id="2_b8wau"] +[ext_resource type="PackedScene" uid="uid://crxp1lat0mj1n" path="res://scenes/barrier.tscn" id="3_mdatr"] + +[node name="Boat" type="Node2D"] +position = Vector2(5, -2) +script = ExtResource("1_brclq") + +[node name="Tile" parent="." instance=ExtResource("2_b8wau")] + +[node name="Barrier" parent="." instance=ExtResource("3_mdatr")] diff --git a/scenes/gam25FD.tmp b/scenes/gam25FD.tmp new file mode 100644 index 0000000..e5cd615 --- /dev/null +++ b/scenes/gam25FD.tmp @@ -0,0 +1,30 @@ +[gd_scene load_steps=6 format=3 uid="uid://c0s77m0ea3sey"] + +[ext_resource type="Script" path="res://scripts/game.gd" id="1_g5flc"] +[ext_resource type="PackedScene" uid="uid://dy71gkll44btc" path="res://scenes/player.tscn" id="2_3msrq"] +[ext_resource type="PackedScene" uid="uid://c7todenm3hn4d" path="res://scenes/boat.tscn" id="3_5kild"] +[ext_resource type="PackedScene" uid="uid://bmxg7u37aon0o" path="res://scenes/tile.tscn" id="4_cd0bw"] + +[sub_resource type="SegmentShape2D" id="SegmentShape2D_dliv6"] + +[node name="Game" type="Node2D"] +position = Vector2(552, 300) +script = ExtResource("1_g5flc") + +[node name="Player" parent="." instance=ExtResource("2_3msrq")] +z_index = 1 +position = Vector2(-546, -300) + +[node name="Boat" parent="." instance=ExtResource("3_5kild")] +position = Vector2(-548, -304) + +[node name="Tile" parent="Boat" instance=ExtResource("4_cd0bw")] +position = Vector2(6, 6) + +[node name="Barrier" type="StaticBody2D" parent="Boat"] + +[node name="Sprite2D" type="Sprite2D" parent="Boat/Barrier"] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Boat/Barrier"] +shape = SubResource("SegmentShape2D_dliv6") +one_way_collision_margin = 63.0 diff --git a/scenes/plaE0E6.tmp b/scenes/plaE0E6.tmp new file mode 100644 index 0000000..01b8b94 --- /dev/null +++ b/scenes/plaE0E6.tmp @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://dy71gkll44btc"] + +[ext_resource type="Script" path="res://scripts/player.gd" id="1_jlots"] +[ext_resource type="Texture2D" uid="uid://s4iiumvei5wc" path="res://assets/triangle.svg" id="2_jjceo"] + +[node name="Player" type="CharacterBody2D"] +motion_mode = 1 +script = ExtResource("1_jlots") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +position = Vector2(-14, 2.86102e-06) +rotation = 1.58969 +scale = Vector2(0.998311, 1.01563) +polygon = PackedVector2Array(-9.03255, -0.816984, -0.51107, -26.5797, 8.99469, -1.15189) + +[node name="Sprite2D2" type="Sprite2D" parent="."] +position = Vector2(0, -9.53674e-07) +rotation = -1.5708 +scale = Vector2(0.230709, 0.642787) +texture = ExtResource("2_jjceo") diff --git a/scenes/plaE0E7.tmp b/scenes/plaE0E7.tmp new file mode 100644 index 0000000..01b8b94 --- /dev/null +++ b/scenes/plaE0E7.tmp @@ -0,0 +1,20 @@ +[gd_scene load_steps=3 format=3 uid="uid://dy71gkll44btc"] + +[ext_resource type="Script" path="res://scripts/player.gd" id="1_jlots"] +[ext_resource type="Texture2D" uid="uid://s4iiumvei5wc" path="res://assets/triangle.svg" id="2_jjceo"] + +[node name="Player" type="CharacterBody2D"] +motion_mode = 1 +script = ExtResource("1_jlots") + +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +position = Vector2(-14, 2.86102e-06) +rotation = 1.58969 +scale = Vector2(0.998311, 1.01563) +polygon = PackedVector2Array(-9.03255, -0.816984, -0.51107, -26.5797, 8.99469, -1.15189) + +[node name="Sprite2D2" type="Sprite2D" parent="."] +position = Vector2(0, -9.53674e-07) +rotation = -1.5708 +scale = Vector2(0.230709, 0.642787) +texture = ExtResource("2_jjceo") diff --git a/scenes/player.tscn b/scenes/player.tscn index f9cbaf7..01b8b94 100644 --- a/scenes/player.tscn +++ b/scenes/player.tscn @@ -1,23 +1,20 @@ -[gd_scene load_steps=5 format=3 uid="uid://dy71gkll44btc"] +[gd_scene load_steps=3 format=3 uid="uid://dy71gkll44btc"] [ext_resource type="Script" path="res://scripts/player.gd" id="1_jlots"] - -[sub_resource type="RectangleShape2D" id="RectangleShape2D_scfaw"] -size = Vector2(80, 124) - -[sub_resource type="Gradient" id="Gradient_pnm6c"] -colors = PackedColorArray(1, 1, 1, 1, 1, 1, 1, 1) - -[sub_resource type="GradientTexture1D" id="GradientTexture1D_wyt1d"] -gradient = SubResource("Gradient_pnm6c") +[ext_resource type="Texture2D" uid="uid://s4iiumvei5wc" path="res://assets/triangle.svg" id="2_jjceo"] [node name="Player" type="CharacterBody2D"] motion_mode = 1 script = ExtResource("1_jlots") -[node name="CollisionShape2D" type="CollisionShape2D" parent="."] -shape = SubResource("RectangleShape2D_scfaw") +[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="."] +position = Vector2(-14, 2.86102e-06) +rotation = 1.58969 +scale = Vector2(0.998311, 1.01563) +polygon = PackedVector2Array(-9.03255, -0.816984, -0.51107, -26.5797, 8.99469, -1.15189) -[node name="Sprite2D" type="Sprite2D" parent="."] -scale = Vector2(0.3125, 126) -texture = SubResource("GradientTexture1D_wyt1d") +[node name="Sprite2D2" type="Sprite2D" parent="."] +position = Vector2(0, -9.53674e-07) +rotation = -1.5708 +scale = Vector2(0.230709, 0.642787) +texture = ExtResource("2_jjceo") diff --git a/scenes/tile.tscn b/scenes/tile.tscn new file mode 100644 index 0000000..9048b2d --- /dev/null +++ b/scenes/tile.tscn @@ -0,0 +1,10 @@ +[gd_scene load_steps=2 format=3 uid="uid://bmxg7u37aon0o"] + +[ext_resource type="Texture2D" uid="uid://bhx36hs83ynqs" path="res://assets/Bordered_Black_Square.png" id="1_bgcjk"] + +[node name="Tile" type="Node2D"] + +[node name="Sprite2D" type="Sprite2D" parent="."] +position = Vector2(0, 2.28882e-05) +scale = Vector2(0.074, 0.0740913) +texture = ExtResource("1_bgcjk") diff --git a/scripts/boat.gd b/scripts/boat.gd new file mode 100644 index 0000000..dd0145a --- /dev/null +++ b/scripts/boat.gd @@ -0,0 +1,70 @@ +extends Node2D + +@export var tile_scene: PackedScene = preload("res://scenes/tile.tscn") +@export var barrier_scene: PackedScene = preload("res://scenes/barrier.tscn") +var tiles = [] +var tile_size = 128.0 +var test_broken_tiles = true +const boatSize = 5 +var speed = 100 +var velocity = Vector2() + +func _ready(): + spawn_boat_tiles() + spawn_boat_barriers() + +func spawn_boat_tiles(): + tiles.clear() + + for y in range(boatSize): + var row = [] + for x in range(boatSize): + if test_broken_tiles && randf() < 0.7 || (x == floor(boatSize/2) && y == floor(boatSize/2)): # 70% de chance de spawn une tuile pour tester les bateaux incomplets + var tile = tile_scene.instantiate() + add_child(tile) + + #Positionner les tuiles pour que l'on spawne toujours au centre + tile.position = Vector2( + (x - ((boatSize - 1) * 0.5)) * tile_size, + (y - ((boatSize - 1) * 0.5)) * tile_size + ) + + row.append(tile) + else: + row.append(null) # On garde la structure mais on marque la tuile manquante + tiles.append(row) + + +func spawn_boat_barriers(): + for x in range(tiles.size()): + for y in range(tiles[x].size()): + if tiles[x][y]: + var x_pos = [null,null,null,null]; + var y_pos = [null,null,null,null]; + var rotations = [90, 180, 270, 360] + if x == 0 || !tiles[x-1][y]: + x_pos[0] = tiles[x][y].position.x + y_pos[0] = tiles[x][y].position.y - (tile_size/2) + if y == 0 || !tiles[x][y-1]: + x_pos[1] = tiles[x][y].position.x - (tile_size/2) + y_pos[1] = tiles[x][y].position.y + if x == tiles.size()-1 || !tiles[x+1][y]: + x_pos[2] = tiles[x][y].position.x + y_pos[2] = tiles[x][y].position.y + (tile_size/2) + if y == tiles[x].size()-1 || !tiles[x][y+1]: + x_pos[3] = tiles[x][y].position.x + (tile_size/2) + y_pos[3] = tiles[x][y].position.y + for z in range(4): + if x_pos[z] != null && y_pos[z] != null: + var barrier = barrier_scene.instantiate() + add_child(barrier) + barrier.position = Vector2( + x_pos[z], + y_pos[z] + ) + # On applique la rotation à la barrière + barrier.rotation = deg_to_rad(rotations[z]) + +func _physics_process(delta): + #Just spinning + rotation += delta/2 diff --git a/scripts/game.gd b/scripts/game.gd new file mode 100644 index 0000000..69fafcd --- /dev/null +++ b/scripts/game.gd @@ -0,0 +1,27 @@ +extends Node2D + +@export var player_scene: PackedScene = preload("res://scenes/player.tscn") +@export var boat_scene: PackedScene = preload("res://scenes/boat.tscn") + +var player_instance: CharacterBody2D +var boat_instance: Node2D + +func _ready(): + # On enlève les scènes par défau + var default_boat = $Boat + var default_player = $Player + if default_boat: + default_boat.queue_free() + if default_player: + default_player.queue_free() + + # On instancie les scènes que l'on veut garder + boat_instance = boat_scene.instantiate() + player_instance = player_scene.instantiate() + + # On ajoue les scènes essentielles à la scène principale + add_child(boat_instance) + add_child(player_instance) + + # Et on assigne le bateau au joueur + player_instance.boat = boat_instance diff --git a/scripts/player.gd b/scripts/player.gd index 5f3b468..05d3c9b 100644 --- a/scripts/player.gd +++ b/scripts/player.gd @@ -1,10 +1,48 @@ extends CharacterBody2D const SPEED = 300.0 -const JUMP_VELOCITY = -400.0 +@export var boat: Node2D -func _physics_process(delta): - velocity.x = Input.get_axis("ui_left", "ui_right") * SPEED - velocity.y = Input.get_axis("ui_up", "ui_down") * SPEED +const TILE_SIZE = 128 +var relative_position_on_boat = Vector2(0, 0) +var is_on_boat = true +var last_boat_rotation = 0.0 - move_and_slide() +func _ready(): + if boat: + relative_position_on_boat = position - boat.position + last_boat_rotation = boat.rotation + +func _physics_process(_delta): + # On tourne le joueur vers la souris + var mouse_position = get_global_mouse_position() + look_at(mouse_position) + if is_on_boat: + if boat: + # On calcule la difference de rotation du bateau depuis le dernier mouvement + var delta_rotation = boat.rotation - last_boat_rotation + + # On adape la position du joueur en fonction de la nouvelle rota + relative_position_on_boat = relative_position_on_boat.rotated(delta_rotation) + position = boat.position + relative_position_on_boat + + # On autorise le joueur à se déplacer dans le bateau + velocity.x = Input.get_axis("ui_left", "ui_right") * SPEED + velocity.y = Input.get_axis("ui_up", "ui_down") * SPEED + + move_and_slide() + + # Mise à jour des paramètres pour le déplacement du joueur en fonction du bateau + relative_position_on_boat = position - boat.position + last_boat_rotation = boat.rotation + + else: + # Quand on est pas sur le bateau, on se déplace librement (le lapin surtout) + velocity.x = Input.get_axis("ui_left", "ui_right") * SPEED/2 + velocity.y = Input.get_axis("ui_up", "ui_down") * SPEED/2 + + move_and_slide() + +func set_on_boat(on_boat: bool): + #TODO + is_on_boat = on_boat