Compare commits
4 Commits
main
...
week3_prep
| Author | SHA1 | Date | |
|---|---|---|---|
| edef8f7f8f | |||
| b8cdde4763 | |||
| b3ca85807f | |||
| 47fa82b075 |
BIN
assets/graphics/animations/player/idle/Player Idle 48x48.png
Normal file
BIN
assets/graphics/animations/player/idle/Player Idle 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1.8 KiB |
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://y7gjdptxvjfu"
|
||||
path="res://.godot/imported/Player Idle 48x48.png-b35e1ef309601cafc0161eed9f72d3a6.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/animations/player/idle/Player Idle 48x48.png"
|
||||
dest_files=["res://.godot/imported/Player Idle 48x48.png-b35e1ef309601cafc0161eed9f72d3a6.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
|
||||
BIN
assets/graphics/animations/player/jump/player jump 48x48.png
Normal file
BIN
assets/graphics/animations/player/jump/player jump 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 1021 B |
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bpchnouakdsvk"
|
||||
path="res://.godot/imported/player jump 48x48.png-49f79fd5510be01ac15a884acca16d43.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/animations/player/jump/player jump 48x48.png"
|
||||
dest_files=["res://.godot/imported/player jump 48x48.png-49f79fd5510be01ac15a884acca16d43.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
|
||||
BIN
assets/graphics/animations/player/run/player run 48x48.png
Normal file
BIN
assets/graphics/animations/player/run/player run 48x48.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.1 KiB |
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bqdop2arlx7rr"
|
||||
path="res://.godot/imported/player run 48x48.png-d5efa0f3a9f0a70a93e094c3e7f118ec.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/animations/player/run/player run 48x48.png"
|
||||
dest_files=["res://.godot/imported/player run 48x48.png-d5efa0f3a9f0a70a93e094c3e7f118ec.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
|
||||
BIN
assets/graphics/projectiles/pixel_bullet.png
Normal file
BIN
assets/graphics/projectiles/pixel_bullet.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.8 KiB |
40
assets/graphics/projectiles/pixel_bullet.png.import
Normal file
40
assets/graphics/projectiles/pixel_bullet.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://bc8cpuacrbf0y"
|
||||
path="res://.godot/imported/pixel_bullet.png-30d6d1e8b5e1332f8b2e2cee72a9e790.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/projectiles/pixel_bullet.png"
|
||||
dest_files=["res://.godot/imported/pixel_bullet.png-30d6d1e8b5e1332f8b2e2cee72a9e790.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
|
||||
@ -1,9 +1,182 @@
|
||||
[gd_scene load_steps=3 format=3 uid="uid://b1yy0sybg66hh"]
|
||||
[gd_scene load_steps=28 format=3 uid="uid://b1yy0sybg66hh"]
|
||||
|
||||
[ext_resource type="Script" uid="uid://kv8w1gwuy3il" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||
[ext_resource type="Texture2D" uid="uid://bpchnouakdsvk" path="res://assets/graphics/animations/player/jump/player jump 48x48.png" id="2_dqkch"]
|
||||
[ext_resource type="Texture2D" uid="uid://y7gjdptxvjfu" path="res://assets/graphics/animations/player/idle/Player Idle 48x48.png" id="2_g2els"]
|
||||
[ext_resource type="Texture2D" uid="uid://bqdop2arlx7rr" path="res://assets/graphics/animations/player/run/player run 48x48.png" id="4_qlg0r"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_3vyb7"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_jej6c"]
|
||||
atlas = ExtResource("2_dqkch")
|
||||
region = Rect2(96, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qhqgy"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(0, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dqkch"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(48, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(96, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(144, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(192, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_smehm"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(240, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_ur7pv"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(288, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_y4r1p"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(336, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_d2wvv"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(384, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_3v2ag"]
|
||||
atlas = ExtResource("2_g2els")
|
||||
region = Rect2(432, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"]
|
||||
atlas = ExtResource("2_dqkch")
|
||||
region = Rect2(0, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_oprun"]
|
||||
atlas = ExtResource("2_dqkch")
|
||||
region = Rect2(48, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a8ls1"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(0, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qfm1y"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(48, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fulsm"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(96, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4r5pv"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(144, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_60mlk"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(192, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_i4ail"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(240, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_a38lo"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(288, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_4ni07"]
|
||||
atlas = ExtResource("4_qlg0r")
|
||||
region = Rect2(336, 0, 48, 48)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_jej6c"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_jej6c")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"fall",
|
||||
"speed": 12.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qhqgy")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dqkch")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qlg0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tuyoq")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fjrip")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_smehm")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_ur7pv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_y4r1p")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_d2wvv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_3v2ag")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"idle",
|
||||
"speed": 12.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_f1ej7")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_oprun")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"jump",
|
||||
"speed": 12.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_a8ls1")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qfm1y")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fulsm")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4r5pv")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_60mlk")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_i4ail")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_a38lo")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_4ni07")
|
||||
}],
|
||||
"loop": true,
|
||||
"name": &"run",
|
||||
"speed": 12.0
|
||||
}]
|
||||
|
||||
[node name="CharacterBody2D" type="CharacterBody2D"]
|
||||
script = ExtResource("1_3vyb7")
|
||||
|
||||
@ -22,3 +195,15 @@ position = Vector2(14, -8)
|
||||
|
||||
[node name="LeftSpawn" type="Marker2D" parent="."]
|
||||
position = Vector2(-13, -8)
|
||||
|
||||
[node name="JumpBufferTimer" type="Timer" parent="."]
|
||||
one_shot = true
|
||||
|
||||
[node name="AnimatedSprite2D" type="AnimatedSprite2D" parent="."]
|
||||
texture_filter = 1
|
||||
position = Vector2(1, -6)
|
||||
sprite_frames = SubResource("SpriteFrames_jej6c")
|
||||
animation = &"fall"
|
||||
autoplay = "idle"
|
||||
|
||||
[connection signal="animation_finished" from="AnimatedSprite2D" to="." method="_on_animation_finished"]
|
||||
|
||||
@ -3,6 +3,9 @@ extends CharacterBody2D
|
||||
|
||||
const SPEED = 300.0
|
||||
const JUMP_VELOCITY = -400.0
|
||||
#add a variable for momentum...t.w.
|
||||
@export var acceleration:int = 8
|
||||
@export var hard_gravity:float =1.5
|
||||
var direction:float = 0
|
||||
@export var BUMP_POWER = 100
|
||||
enum FaceDirection{LEFT, RIGHT}
|
||||
@ -14,23 +17,64 @@ var pushEnabled:bool = false
|
||||
@onready var right_spawn = $RightSpawn
|
||||
@onready var left_spawn = $LeftSpawn
|
||||
|
||||
var upJump:bool = false
|
||||
@onready var jump_buffer_timer: Timer = $JumpBufferTimer
|
||||
@onready var player_graphic: AnimatedSprite2D = $AnimatedSprite2D
|
||||
|
||||
#For State Machine.............t.w.
|
||||
enum State{IDLE, RUNNING, JUMP, FALLING}
|
||||
var current_state:State = State.IDLE
|
||||
|
||||
func _physics_process(delta):
|
||||
# Get the input direction and handle the movement/deceleration.
|
||||
# As good practice, you should replace UI actions with custom gameplay actions.
|
||||
handle_input()
|
||||
handle_movement(delta)
|
||||
update_states()
|
||||
update_animation()
|
||||
move_and_slide()
|
||||
handle_collisions()
|
||||
|
||||
#Create a State Machine.........t.w.
|
||||
func update_states()->void:
|
||||
match current_state:
|
||||
State.IDLE when velocity.x !=0:
|
||||
current_state = State.RUNNING
|
||||
State.RUNNING:
|
||||
if velocity.x ==0:
|
||||
current_state = State.IDLE
|
||||
#jumping when reaching apex
|
||||
State.JUMP when velocity.y > 0:
|
||||
current_state = State.FALLING
|
||||
State.FALLING when is_on_floor():
|
||||
if velocity.x == 0:
|
||||
current_state = State.IDLE
|
||||
else:
|
||||
current_state = State.RUNNING
|
||||
func update_animation():
|
||||
match current_state:
|
||||
State.IDLE:
|
||||
player_graphic.play("idle")
|
||||
State.RUNNING:
|
||||
player_graphic.play("run")
|
||||
State.JUMP:
|
||||
if upJump:
|
||||
player_graphic.play("jump")
|
||||
State.FALLING:
|
||||
player_graphic.play("fall")
|
||||
|
||||
func handle_input()->void:
|
||||
# Handle jump.
|
||||
if Input.is_action_just_pressed("jump") and is_on_floor():
|
||||
velocity.y = JUMP_VELOCITY
|
||||
jump_buffer_timer.start()
|
||||
|
||||
direction = Input.get_axis("moveLeft", "moveRight")
|
||||
if direction <0:
|
||||
facing=FaceDirection.LEFT
|
||||
player_graphic.flip_h = true
|
||||
if direction >0:
|
||||
facing=FaceDirection.RIGHT
|
||||
player_graphic.flip_h = false
|
||||
|
||||
if Input.is_action_just_pressed("shove") && pushEnabled:
|
||||
print("I want to shove")
|
||||
@ -60,14 +104,27 @@ func handle_input()->void:
|
||||
%SceneManager.makeGrenade(left_spawn.global_transform, -1)
|
||||
|
||||
func handle_movement(_delta)->void:
|
||||
if direction:
|
||||
velocity.x = direction * SPEED
|
||||
#change to create some momentum.....t.w.
|
||||
if direction == 0:
|
||||
velocity.x = move_toward(velocity.x, 0, acceleration)
|
||||
else:
|
||||
velocity.x = move_toward(velocity.x, 0, SPEED)
|
||||
velocity.x = move_toward(velocity.x, SPEED * direction, acceleration)
|
||||
|
||||
if not is_on_floor():
|
||||
if current_state == State.JUMP:
|
||||
#apply normal velocity
|
||||
velocity += get_gravity() * _delta
|
||||
else:
|
||||
#apply hard gravity, character falling
|
||||
velocity += get_gravity() * hard_gravity * _delta
|
||||
|
||||
#add a buffer timer to the jump velocity............t.w.
|
||||
if is_on_floor() && jump_buffer_timer.time_left >0:
|
||||
velocity.y = JUMP_VELOCITY
|
||||
#change state...........t.w.
|
||||
current_state = State.JUMP
|
||||
upJump = true
|
||||
jump_buffer_timer.stop()
|
||||
|
||||
func handle_collisions()->void:
|
||||
#handle world reactions
|
||||
for i in get_slide_collision_count():
|
||||
@ -90,3 +147,9 @@ func handle_collisions()->void:
|
||||
|
||||
if not right_cast.is_colliding() && not left_cast.is_colliding():
|
||||
pushEnabled = false
|
||||
|
||||
|
||||
func _on_animation_finished() -> void:
|
||||
match current_state:
|
||||
State.JUMP:
|
||||
upJump=false
|
||||
|
||||
Loading…
Reference in New Issue
Block a user