Luna Brovchuk 2023-10-01 16:14:35 +02:00
commit d67d1568ee
8 changed files with 61 additions and 46 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -1,35 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/trash_can.png-0987d8f67e93f5b32fac39729f87305a.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://src/models/enemies/trash_can/sprites/trash_can.png"
dest_files=[ "res://.import/trash_can.png-0987d8f67e93f5b32fac39729f87305a.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

View File

@ -1,6 +1,6 @@
[gd_scene load_steps=8 format=2] [gd_scene load_steps=8 format=2]
[ext_resource path="res://src/models/player/sprite.png" type="Texture" id=1] [ext_resource path="res://src/models/player/sprites/player_spriteframes.tres" type="SpriteFrames" id=1]
[ext_resource path="res://src/models/player/player.gd" type="Script" id=2] [ext_resource path="res://src/models/player/player.gd" type="Script" id=2]
[ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3] [ext_resource path="res://res/shaders/colorize.tres" type="Material" id=3]
@ -69,9 +69,11 @@ tracks/1/keys = {
[node name="Player" type="KinematicBody2D" groups=["player"]] [node name="Player" type="KinematicBody2D" groups=["player"]]
script = ExtResource( 2 ) script = ExtResource( 2 )
[node name="Sprite" type="Sprite" parent="."] [node name="Sprite" type="AnimatedSprite" parent="."]
material = ExtResource( 3 ) material = ExtResource( 3 )
texture = ExtResource( 1 ) frames = ExtResource( 1 )
animation = "idle"
playing = true
centered = false centered = false
[node name="WallCollision" type="CollisionShape2D" parent="."] [node name="WallCollision" type="CollisionShape2D" parent="."]

View File

@ -37,11 +37,6 @@ func draw_dashed_line(from, to, color, width, dash_length = 4, cap_end = false,
if cap_end: if cap_end:
draw_line(segment_start, to, color, width, antialiased) draw_line(segment_start, to, color, width, antialiased)
func _process(_delta):
if Input.is_action_just_pressed("shoot"):
_shoot()
update()
func get_input(): func get_input():
var input_direction = Input.get_vector("left", "right", "up", "down") var input_direction = Input.get_vector("left", "right", "up", "down")
velocity = input_direction * speed velocity = input_direction * speed
@ -77,6 +72,15 @@ func _draw():
var dist2enemy = position.distance_to(target.global_position) var dist2enemy = position.distance_to(target.global_position)
draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1) draw_dashed_line(Vector2(12, 12), target.global_position - self.global_position + Vector2(8, 7), Color("ffde00"), 1)
func _process(_delta):
$Sprite.play("idle") if velocity == Vector2.ZERO else $Sprite.play("run")
if abs(velocity.x) > 10:
$Sprite.flip_h = true if velocity.x < 0 else false
if Input.is_action_just_pressed("shoot"):
_shoot()
update()
func _physics_process(delta): func _physics_process(delta):
get_input() get_input()

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

View File

@ -0,0 +1,44 @@
[gd_resource type="SpriteFrames" load_steps=9 format=2]
[ext_resource path="res://src/models/player/sprites/run.png" type="Texture" id=1]
[sub_resource type="AtlasTexture" id=7]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 22, 25 )
[sub_resource type="AtlasTexture" id=1]
atlas = ExtResource( 1 )
region = Rect2( 0, 0, 22, 25 )
[sub_resource type="AtlasTexture" id=2]
atlas = ExtResource( 1 )
region = Rect2( 22, 0, 22, 25 )
[sub_resource type="AtlasTexture" id=3]
atlas = ExtResource( 1 )
region = Rect2( 44, 0, 22, 25 )
[sub_resource type="AtlasTexture" id=4]
atlas = ExtResource( 1 )
region = Rect2( 66, 0, 22, 25 )
[sub_resource type="AtlasTexture" id=5]
atlas = ExtResource( 1 )
region = Rect2( 88, 0, 22, 25 )
[sub_resource type="AtlasTexture" id=6]
atlas = ExtResource( 1 )
region = Rect2( 110, 0, 22, 25 )
[resource]
animations = [ {
"frames": [ SubResource( 7 ) ],
"loop": true,
"name": "idle",
"speed": 0.0
}, {
"frames": [ SubResource( 1 ), SubResource( 2 ), SubResource( 3 ), SubResource( 4 ), SubResource( 5 ), SubResource( 6 ) ],
"loop": true,
"name": "run",
"speed": 12.0
} ]

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@ -2,15 +2,15 @@
importer="texture" importer="texture"
type="StreamTexture" type="StreamTexture"
path="res://.import/sprite.png-d1a953a55fa409c61c2d0834450a9346.stex" path="res://.import/run.png-345781115512817e4a25318657a4c97e.stex"
metadata={ metadata={
"vram_texture": false "vram_texture": false
} }
[deps] [deps]
source_file="res://src/models/player/sprite.png" source_file="res://src/models/player/sprites/run.png"
dest_files=[ "res://.import/sprite.png-d1a953a55fa409c61c2d0834450a9346.stex" ] dest_files=[ "res://.import/run.png-345781115512817e4a25318657a4c97e.stex" ]
[params] [params]