Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@
* Баг прохождения игрока через коллайдеры при принятии положения лежа.

![image](https://github.com/magarich228/TDP5/assets/78496868/e8e352f7-186e-45a4-aea9-f5b1e19b06db)
![image](https://github.com/user-attachments/assets/ee89260b-6516-4b3f-95db-8120d7b0fa6a)
2 changes: 1 addition & 1 deletion Tdp 5.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Godot.NET.Sdk/4.2.0-rc.1">
<Project Sdk="Godot.NET.Sdk/4.3.0">
<PropertyGroup>
<TargetFramework>net6.0</TargetFramework>
<TargetFramework Condition=" '$(GodotTargetPlatform)' == 'android' ">net7.0</TargetFramework>
Expand Down
14 changes: 7 additions & 7 deletions Tdp 5.sln
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 2012
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tdp 5", "Tdp 5.csproj", "{73604F0A-1D7C-4DC9-9378-41C92D73B604}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Tdp 5", "Tdp 5.csproj", "{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -9,11 +9,11 @@ Global
ExportRelease|Any CPU = ExportRelease|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{73604F0A-1D7C-4DC9-9378-41C92D73B604}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{73604F0A-1D7C-4DC9-9378-41C92D73B604}.Debug|Any CPU.Build.0 = Debug|Any CPU
{73604F0A-1D7C-4DC9-9378-41C92D73B604}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{73604F0A-1D7C-4DC9-9378-41C92D73B604}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{73604F0A-1D7C-4DC9-9378-41C92D73B604}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{73604F0A-1D7C-4DC9-9378-41C92D73B604}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}.ExportDebug|Any CPU.ActiveCfg = ExportDebug|Any CPU
{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}.ExportDebug|Any CPU.Build.0 = ExportDebug|Any CPU
{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}.ExportRelease|Any CPU.ActiveCfg = ExportRelease|Any CPU
{0E6E8F5E-017B-4425-A305-C0E495AE9ED5}.ExportRelease|Any CPU.Build.0 = ExportRelease|Any CPU
EndGlobalSection
EndGlobal
Binary file added assets/map-tiles/boat_pack/boat.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 assets/map-tiles/boat_pack/boat.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://dyd2mk302g4bv"
path="res://.godot/imported/boat.png-f26ccc175fe318d431bba65ccfc545f4.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/map-tiles/boat_pack/boat.png"
dest_files=["res://.godot/imported/boat.png-f26ccc175fe318d431bba65ccfc545f4.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
Binary file added assets/map-tiles/boat_pack/front_boat.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 assets/map-tiles/boat_pack/front_boat.png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://cd447moy6p6sw"
path="res://.godot/imported/front_boat.png-65921552ec506361635dfcdca6ec53a7.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/map-tiles/boat_pack/front_boat.png"
dest_files=["res://.godot/imported/front_boat.png-65921552ec506361635dfcdca6ec53a7.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
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 assets/map-tiles/boat_pack/wm_enlarge_help (1).png.import
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
[remap]

importer="texture"
type="CompressedTexture2D"
uid="uid://ctvwvspmqe28l"
path="res://.godot/imported/wm_enlarge_help (1).png-8f1cfac864ab96b2476a9d813810b5ee.ctex"
metadata={
"vram_texture": false
}

[deps]

source_file="res://assets/map-tiles/boat_pack/wm_enlarge_help (1).png"
dest_files=["res://.godot/imported/wm_enlarge_help (1).png-8f1cfac864ab96b2476a9d813810b5ee.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
30 changes: 3 additions & 27 deletions guns/Ak47Gun.cs
Original file line number Diff line number Diff line change
@@ -1,35 +1,11 @@
using System;
using Godot;
using Tdp5.guns;

public partial class Ak47Gun : GunBase
{
public override PackedScene GunScene =>
public override PackedScene GunScene { get; } =
ResourceLoader.Load<PackedScene>("res://guns/Ak47Gun.tscn");

// Called when the node enters the scene tree for the first time.
public override void _Ready()
{
}

// Called every frame. 'delta' is the elapsed time since the previous frame.
public override void _Process(double delta)
{
}


public override void Shoot()
{
// TODO: фикс поворота пули.
var bullet = (Bullet)ResourceLoader.Load<PackedScene>("res://guns/bullet.tscn").Instantiate();

bullet.ZIndex = 1;
bullet.Position = new Vector2(
GlobalPosition.X,
GlobalPosition.Y);
bullet.GlobalRotation = GlobalRotation;
bullet.Rotate(Mathf.DegToRad(90f));

GetTree().Root.AddChild(bullet);
}
protected override PackedScene BulletScene { get; } =
ResourceLoader.Load<PackedScene>("res://guns/bullet.tscn");
}
35 changes: 24 additions & 11 deletions guns/Bullet.cs
Original file line number Diff line number Diff line change
@@ -1,30 +1,43 @@
using Godot;
using System;
using Godot;

public partial class Bullet : Node2D
{
// Godot public properties.
// ReSharper disable MemberCanBePrivate.Global
public const float Speed = 1800.0f;
// ReSharper restore MemberCanBePrivate.Global
public override void _Ready()

public override void _PhysicsProcess(double delta)
{
Position += new Vector2((float)Speed * (float)delta, 0)
.Rotated(GlobalRotation + Mathf.DegToRad(-90f));

//if (Position.X > GetViewportRect().Size.X)
//{
//QueueFree();
//}
//
//if (Position.X < 0)
//{
//QueueFree();
//}

base._PhysicsProcess(delta);
}

public override void _Process(double delta)
{
Position += new Vector2((float)Speed * (float)delta, 0)
.Rotated(GlobalRotation + Mathf.DegToRad(-90f));

if (Position.X > GetViewportRect().Size.X)
base._Process(delta);
}

private void _OnBodyEntered(Node2D body)
{
if (body is StaticBody2D)
{
QueueFree();
}

if (Position.X < 0)
{
QueueFree();
}
Console.WriteLine(body.GetType());
}
}
18 changes: 16 additions & 2 deletions guns/GunBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ namespace Tdp5.guns;
public abstract partial class GunBase : Node2D
{
public abstract PackedScene GunScene { get; }
protected abstract PackedScene BulletScene { get; }

public override void _Input(InputEvent @event)
{
if (@event is InputEventMouseButton mouseButtonEvent && mouseButtonEvent.ButtonIndex == MouseButton.Left)
if (@event is InputEventMouseButton {ButtonIndex: MouseButton.Left} mouseButtonEvent)
{
if (mouseButtonEvent.IsPressed())
{
Expand All @@ -18,5 +19,18 @@ public override void _Input(InputEvent @event)

base._Input(@event);
}
public abstract void Shoot();

protected virtual void Shoot()
{
var bullet = BulletScene.Instantiate<Bullet>();

bullet.ZIndex = 1;
bullet.Position = new Vector2(
GlobalPosition.X,
GlobalPosition.Y);
bullet.GlobalRotation = GlobalRotation;
bullet.Rotate(Mathf.DegToRad(90f));

GetTree().Root.AddChild(bullet);
}
}
8 changes: 5 additions & 3 deletions guns/bullet.tscn
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
[gd_scene load_steps=4 format=3 uid="uid://221emkilcxhc"]

[ext_resource type="Script" path="res://guns/Bullet.cs" id="1_6nxlb"]
[ext_resource type="Script" path="res://guns/Bullet.cs" id="1_cpxgm"]
[ext_resource type="Texture2D" uid="uid://q4xgn0tf1b1x" path="res://assets/guns/ak47bullet.png" id="2_np7oq"]

[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_al8o4"]
radius = 2.0
height = 32.0

[node name="Bullet" type="Node2D"]
scale = Vector2(0.541096, 0.541096)
script = ExtResource("1_6nxlb")
script = ExtResource("1_cpxgm")

[node name="bulletSprite" type="Sprite2D" parent="."]
scale = Vector2(0.00990099, 0.00990099)
Expand All @@ -19,3 +18,6 @@ texture = ExtResource("2_np7oq")

[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
shape = SubResource("CapsuleShape2D_al8o4")

[connection signal="area_entered" from="Area2D" to="." method="_OnAreaEntered"]
[connection signal="body_entered" from="Area2D" to="." method="_OnBodyEntered"]
2 changes: 1 addition & 1 deletion levels/testlevel.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[gd_scene load_steps=3 format=3 uid="uid://dtbdvkbvex0j3"]

[ext_resource type="PackedScene" uid="uid://dncbfkx3vm1xp" path="res://maps/testmap.tscn" id="1_mdbgx"]
[ext_resource type="PackedScene" uid="uid://bcavm6ggf6ur3" path="res://player/StickPlayer.tscn" id="2_t4ahk"]
[ext_resource type="PackedScene" uid="uid://bcavm6ggf6ur3" path="res://player/stickplayer.tscn" id="2_t4ahk"]

[node name="game" type="Node2D"]
position = Vector2(574, 329)
Expand Down
11 changes: 11 additions & 0 deletions levels/testlevel2.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[gd_scene load_steps=3 format=3 uid="uid://bemua34sh662x"]

[ext_resource type="PackedScene" uid="uid://bcavm6ggf6ur3" path="res://player/stickplayer.tscn" id="1_gmfu8"]
[ext_resource type="PackedScene" uid="uid://eog1210lv8nq" path="res://maps/testmap2.tscn" id="2_k1ecl"]

[node name="Testlevel2" type="Node2D"]

[node name="CharacterBody2D" parent="." instance=ExtResource("1_gmfu8")]
top_level = true

[node name="Testmap2" parent="." instance=ExtResource("2_k1ecl")]
59 changes: 59 additions & 0 deletions maps/testmap2.tscn
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
[gd_scene load_steps=2 format=3 uid="uid://eog1210lv8nq"]

[ext_resource type="Texture2D" uid="uid://ctvwvspmqe28l" path="res://assets/map-tiles/boat_pack/wm_enlarge_help (1).png" id="1_0xker"]

[node name="Testmap2" type="Node2D"]
scale = Vector2(1.68, 1.68)

[node name="WmEnlargeHelp(1)" type="Sprite2D" parent="."]
texture = ExtResource("1_0xker")

[node name="StaticBody2D" type="StaticBody2D" parent="."]

[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-892, -37, -878, 22, -853, 112, -826, 183, -790, 246, -743, 314, -725, 311, -678, 347, -660, 379, -625, 396, -579, 407, 72, 413, 70, 397, 201, 394, 247, 396, 259, 402, 267, 413, 502, 413, 557, 403, 704, 367, 816, 326, 974, 257, 1004, 177, 1022, 176, 1053, 68, 1060, 67, 1072, 26, 1095, 21, 1117, 7, 1133, -8, 1145, -11, 1198, -196, 1246, -203, 1310, -441, 1335, -445, 1327, -429, 1289, -281, 1270, -206, 1275, -200, 1273, -191, 1210, -144, 1203, -115, 1190, -112, 1168, -18, 1216, -25, 1216, -17, 1208, -10, 1199, 32, 1145, 41, 1126, 46, 1104, 64, 1077, 94, 1078, 106, 1087, 103, 1100, 90, 1115, 104, 1121, 109, 1121, 122, 1111, 121, 1090, 209, 1092, 231, 1097, 239, 1058, 454, 55, 457, -576, 453, -621, 444, -686, 418, -741, 376, -797, 316, -851, 231, -887, 196, -930, 153, -980, 114, -1042, 82, -1145, 64, -1348, 31, -1348, 16, -1068, 51, -1067, 17, -1051, 12, -1005, 15, -984, 11, -963, -2, -948, -23, -937, -43, -935, -61)

[node name="CollisionPolygon2D2" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-804, 223, -645, 236, -476, 245, -281, 254, 13, 248, 30, 246, 29, 268, 13, 268, 12, 255, -219, 263, -345, 259, -467, 255, -661, 243, -799, 232)

[node name="CollisionPolygon2D3" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(108, 240, 133, 243, 223, 240, 361, 230, 699, 199, 1024, 167, 1022, 178, 857, 191, 669, 212, 357, 237, 192, 249, 106, 253)

[node name="CollisionPolygon2D4" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-863, 76, -853, 75, -845, 105, -646, 125, -503, 138, -368, 145, -333, 143, -334, 109, -324, 104, -326, 93, -322, 91, -322, 78, -298, 78, -298, 89, -295, 93, -294, 107, -290, 108, -287, 144, -253, 145, -234, 153, -198, 153, -192, 144, 25, 141, 26, 152, 26, 166, 14, 166, 0, 158, -197, 163, -252, 164, -253, 178, -278, 177, -281, 209, -346, 209, -347, 176, -370, 175, -372, 155, -539, 149, -696, 133, -838, 122, -828, 142, -843, 141)

[node name="CollisionPolygon2D5" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(103, 165, 102, 142, 220, 137, 381, 120, 381, 112, 387, 79, 396, 76, 396, 48, 425, 47, 429, 56, 430, 75, 441, 82, 453, 112, 477, 116, 521, 113, 641, 100, 705, 92, 709, 80, 719, 72, 727, 69, 769, 66, 781, 70, 786, 81, 788, 85, 1061, 56, 1064, 53, 1060, 68, 784, 96, 596, 116, 464, 129, 464, 141, 440, 145, 439, 130, 393, 133, 393, 146, 371, 148, 371, 135, 198, 148, 124, 153, 124, 165)

[node name="CollisionPolygon2D6" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(1158, -62, 981, -39, 828, -21, 759, -13, 760, -4, 914, -23, 1147, -52, 1144, -38, 1152, -38)

[node name="CollisionPolygon2D7" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(730, 11, 730, -11, 531, 12, 532, 32, 548, 32, 548, 18, 719, 1, 718, 14)

[node name="CollisionPolygon2D8" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(326, 38, 326, 50, 340, 50, 339, 38)

[node name="CollisionPolygon2D9" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(434, 28, 434, 43, 451, 41, 450, 27)

[node name="CollisionPolygon2D10" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-325, 49, -201, 51, -69, 49, 72, 45, 272, 35, 287, 26, 287, 53, 272, 54, 271, 43, 197, 49, 198, 62, 130, 67, 129, 53, -79, 59, -243, 59, -325, 56)

[node name="CollisionPolygon2D11" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-370, 35, -359, 35, -361, 54, -365, 54, -366, 69, -383, 69, -382, 54, -529, 43, -654, 32, -816, 17, -865, 14, -864, 32, -875, 32, -887, -27, -849.999, -2.97619, -837, 5, -827.976, 7.73809, -820, 9, -633, 27, -434, 43, -370, 47)

[node name="CollisionPolygon2D12" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(754, -136, 754, -123, 771, -123, 770, -129, 964, -155, 1105, -175, 1195, -188, 1200, -195, 1151, -188, 1020, -171, 886, -152)

[node name="CollisionPolygon2D13" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(221, -56, 302, -61, 387, -68, 499, -78, 622, -91, 738, -103, 737, -97, 593, -82, 420, -66, 293, -55, 234, -51, 233, -39, 220, -38)

[node name="CollisionPolygon2D14" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(980, -258, 1270, -298, 1273, -307, 980, -265)

[node name="CollisionPolygon2D16" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(-790, -84, -672, -70, -564, -60, -491, -53, -491, -60, -547, -63, -618, -70, -715, -80, -789, -89)

[node name="CollisionPolygon2D15" type="CollisionPolygon2D" parent="StaticBody2D"]
polygon = PackedVector2Array(7.57575, 411.363, 7.57575, 383.333, 14.3939, 382.575, 15.9091, 339.394, 122.727, 342.424, 124.242, 393.181, 111.364, 394.697, 111.364, 354.545, 26.5151, 354.545, 27.2727, 386.363, 35.606, 387.121, 36.3636, 411.363)
Loading