idle, run, jump working

This commit is contained in:
mitchellgunn 2024-07-22 19:38:39 -04:00
parent 6380415a1e
commit 3ac8d5daed
29 changed files with 344 additions and 31 deletions

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Area2D")])
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")])

View File

@ -8,7 +8,7 @@ Anim={
"grid_snap_active": false,
"grid_step": Vector2(8, 8),
"grid_visibility": 1,
"ofs": Vector2(-105.112, -79.4505),
"ofs": Vector2(-103.237, -64.8437),
"primary_grid_step": Vector2i(8, 8),
"show_edit_locks": true,
"show_guides": true,
@ -32,7 +32,7 @@ Anim={
"snap_rotation_step": 0.261799,
"snap_scale": false,
"snap_scale_step": 0.1,
"zoom": 4.23785
"zoom": 4.75683
}
3D={
"fov": 70.01,
@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Area2D")])
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")])

View File

@ -1,5 +1,5 @@
[folding]
node_unfolds=[]
resource_unfolds=["res://scenes/character.tscn::CircleShape2D_ubfw4", PackedStringArray()]
node_unfolds=[NodePath("AnimatedSprite2D"), PackedStringArray("Animation", "sprite_frames", "Texture")]
resource_unfolds=["res://scenes/character.tscn::SpriteFrames_8idir", PackedStringArray("Resource"), "res://scenes/character.tscn::CircleShape2D_ubfw4", PackedStringArray()]
nodes_folded=[]

View File

@ -1,3 +1,4 @@
AnimatedSprite2D
Node2D
CollisionShape2D
Area2D

View File

@ -4,7 +4,7 @@ dock_1_selected_tab_idx=0
dock_2_selected_tab_idx=0
dock_3_selected_tab_idx=0
dock_4_selected_tab_idx=0
dock_5_selected_tab_idx=1
dock_5_selected_tab_idx=0
dock_6_selected_tab_idx=0
dock_7_selected_tab_idx=0
dock_8_selected_tab_idx=0
@ -19,8 +19,8 @@ dock_filesystem_split=0
dock_filesystem_display_mode=0
dock_filesystem_file_sort=0
dock_filesystem_file_list_display_mode=1
dock_filesystem_selected_paths=PackedStringArray("res://scenes/bullet.tscn")
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/")
dock_filesystem_selected_paths=PackedStringArray()
dock_filesystem_uncollapsed_paths=PackedStringArray("Favorites", "res://", "res://scripts/", "res://scenes/", "res://graphics/")
dock_3="Scene,Import"
dock_4="FileSystem"
dock_5="Inspector,Node,History"
@ -28,16 +28,16 @@ dock_5="Inspector,Node,History"
[EditorNode]
open_scenes=PackedStringArray("res://scenes/game.tscn", "res://scenes/character.tscn", "res://scenes/bullet.tscn")
current_scene="res://scenes/bullet.tscn"
current_scene="res://scenes/character.tscn"
center_split_offset=0
selected_default_debugger_tab_idx=0
selected_main_editor_idx=2
selected_bottom_panel_item=0
selected_main_editor_idx=0
selected_bottom_panel_item=9
[ScriptEditor]
open_scripts=["res://scripts/bullet.gd", "res://scripts/CharacterBody2D.gd", "res://scripts/gamecontroller.gd"]
selected_script="res://scripts/bullet.gd"
selected_script="res://scripts/CharacterBody2D.gd"
open_help=[]
script_split_offset=70
list_split_offset=0

View File

@ -1,9 +1,18 @@
ea4bc82a6ad023ab7ee23ee620429895
::res://::1721083613
icon.svg::CompressedTexture2D::9114977118871582245::1721083376::1721083376::1::::<><>::
::res://scenes/::1721083376
game.tscn::PackedScene::1738196330916037717::1721083376::0::1::::<><>::res://scripts/gamecontroller.gd<>res://scripts/CharacterBody2D.gd<>res://scripts/Trigger.gd
::res://scripts/::1721083376
CharacterBody2D.gd::GDScript::-1::1721083376::0::1::::<>CharacterBody2D<>::
gamecontroller.gd::GDScript::-1::1721083376::0::1::::<>Node2D<>::
Trigger.gd::GDScript::-1::1721083376::0::1::::<>Area2D<>::
::res://::1721688548
icon.svg::CompressedTexture2D::9114977118871582245::1721682499::1721682499::1::::<><>::
README.md::TextFile::-1::1721686817::0::1::::<><>::
::res://graphics/::1721691245
Player Idle 48x48.png::CompressedTexture2D::3529809544777189649::1721688527::1721688496::1::::<><>::
player jump 48x48.png::CompressedTexture2D::3342890448265989669::1721690657::1721690657::1::::<><>::
player land 48x48.png::CompressedTexture2D::5541143191019734946::1721691245::1721691245::1::::<><>::
player run 48x48.png::CompressedTexture2D::2400852804432818940::1721689939::1721689939::1::::<><>::
::res://scenes/::1721691227
bullet.tscn::PackedScene::6880909734590904373::1721691227::0::1::::<><>::res://scripts/bullet.gd
character.tscn::PackedScene::451838158579532324::1721691227::0::1::::<><>::res://scripts/CharacterBody2D.gd<>uid://bqj4phkget2pp::::res://graphics/Player Idle 48x48.png<>uid://bnvk6gm188vsv::::res://graphics/player jump 48x48.png<>uid://bag8xvlev6yxg::::res://graphics/player run 48x48.png
game.tscn::PackedScene::1738196330916037717::1721691227::0::1::::<><>::res://scripts/gamecontroller.gd<>uid://go4yc8hfo1gq::::res://scenes/character.tscn<>res://scripts/Trigger.gd
::res://scripts/::1721691227
bullet.gd::GDScript::-1::1721682499::0::1::::<>Area2D<>::
CharacterBody2D.gd::GDScript::-1::1721691227::0::1::::<>CharacterBody2D<>::
gamecontroller.gd::GDScript::-1::1721682499::0::1::::<>Node2D<>::
Trigger.gd::GDScript::-1::1721682499::0::1::::<>Area2D<>::

View File

@ -1,5 +1,4 @@
res://scenes/game.tscn
res://scripts/CharacterBody2D.gd
res://scenes/character.tscn
res://scripts/bullet.gd
res://scenes/bullet.tscn
res://scripts/CharacterBody2D.gd

View File

@ -172,4 +172,4 @@ Anim={
"zfar": 4000.01,
"znear": 0.05
}
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/Area2D")])
selected_nodes=Array[NodePath]([NodePath("/root/@EditorNode@17140/@Panel@13/@VBoxContainer@14/@HSplitContainer@17/@HSplitContainer@25/@HSplitContainer@33/@VBoxContainer@34/@VSplitContainer@36/@VSplitContainer@62/@VBoxContainer@63/@PanelContainer@110/MainScreen/@CanvasItemEditor@9462/@VSplitContainer@9281/@HSplitContainer@9283/@HSplitContainer@9285/@Control@9286/@SubViewportContainer@9287/@SubViewport@9288/CharacterBody2D/AnimatedSprite2D")])

View File

@ -1,6 +1,6 @@
[editor_metadata]
executable_path="/home/timbot/Documents/Software/godot/Godot_v4.2.1-stable_linux.x86_64"
executable_path="/home/timbuntu/Documents/software/godot/Godot_v4.2.1-stable_linux.x86_64"
use_advanced_connections=false
[debug_options]
@ -23,6 +23,7 @@ CollisionShape2D:scale=true
RigidBody2D:scale=true
RayCast2D:scale=true
Area2D:scale=true
AnimatedSprite2D:scale=true
[dialog_bounds]

View File

@ -1,2 +1,3 @@
res://graphics
res://scripts
res://scenes

View File

@ -17,11 +17,11 @@ state={
state={
"bookmarks": PackedInt32Array(),
"breakpoints": PackedInt32Array(),
"column": 52,
"column": 30,
"folded_lines": Array[int]([]),
"h_scroll_position": 0,
"row": 47,
"scroll_position": 30.0,
"row": 69,
"scroll_position": 51.0,
"selection": false,
"syntax_highlighter": "GDScript"
}

View File

@ -0,0 +1,3 @@
source_md5="25eca82a8943e0cb7df742fc2f8287eb"
dest_md5="40424c46e7e7da6cb6f8f38becacd5fa"

View File

@ -0,0 +1,3 @@
source_md5="25eca82a8943e0cb7df742fc2f8287eb"
dest_md5="40424c46e7e7da6cb6f8f38becacd5fa"

View File

@ -0,0 +1,3 @@
source_md5="32c25d5ee4a6233bebc766fa35137e71"
dest_md5="e2c6a646cfe3495563ee0fd7127f6784"

View File

@ -0,0 +1,3 @@
source_md5="6499731a5b8ba07779f39a50ca1cf8b1"
dest_md5="ee57d845fdcb15a719035fe5911e8bdc"

View File

@ -0,0 +1,3 @@
source_md5="01ad20affe3a719d2248d3eb59a0b3dd"
dest_md5="c7e49f2c0ac84ac6a6d941074f19bd68"

Binary file not shown.

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bqj4phkget2pp"
path="res://.godot/imported/Player Idle 48x48.png-b25968a287377bab7d6899f33fed0ec9.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/Player Idle 48x48.png"
dest_files=["res://.godot/imported/Player Idle 48x48.png-b25968a287377bab7d6899f33fed0ec9.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 not shown.

After

Width:  |  Height:  |  Size: 1021 B

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bnvk6gm188vsv"
path="res://.godot/imported/player jump 48x48.png-44bab2151e6e1eb3cf69ed16e7a4f4ad.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/player jump 48x48.png"
dest_files=["res://.godot/imported/player jump 48x48.png-44bab2151e6e1eb3cf69ed16e7a4f4ad.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 not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

View File

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://bag8xvlev6yxg"
path="res://.godot/imported/player run 48x48.png-626defb011aee5b3f5c54d9acb45d5f5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://graphics/player run 48x48.png"
dest_files=["res://.godot/imported/player run 48x48.png-626defb011aee5b3f5c54d9acb45d5f5.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

View File

@ -19,6 +19,7 @@ config/icon="res://icon.svg"
folder_colors={
"res://assets/": "green",
"res://graphics/": "green",
"res://scenes/": "yellow",
"res://scripts/": "red"
}

View File

@ -1,18 +1,193 @@
[gd_scene load_steps=3 format=3 uid="uid://go4yc8hfo1gq"]
[gd_scene load_steps=28 format=3 uid="uid://go4yc8hfo1gq"]
[ext_resource type="Script" path="res://scripts/CharacterBody2D.gd" id="1_x87yo"]
[ext_resource type="Texture2D" uid="uid://bqj4phkget2pp" path="res://graphics/Player Idle 48x48.png" id="2_c7awu"]
[ext_resource type="Texture2D" uid="uid://bnvk6gm188vsv" path="res://graphics/player jump 48x48.png" id="3_h6vre"]
[ext_resource type="Texture2D" uid="uid://bag8xvlev6yxg" path="res://graphics/player run 48x48.png" id="3_w6p3w"]
[sub_resource type="AtlasTexture" id="AtlasTexture_aeg01"]
atlas = ExtResource("2_c7awu")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_1uaof"]
atlas = ExtResource("2_c7awu")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_gt6ba"]
atlas = ExtResource("2_c7awu")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_tay2c"]
atlas = ExtResource("2_c7awu")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_1ag8q"]
atlas = ExtResource("2_c7awu")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_hjiy4"]
atlas = ExtResource("2_c7awu")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_82onf"]
atlas = ExtResource("2_c7awu")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_yqp8u"]
atlas = ExtResource("2_c7awu")
region = Rect2(336, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_m6d3n"]
atlas = ExtResource("2_c7awu")
region = Rect2(384, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ax7e1"]
atlas = ExtResource("2_c7awu")
region = Rect2(432, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_qrer8"]
atlas = ExtResource("3_h6vre")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_wpiaq"]
atlas = ExtResource("3_h6vre")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_kc70w"]
atlas = ExtResource("3_h6vre")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_i4hpn"]
atlas = ExtResource("3_w6p3w")
region = Rect2(0, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_sri3h"]
atlas = ExtResource("3_w6p3w")
region = Rect2(48, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_igbwk"]
atlas = ExtResource("3_w6p3w")
region = Rect2(96, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_t7p31"]
atlas = ExtResource("3_w6p3w")
region = Rect2(144, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ovti0"]
atlas = ExtResource("3_w6p3w")
region = Rect2(192, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_2vy0d"]
atlas = ExtResource("3_w6p3w")
region = Rect2(240, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_klr2a"]
atlas = ExtResource("3_w6p3w")
region = Rect2(288, 0, 48, 48)
[sub_resource type="AtlasTexture" id="AtlasTexture_ax6e1"]
atlas = ExtResource("3_w6p3w")
region = Rect2(336, 0, 48, 48)
[sub_resource type="SpriteFrames" id="SpriteFrames_8idir"]
animations = [{
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_aeg01")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1uaof")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_gt6ba")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_tay2c")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_1ag8q")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_hjiy4")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_82onf")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_yqp8u")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_m6d3n")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ax7e1")
}],
"loop": true,
"name": &"idle",
"speed": 15.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_qrer8")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_wpiaq")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_kc70w")
}],
"loop": false,
"name": &"jump",
"speed": 5.0
}, {
"frames": [{
"duration": 1.0,
"texture": SubResource("AtlasTexture_i4hpn")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_sri3h")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_igbwk")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_t7p31")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ovti0")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_2vy0d")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_klr2a")
}, {
"duration": 1.0,
"texture": SubResource("AtlasTexture_ax6e1")
}],
"loop": true,
"name": &"run",
"speed": 15.0
}]
[sub_resource type="CircleShape2D" id="CircleShape2D_ubfw4"]
radius = 13.0384
radius = 12.0
[node name="CharacterBody2D" type="CharacterBody2D"]
position = Vector2(-1, 0)
script = ExtResource("1_x87yo")
JUMP_VELOCITY = -500.0
PUSH_FORCE = 200
metadata/_edit_group_ = true
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
texture_filter = 1
sprite_frames = SubResource("SpriteFrames_8idir")
animation = &"idle"
autoplay = "idle"
frame_progress = 0.758732
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2(0, 3)
shape = SubResource("CircleShape2D_ubfw4")
[node name="RightRay" type="RayCast2D" parent="."]

View File

@ -10,6 +10,7 @@ extends CharacterBody2D
@onready var left_ray = $LeftRay
@onready var marker_right = $MarkerRight
@onready var marker_left = $MarkerLeft
@onready var animated_sprite = $AnimatedSprite2D
var faceLeft = false
var pushLeftEnabled = false
@ -57,8 +58,16 @@ func _physics_process(delta):
if direction:
velocity.x = direction * SPEED
animated_sprite.flip_h = true if direction <0 else false
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
if is_on_floor():
if direction == 0:
animated_sprite.play("idle")
else:
animated_sprite.play("run")
else:
animated_sprite.play("jump")
move_and_slide()
if right_ray.is_colliding():