Compare commits
4 commits
b7693e8575
...
7f3c910414
| Author | SHA1 | Date | |
|---|---|---|---|
| 7f3c910414 | |||
| 29aac6edf2 | |||
| dd00945c15 | |||
| 847d21a06d |
20 changed files with 245 additions and 17 deletions
|
|
@ -1,18 +1,24 @@
|
|||
[gd_scene load_steps=3 format=4 uid="uid://d3c6aioatcy20"]
|
||||
[gd_scene load_steps=4 format=4 uid="uid://d3c6aioatcy20"]
|
||||
|
||||
[ext_resource type="PackedScene" uid="uid://642nm6c4mpxx" path="res://scenes/Player.tscn" id="1_elqb8"]
|
||||
[ext_resource type="TileSet" uid="uid://doja61ouvb77l" path="res://resources/tilesets/level.tres" id="1_rvslj"]
|
||||
[ext_resource type="TileSet" uid="uid://doja61ouvb77l" path="res://resources/tilesets/level.tres" id="1_uu6xs"]
|
||||
[ext_resource type="PackedScene" uid="uid://642nm6c4mpxx" path="res://scenes/player/player.tscn" id="2_r0du0"]
|
||||
[ext_resource type="PackedScene" uid="uid://cmgwv41ht3q4j" path="res://scenes/ball/ball.tscn" id="3_r0du0"]
|
||||
|
||||
[node name="Main" type="Node"]
|
||||
|
||||
[node name="FloorTilemap" type="TileMapLayer" parent="."]
|
||||
tile_map_data = PackedByteArray("AAAEAAAAAgAAAAAAAAAEAAEAAgAAAAAAAAAEAAIAAgAAAAAAAAAEAAMAAgAAAAAAAAAEAAQAAgAAAAAAAAAEAAUAAgAAAAAAAAAEAAYAAgAAAAAAAAAEAAcAAgAAAAAAAAAEAAgAAgAAAAAAAAAEAAkAAgAAAAAAAAAEAAoAAgAAAAAAAAAEAAsAAgAAAAAAAAAEAAwAAgAAAAAAAAAEAA0AAgAAAAAAAAAEAA4AAgAAAAAAAAAFAAAAAgAAAAAAAAAFAAEAAgAAAAAAAAAFAAIAAgAAAAAAAAAFAAMAAgAAAAAAAAAFAAQAAgAAAAAAAAAFAAUAAgAAAAAAAAAFAAYAAgAAAAAAAAAFAAcAAgAAAAAAAAAFAAgAAgAAAAAAAAAFAAkAAgAAAAA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AAAAAAOAAUAAgAAAAAAAAAOAAYAAgAAAAAAAAAOAAcAAgAAAAAAAAAOAAgAAgAAAAAAAAAOAAkAAgAAAAAAAAAOAAoAAgAAAAAAAAAOAAsAAgAAAAAAAAAOAAwAAgAAAAAAAAAOAA0AAgAAAAAAAAAOAA4AAgAAAAAAAAAPAAAAAgAAAAAAAAAPAAEAAgAAAAAAAAAPAAIAAgAAAAAAAAAPAAMAAgAAAAAAAAAPAAQAAgAAAAAAAAAPAAUAAgAAAAAAAAAPAAYAAgAAAAAAAAAPAAcAAgAAAAAAAAAPAAgAAgAAAAAAAAAPAAkAAgAAAAAAAAAPAAoAAgAAAAAAAAAPAAsAAgAAAAAAAAAPAAwAAgAAAAAAAAAPAA0AAgAAAAAAAAAPAA4AAgAAAAAAAAA=")
|
||||
tile_set = ExtResource("1_rvslj")
|
||||
tile_set = ExtResource("1_uu6xs")
|
||||
collision_enabled = false
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="BlockTilemap" type="TileMapLayer" parent="."]
|
||||
tile_map_data = PackedByteArray("AAADAA0AAwAEAAIAAAADAAwAAwAEAAIAAAADAAsAAwAEAAIAAAADAAoAAwAEAAIAAAADAAkAAwAEAAIAAAADAAgAAwAEAAIAAAADAAcAAwAEAAIAAAADAAYAAwAEAAIAAAADAAUAAwAEAAIAAAADAAQAAwAEAAIAAAADAAMAAwAEAAIAAAADAAIAAwAEAAIAAAADAAEAAwAEAAIAAAAQAA0AAwAEAAIAAAAQAAwAAwAEAAIAAAAQAAsAAwAEAAIAAAAQAAoAAwAEAAIAAAAQAAkAAwAEAAIAAAAQAAgAAwAEAAIAAAAQAAcAAwAEAAIAAAAQAAYAAwAEAAIAAAAQAAUAAwAEAAIAAAAQAAQAAwAEAAIAAAAQAAMAAwAEAAIAAAAQAAIAAwAEAAIAAAAQAAEAAwAEAAIAAAADAAAAAwAEAAEAAAAQAAAAAwAEAAEAAAADAA4AAwAEAAMAAAAQAA4AAwAEAAMAAAAEAA4AA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wAHAAcAAAAFAAAAAwAGAAUAAAAGAAAAAwAHAAUAAAANAAAAAwAEAAEAAAAOAAAAAwAGAAAAAAAGAAIAAwAGAAQAAAAFAAMAAwAGAAQAAAAEAAQAAwAGAAQAAAANAAIAAwAFAAMAAAAOAAMAAwAFAAMAAAAPAAQAAwAFAAMAAAAOAAIAAwAGAAMAAAAPAAMAAwAGAAMAAAAFAAIAAwAFAAIAAAAEAAMAAwAFAAIAAAANAAEAAwAEAAMAAAAGAAEAAwAHAAIAAAAEAAEAAwAEAAQAAAAFAAEAAwAHAAcAAAAEAAAAAwAEAAAAAAAPAAIAAwAEAAQAAAAOAAEAAwAHAAAAAAAEAAIAAwAEAAUAAAAPAAEAAwAGAAMAAAAPAAAAAwAGAAMAAAAHAA0ABAAAAAMAAAAIAA0ABAABAAMAAAAJAA0ABAACAAMAAAAKAA0ABAADAAMAAAALAA0ABAAEAAMAAAAMAA0ABAAFAAMAAAAHAAEABAAAAAMAAAAIAAEABAABAAMAAAAJAAEABAACAAMAAAAKAAEABAADAAMAAAALAAEABAAEAAMAAAAMAAEABAAFAAMAAAA=")
|
||||
tile_set = ExtResource("1_uu6xs")
|
||||
metadata/_edit_lock_ = true
|
||||
|
||||
[node name="Player" parent="." instance=ExtResource("1_elqb8")]
|
||||
[node name="Player" parent="." instance=ExtResource("2_r0du0")]
|
||||
position = Vector2(148, 105)
|
||||
|
||||
[node name="Ball" parent="." instance=ExtResource("3_r0du0")]
|
||||
position = Vector2(193, 130)
|
||||
|
|
@ -27,6 +27,10 @@ window/stretch/scale_mode="integer"
|
|||
version_control/plugin_name="GitPlugin"
|
||||
version_control/autoload_on_startup=true
|
||||
|
||||
[global_group]
|
||||
|
||||
paddle="objects that hit the ball"
|
||||
|
||||
[input]
|
||||
|
||||
move_up={
|
||||
|
|
@ -54,6 +58,16 @@ shift={
|
|||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":4194325,"key_label":0,"unicode":0,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
hit_left={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":79,"key_label":0,"unicode":111,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
hit_right={
|
||||
"deadzone": 0.2,
|
||||
"events": [Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"pressed":false,"keycode":0,"physical_keycode":80,"key_label":0,"unicode":112,"location":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,12 @@
|
|||
[gd_resource type="TileSet" load_steps=8 format=3 uid="uid://doja61ouvb77l"]
|
||||
[gd_resource type="TileSet" load_steps=9 format=3 uid="uid://doja61ouvb77l"]
|
||||
|
||||
[ext_resource type="Texture2D" uid="uid://cwyhgn5jgia1m" path="res://assets/environment/proto.png" id="1_ohrjv"]
|
||||
[ext_resource type="Texture2D" uid="uid://nk83a47ifsqo" path="res://assets/environment/Block Tileset 4 Colors RVG.png" id="2_br5dt"]
|
||||
[ext_resource type="Texture2D" uid="uid://coabfw2isxhtc" path="res://assets/environment/match3_db16.png" id="3_xww2a"]
|
||||
|
||||
[sub_resource type="TileMapPattern" id="TileMapPattern_ohrjv"]
|
||||
tile_data = PackedInt32Array(0, 458755, 4, 65536, 327683, 4, 131072, 458755, 0, 196608, 393219, 5, 262144, 393219, 7, 65537, 458755, 4, 131073, 327683, 4, 196609, 458755, 5, 262145, 458755, 7, 131074, 458755, 4, 196610, 262147, 1, 262146, 262147, 3, 262147, 65540, 6, 262148, 65540, 6, 262149, 65540, 6, 262150, 65540, 6, 262151, 65540, 6, 262152, 65540, 6, 131081, 458755, 3, 196617, 262147, 1, 262153, 262147, 3, 65546, 458755, 3, 131082, 393219, 3, 196618, 458755, 2, 262154, 393219, 7, 11, 458755, 3, 65547, 393219, 3, 131083, 262147, 1, 196619, 262147, 3, 262155, 458755, 7)
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_ohrjv"]
|
||||
|
||||
[sub_resource type="TileSetAtlasSource" id="TileSetAtlasSource_pdhcq"]
|
||||
|
|
@ -483,3 +486,4 @@ terrain_set_0/terrain_0/color = Color(0.5, 0.34375, 0.25, 1)
|
|||
sources/2 = SubResource("TileSetAtlasSource_pdhcq")
|
||||
sources/3 = SubResource("TileSetAtlasSource_58657")
|
||||
sources/4 = SubResource("TileSetAtlasSource_ln5p0")
|
||||
pattern_0 = SubResource("TileMapPattern_ohrjv")
|
||||
|
|
|
|||
BIN
scenes/ball/ball.ase
Normal file
BIN
scenes/ball/ball.ase
Normal file
Binary file not shown.
23
scenes/ball/ball.gd
Normal file
23
scenes/ball/ball.gd
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
extends RigidBody2D
|
||||
|
||||
@onready var hurtbox: Area2D = $HurtArea2D
|
||||
|
||||
@export var launch_speed: float = 400
|
||||
@export var speed_mult: float = 1.08
|
||||
|
||||
var is_hit: bool = false
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
hurtbox.connect("area_entered", _on_hit)
|
||||
launch_random()
|
||||
|
||||
|
||||
func launch_random():
|
||||
var angle = randf_range(-PI/3, PI/3) + PI * float(randi()%2)
|
||||
linear_velocity = Vector2(cos(angle), sin(angle)) * launch_speed
|
||||
|
||||
|
||||
func _on_hit(area: Area2D) -> void:
|
||||
if area.is_in_group("paddle"):
|
||||
linear_velocity = linear_velocity.normalized() * linear_velocity.length() * speed_mult
|
||||
1
scenes/ball/ball.gd.uid
Normal file
1
scenes/ball/ball.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://d2s0fid28eihy
|
||||
BIN
scenes/ball/ball.png
Normal file
BIN
scenes/ball/ball.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 316 B |
40
scenes/ball/ball.png.import
Normal file
40
scenes/ball/ball.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c44hadxh2458n"
|
||||
path="res://.godot/imported/ball.png-20bc590ed01e3c3d037babb65682d093.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/ball/ball.png"
|
||||
dest_files=["res://.godot/imported/ball.png-20bc590ed01e3c3d037babb65682d093.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
|
||||
36
scenes/ball/ball.tscn
Normal file
36
scenes/ball/ball.tscn
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
[gd_scene load_steps=6 format=3 uid="uid://cmgwv41ht3q4j"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://d2s0fid28eihy" path="res://scenes/ball/ball.gd" id="1_nv6q1"]
|
||||
[ext_resource type="Texture2D" uid="uid://c44hadxh2458n" path="res://scenes/ball/ball.png" id="1_oqv3d"]
|
||||
|
||||
[sub_resource type="PhysicsMaterial" id="PhysicsMaterial_oqv3d"]
|
||||
friction = 0.0
|
||||
bounce = 0.3
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_oqv3d"]
|
||||
radius = 11.0
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_nv6q1"]
|
||||
radius = 8.062258
|
||||
|
||||
[node name="Ball" type="RigidBody2D"]
|
||||
collision_layer = 18
|
||||
collision_mask = 5
|
||||
physics_material_override = SubResource("PhysicsMaterial_oqv3d")
|
||||
gravity_scale = 0.0
|
||||
continuous_cd = 1
|
||||
script = ExtResource("1_nv6q1")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
texture = ExtResource("1_oqv3d")
|
||||
|
||||
[node name="HurtArea2D" type="Area2D" parent="."]
|
||||
collision_layer = 16
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="HurtArea2D"]
|
||||
shape = SubResource("CircleShape2D_oqv3d")
|
||||
debug_color = Color(0.8785819, 0.30416045, 0.40790904, 0.41960785)
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource("CircleShape2D_nv6q1")
|
||||
BIN
scenes/hit/hit.ase
Normal file
BIN
scenes/hit/hit.ase
Normal file
Binary file not shown.
14
scenes/hit/hit.gd
Normal file
14
scenes/hit/hit.gd
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
extends Area2D
|
||||
|
||||
@onready var timer: Timer = $Timer
|
||||
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
timer.connect("timeout", _despawn)
|
||||
|
||||
# Called every frame. 'delta' is the elapsed time since the previous frame.
|
||||
func _process(delta: float) -> void:
|
||||
pass
|
||||
|
||||
func _despawn() -> void:
|
||||
queue_free()
|
||||
1
scenes/hit/hit.gd.uid
Normal file
1
scenes/hit/hit.gd.uid
Normal file
|
|
@ -0,0 +1 @@
|
|||
uid://c0m6xhbtgbgtu
|
||||
BIN
scenes/hit/hit.png
Normal file
BIN
scenes/hit/hit.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 267 B |
40
scenes/hit/hit.png.import
Normal file
40
scenes/hit/hit.png.import
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://c6a62gvw7218s"
|
||||
path="res://.godot/imported/hit.png-ab7094ea32cf7bd1cd8dffcb2c8ef7cb.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://scenes/hit/hit.png"
|
||||
dest_files=["res://.godot/imported/hit.png-ab7094ea32cf7bd1cd8dffcb2c8ef7cb.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
compress/mode=0
|
||||
compress/high_quality=false
|
||||
compress/lossy_quality=0.7
|
||||
compress/uastc_level=0
|
||||
compress/rdo_quality_loss=0.0
|
||||
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/channel_remap/red=0
|
||||
process/channel_remap/green=1
|
||||
process/channel_remap/blue=2
|
||||
process/channel_remap/alpha=3
|
||||
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
|
||||
28
scenes/hit/hit.tscn
Normal file
28
scenes/hit/hit.tscn
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
[gd_scene load_steps=4 format=3 uid="uid://px67runjx6ex"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://c0m6xhbtgbgtu" path="res://scenes/hit/hit.gd" id="1_fxeki"]
|
||||
[ext_resource type="Texture2D" uid="uid://c6a62gvw7218s" path="res://scenes/hit/hit.png" id="1_wjo4f"]
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_fxeki"]
|
||||
radius = 7.0
|
||||
height = 18.0
|
||||
|
||||
[node name="Hit" type="Area2D" groups=["paddle"]]
|
||||
collision_layer = 0
|
||||
collision_mask = 16
|
||||
script = ExtResource("1_fxeki")
|
||||
|
||||
[node name="Sprite2D" type="Sprite2D" parent="."]
|
||||
position = Vector2(7, -4)
|
||||
texture = ExtResource("1_wjo4f")
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
|
||||
position = Vector2(5, -1)
|
||||
rotation = 1.5707964
|
||||
shape = SubResource("CapsuleShape2D_fxeki")
|
||||
debug_color = Color(0.6205005, 0.42311785, 0.8432588, 0.41960785)
|
||||
|
||||
[node name="Timer" type="Timer" parent="."]
|
||||
wait_time = 0.5
|
||||
one_shot = true
|
||||
autostart = true
|
||||
|
|
@ -1,9 +1,11 @@
|
|||
extends CharacterBody2D
|
||||
|
||||
const MAX_SPEED: float = 150
|
||||
@export var player: int = 1
|
||||
@export var max_speed: float = 150
|
||||
|
||||
@onready var sprite: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
var is_hitting: bool = false
|
||||
var was_moving: bool = false
|
||||
var anim_dir: String = 'down'
|
||||
|
||||
|
|
@ -14,13 +16,26 @@ func _ready() -> void:
|
|||
|
||||
func _physics_process(_delta: float) -> void:
|
||||
var movement_vector: Vector2 = get_movement_vector()
|
||||
var direction: Vector2 = movement_vector.normalized()
|
||||
velocity = direction * MAX_SPEED
|
||||
var direction: Vector2 = movement_vector.normalized() if not is_hitting else Vector2.ZERO
|
||||
velocity = direction * max_speed
|
||||
|
||||
move_and_slide()
|
||||
|
||||
var is_moving: bool = velocity.length() > 10
|
||||
|
||||
if Input.is_action_pressed("hit_left") and not is_hitting:
|
||||
if not is_hitting:
|
||||
sprite.play('up')
|
||||
sprite.frame = 1
|
||||
sprite.pause()
|
||||
|
||||
var hit: Area2D = preload("res://scenes/hit/hit.tscn").instantiate()
|
||||
add_child(hit)
|
||||
|
||||
hit.timer.connect("timeout", _on_hit_end)
|
||||
|
||||
is_hitting = true
|
||||
|
||||
if is_moving:
|
||||
if abs(velocity.x) > abs(velocity.y):
|
||||
anim_dir = 'right' if velocity.x > 0 else 'left'
|
||||
|
|
@ -29,7 +44,7 @@ func _physics_process(_delta: float) -> void:
|
|||
|
||||
sprite.play(anim_dir)
|
||||
else:
|
||||
if was_moving:
|
||||
if was_moving and not is_hitting:
|
||||
sprite.play('down')
|
||||
sprite.frame = 1
|
||||
sprite.pause()
|
||||
|
|
@ -40,3 +55,6 @@ func get_movement_vector() -> Vector2:
|
|||
var x_mov: float = Input.get_action_strength('move_right') - Input.get_action_strength('move_left')
|
||||
var y_mov: float = Input.get_action_strength('move_down') - Input.get_action_strength('move_up')
|
||||
return Vector2(x_mov, y_mov)
|
||||
|
||||
func _on_hit_end() -> void:
|
||||
is_hitting = false
|
||||
|
|
@ -1,7 +1,7 @@
|
|||
[gd_scene load_steps=17 format=3 uid="uid://642nm6c4mpxx"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://rdqmsvofiots" path="res://scenes/player.gd" id="1_v6fml"]
|
||||
[ext_resource type="Texture2D" uid="uid://b8ptokcqwpdud" path="res://assets/sprites/saffron.png" id="2_3li8b"]
|
||||
[ext_resource type="Script" uid="uid://rdqmsvofiots" path="res://scenes/player/player.gd" id="1_v6fml"]
|
||||
[ext_resource type="Texture2D" uid="uid://b8ptokcqwpdud" path="res://scenes/player/saffron.png" id="2_3li8b"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_g2els"]
|
||||
atlas = ExtResource("2_3li8b")
|
||||
|
|
@ -127,6 +127,9 @@ radius = 5.0
|
|||
height = 16.0
|
||||
|
||||
[node name="Player" type="CharacterBody2D"]
|
||||
collision_layer = 2
|
||||
collision_mask = 13
|
||||
floor_stop_on_slope = false
|
||||
script = ExtResource("1_v6fml")
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
|
Before Width: | Height: | Size: 1.4 KiB After Width: | Height: | Size: 1.4 KiB |
|
|
@ -3,15 +3,15 @@
|
|||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://b8ptokcqwpdud"
|
||||
path="res://.godot/imported/saffron.png-c81108ff0df47612a2c9489571b1d8bd.ctex"
|
||||
path="res://.godot/imported/saffron.png-991e20279426633ebd2f473c0690f57d.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/sprites/saffron.png"
|
||||
dest_files=["res://.godot/imported/saffron.png-c81108ff0df47612a2c9489571b1d8bd.ctex"]
|
||||
source_file="res://scenes/player/saffron.png"
|
||||
dest_files=["res://.godot/imported/saffron.png-991e20279426633ebd2f473c0690f57d.ctex"]
|
||||
|
||||
[params]
|
||||
|
||||
Loading…
Add table
Reference in a new issue