From b2bed344674d47e24eca8b8e13c5e054e29e96fb Mon Sep 17 00:00:00 2001 From: Just Dzhi Date: Sun, 1 Oct 2023 18:47:42 +0400 Subject: [PATCH] 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