From f8f67c98391619f4aa2b7da9063cd1475b8da005 Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Sun, 1 Oct 2023 18:37:28 +0400 Subject: [PATCH 1/3] #TODO Rat --- res/shaders/colorize.tres | 4 +- src/models/enemies/rat/Rat.gd | 2 + src/models/enemies/rat/Rat.tscn | 23 ++++++++++++ src/models/enemies/rat/sprites/rat.png | Bin 0 -> 572 bytes src/models/enemies/rat/sprites/rat.png.import | 35 ++++++++++++++++++ .../enemies/rat/sprites/rat_spriteframes.tres | 27 ++++++++++++++ 6 files changed, 89 insertions(+), 2 deletions(-) create mode 100644 src/models/enemies/rat/Rat.gd create mode 100644 src/models/enemies/rat/Rat.tscn create mode 100644 src/models/enemies/rat/sprites/rat.png create mode 100644 src/models/enemies/rat/sprites/rat.png.import create mode 100644 src/models/enemies/rat/sprites/rat_spriteframes.tres diff --git a/res/shaders/colorize.tres b/res/shaders/colorize.tres index dcdce01..f7d36b5 100644 --- a/res/shaders/colorize.tres +++ b/res/shaders/colorize.tres @@ -15,5 +15,5 @@ void fragment(){ [resource] shader = SubResource( 3 ) -shader_param/active = true -shader_param/color = Color( 1, 1, 1, 0 ) +shader_param/active = false +shader_param/color = Color( 1, 1, 1, 1 ) diff --git a/src/models/enemies/rat/Rat.gd b/src/models/enemies/rat/Rat.gd new file mode 100644 index 0000000..cf49cba --- /dev/null +++ b/src/models/enemies/rat/Rat.gd @@ -0,0 +1,2 @@ +extends KinematicBody2D + diff --git a/src/models/enemies/rat/Rat.tscn b/src/models/enemies/rat/Rat.tscn new file mode 100644 index 0000000..a359e3b --- /dev/null +++ b/src/models/enemies/rat/Rat.tscn @@ -0,0 +1,23 @@ +[gd_scene load_steps=4 format=2] + +[ext_resource path="res://src/models/enemies/rat/sprites/rat_spriteframes.tres" type="SpriteFrames" id=1] +[ext_resource path="res://src/models/enemies/rat/Rat.gd" type="Script" id=2] + +[sub_resource type="RectangleShape2D" id=1] +extents = Vector2( 8, 3 ) + +[node name="Rat" type="KinematicBody2D" groups=["enemy"]] +script = ExtResource( 2 ) + +[node name="Sprite" type="AnimatedSprite" parent="."] +frames = ExtResource( 1 ) +animation = "idle" +frame = 2 +playing = true +centered = false + +[node name="Area2D" type="Area2D" parent="."] + +[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"] +position = Vector2( 12, 6 ) +shape = SubResource( 1 ) diff --git a/src/models/enemies/rat/sprites/rat.png b/src/models/enemies/rat/sprites/rat.png new file mode 100644 index 0000000000000000000000000000000000000000..93f6ff18d0b20199af2229343e3b695d143c7dc2 GIT binary patch literal 572 zcmV-C0>k}@P)Px$_DMuRR9J=WmN9GFP!Pxe7xD=jJSvMjc!>!Dt@#c@kAR>WN=J8br+f=RL1QKb zyx8aqbn5CLiYE{Cq|xBD<8`p^@gzODj;$sT^ao?<>E8Wx=ev6bdiCn{b|Sf8W~+f8 zx$=OrG(R6m^eVi6ao!8>@}(P%7XSccX-;jnU8v_BR%-{=9E%+Tz-GM#01QV14fP`z z$5d2XrM{GRD(AiNF7(RHJ(u6`BbT#ZA5D8UVZ+ft!)%Hv;X>^=ri1~YP`jql89eb{ zs2%*sZLC{gs)P6rasMZ;o<}pE<_IM}av8V#8~^rq#hFxzO)({$@xE%x1k!vl)6b?n zu~pQ`yeUs8rUU@&Tmr+GE?vZ@f)FYQC9Vdy%lI1cppi$-yr}IX`DAHM(#o6l7OQ1J z07xojv)*E}-cpw4^z+jrNu|seGg3iV@!8rH7G7<9P|4Nz=5rN_)w(at6v+kh9E>T+Y&*#-0NJJRA-5e3mtoKkD~CKOohjf)LL9 z0|21x6ij)t2O4KZooA{%GxR^TvFGq=Sav}Ir^dHh7FLGDrh*XHi>p?fUcGv~mi_`V#jSpHpq)qn0000< KMNUMnLSTZb(hLm% literal 0 HcmV?d00001 diff --git a/src/models/enemies/rat/sprites/rat.png.import b/src/models/enemies/rat/sprites/rat.png.import new file mode 100644 index 0000000..ee7c2f4 --- /dev/null +++ b/src/models/enemies/rat/sprites/rat.png.import @@ -0,0 +1,35 @@ +[remap] + +importer="texture" +type="StreamTexture" +path="res://.import/rat.png-e73e7b6a730462f71668a742e225b538.stex" +metadata={ +"vram_texture": false +} + +[deps] + +source_file="res://src/models/enemies/rat/sprites/rat.png" +dest_files=[ "res://.import/rat.png-e73e7b6a730462f71668a742e225b538.stex" ] + +[params] + +compress/mode=0 +compress/lossy_quality=0.7 +compress/hdr_mode=0 +compress/bptc_ldr=0 +compress/normal_map=0 +flags/repeat=0 +flags/filter=false +flags/mipmaps=false +flags/anisotropic=false +flags/srgb=2 +process/fix_alpha_border=true +process/premult_alpha=false +process/HDR_as_SRGB=false +process/invert_color=false +process/normal_map_invert_y=false +stream=false +size_limit=0 +detect_3d=false +svg/scale=1.0 diff --git a/src/models/enemies/rat/sprites/rat_spriteframes.tres b/src/models/enemies/rat/sprites/rat_spriteframes.tres new file mode 100644 index 0000000..7fedab7 --- /dev/null +++ b/src/models/enemies/rat/sprites/rat_spriteframes.tres @@ -0,0 +1,27 @@ +[gd_resource type="SpriteFrames" load_steps=6 format=2] + +[ext_resource path="res://src/models/enemies/rat/sprites/rat.png" type="Texture" id=1] + +[sub_resource type="AtlasTexture" id=1] +atlas = ExtResource( 1 ) +region = Rect2( 0, 0, 28, 11 ) + +[sub_resource type="AtlasTexture" id=2] +atlas = ExtResource( 1 ) +region = Rect2( 28, 0, 28, 11 ) + +[sub_resource type="AtlasTexture" id=3] +atlas = ExtResource( 1 ) +region = Rect2( 56, 0, 28, 11 ) + +[sub_resource type="AtlasTexture" id=4] +atlas = ExtResource( 1 ) +region = Rect2( 84, 0, 28, 11 ) + +[resource] +animations = [ { +"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ) ], +"loop": true, +"name": "idle", +"speed": 12.0 +} ] From b2bed344674d47e24eca8b8e13c5e054e29e96fb Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Sun, 1 Oct 2023 18:47:42 +0400 Subject: [PATCH 2/3] Rat --- res/shaders/colorize.tres | 4 ++-- src/models/enemies/rat/Rat.gd | 11 ++++++++++- src/models/enemies/rat/Rat.tscn | 2 +- src/models/player/Player.tscn | 2 +- src/scenes/game/Game.tscn | 6 +++++- 5 files changed, 19 insertions(+), 6 deletions(-) diff --git a/res/shaders/colorize.tres b/res/shaders/colorize.tres index f7d36b5..dcdce01 100644 --- a/res/shaders/colorize.tres +++ b/res/shaders/colorize.tres @@ -15,5 +15,5 @@ void fragment(){ [resource] shader = SubResource( 3 ) -shader_param/active = false -shader_param/color = Color( 1, 1, 1, 1 ) +shader_param/active = true +shader_param/color = Color( 1, 1, 1, 0 ) diff --git a/src/models/enemies/rat/Rat.gd b/src/models/enemies/rat/Rat.gd index cf49cba..6a5786f 100644 --- a/src/models/enemies/rat/Rat.gd +++ b/src/models/enemies/rat/Rat.gd @@ -1,2 +1,11 @@ -extends KinematicBody2D +extends EnemyClass +onready var player = $"../../Player" +var velocity = Vector2.ZERO +var speed = 48 + +func _process(delta): + $Sprite.flip_h = true if player.global_position.x > self.global_position.x else false + +func _physics_process(delta): + global_position = global_position.move_toward(player.global_position + Vector2(8, 8), speed * delta * speed_multiplier) diff --git a/src/models/enemies/rat/Rat.tscn b/src/models/enemies/rat/Rat.tscn index a359e3b..e1b47e9 100644 --- a/src/models/enemies/rat/Rat.tscn +++ b/src/models/enemies/rat/Rat.tscn @@ -6,7 +6,7 @@ [sub_resource type="RectangleShape2D" id=1] extents = Vector2( 8, 3 ) -[node name="Rat" type="KinematicBody2D" groups=["enemy"]] +[node name="Rat" type="KinematicBody2D" groups=["enemy", "rat"]] script = ExtResource( 2 ) [node name="Sprite" type="AnimatedSprite" parent="."] diff --git a/src/models/player/Player.tscn b/src/models/player/Player.tscn index c1a8aab..c39d192 100644 --- a/src/models/player/Player.tscn +++ b/src/models/player/Player.tscn @@ -48,7 +48,7 @@ tracks/0/loop_wrap = true tracks/0/imported = false tracks/0/enabled = true tracks/0/keys = { -"times": PoolRealArray( 0, 0.9 ), +"times": PoolRealArray( 0, 2 ), "transitions": PoolRealArray( 1, 1 ), "update": 1, "values": [ true, false ] diff --git a/src/scenes/game/Game.tscn b/src/scenes/game/Game.tscn index 94a15ca..88c6a6a 100644 --- a/src/scenes/game/Game.tscn +++ b/src/scenes/game/Game.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=21 format=2] +[gd_scene load_steps=22 format=2] [ext_resource path="res://src/scenes/menu/background/background.png" type="Texture" id=1] [ext_resource path="res://src/scenes/game/sprites/background_houses.png" type="Texture" id=2] @@ -16,6 +16,7 @@ [ext_resource path="res://src/models/enemies/bat/Bat.tscn" type="PackedScene" id=14] [ext_resource path="res://src/models/enemies/ghost/Ghost.tscn" type="PackedScene" id=15] [ext_resource path="res://src/scenes/game/spell_recharge_bar.gd" type="Script" id=16] +[ext_resource path="res://src/models/enemies/rat/Rat.tscn" type="PackedScene" id=17] [sub_resource type="RectangleShape2D" id=2] extents = Vector2( 10, 60 ) @@ -88,6 +89,9 @@ position = Vector2( 142, 54 ) [node name="Ghost" parent="View/Enemies" instance=ExtResource( 15 )] position = Vector2( 509, 100 ) +[node name="Rat" parent="View/Enemies" instance=ExtResource( 17 )] +position = Vector2( 93, 72 ) + [node name="UIWrapper" type="CanvasLayer" parent="."] layer = 3 From 10e53ffc0980666b7fa83b6b96e31119bb68d2bc Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Sun, 1 Oct 2023 18:48:49 +0400 Subject: [PATCH 3/3] fix rat hp --- src/models/enemies/rat/Rat.gd | 3 +++ src/models/enemies/rat/Rat.tscn | 1 - 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/models/enemies/rat/Rat.gd b/src/models/enemies/rat/Rat.gd index 6a5786f..eed9687 100644 --- a/src/models/enemies/rat/Rat.gd +++ b/src/models/enemies/rat/Rat.gd @@ -4,6 +4,9 @@ onready var player = $"../../Player" var velocity = Vector2.ZERO var speed = 48 +func _ready(): + hp = 15 + func _process(delta): $Sprite.flip_h = true if player.global_position.x > self.global_position.x else false diff --git a/src/models/enemies/rat/Rat.tscn b/src/models/enemies/rat/Rat.tscn index e1b47e9..b02646e 100644 --- a/src/models/enemies/rat/Rat.tscn +++ b/src/models/enemies/rat/Rat.tscn @@ -12,7 +12,6 @@ script = ExtResource( 2 ) [node name="Sprite" type="AnimatedSprite" parent="."] frames = ExtResource( 1 ) animation = "idle" -frame = 2 playing = true centered = false