adding a charge attack to states
This commit is contained in:
parent
29b125f5af
commit
2dd2c13b19
6
Week3Readme.md
Normal file
6
Week3Readme.md
Normal file
@ -0,0 +1,6 @@
|
||||
Here in week3 we have several missions to achieve.
|
||||
|
||||
1. Update the Bullet with some graphics
|
||||
2. Update the player with graphics and a state-machine
|
||||
3. Update the destroy function in SceneManager to stash bullets
|
||||
4. Update level loading in GameController and SceneManager
|
||||
BIN
assets/graphics/player/charge/Player Punch 64x64.png
Normal file
BIN
assets/graphics/player/charge/Player Punch 64x64.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 3.2 KiB |
40
assets/graphics/player/charge/Player Punch 64x64.png.import
Normal file
40
assets/graphics/player/charge/Player Punch 64x64.png.import
Normal file
@ -0,0 +1,40 @@
|
||||
[remap]
|
||||
|
||||
importer="texture"
|
||||
type="CompressedTexture2D"
|
||||
uid="uid://t2wrpg2jjey2"
|
||||
path="res://.godot/imported/Player Punch 64x64.png-3a937f356fef19bd687f033e25d25550.ctex"
|
||||
metadata={
|
||||
"vram_texture": false
|
||||
}
|
||||
|
||||
[deps]
|
||||
|
||||
source_file="res://assets/graphics/player/charge/Player Punch 64x64.png"
|
||||
dest_files=["res://.godot/imported/Player Punch 64x64.png-3a937f356fef19bd687f033e25d25550.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
|
||||
@ -2,11 +2,16 @@
|
||||
|
||||
[ext_resource type="Script" uid="uid://b1obldvd2etx7" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||
[ext_resource type="Texture2D" uid="uid://c84o6tpt2h0s8" path="res://assets/graphics/player/jump_fall/player jump 48x48.png" id="2_dqkch"]
|
||||
[ext_resource type="Texture2D" uid="uid://t2wrpg2jjey2" path="res://assets/graphics/player/charge/Player Punch 64x64.png" id="2_qlg0r"]
|
||||
[ext_resource type="Texture2D" uid="uid://bhjnspvqa20rc" path="res://assets/graphics/player/idle/Player Idle 48x48.png" id="3_qlg0r"]
|
||||
[ext_resource type="Texture2D" uid="uid://jdvo0dp5qvnd" path="res://assets/graphics/player/running/player run 48x48.png" id="4_tuyoq"]
|
||||
|
||||
[sub_resource type="CircleShape2D" id="CircleShape2D_uwrxv"]
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_tuyoq"]
|
||||
atlas = ExtResource("2_qlg0r")
|
||||
region = Rect2(192, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_fjrip"]
|
||||
atlas = ExtResource("2_dqkch")
|
||||
region = Rect2(96, 0, 48, 48)
|
||||
@ -91,10 +96,34 @@ region = Rect2(288, 0, 48, 48)
|
||||
atlas = ExtResource("4_tuyoq")
|
||||
region = Rect2(336, 0, 48, 48)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_qlg0r"]
|
||||
atlas = ExtResource("2_qlg0r")
|
||||
region = Rect2(192, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_pf23h"]
|
||||
atlas = ExtResource("2_qlg0r")
|
||||
region = Rect2(256, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_dt7fs"]
|
||||
atlas = ExtResource("2_qlg0r")
|
||||
region = Rect2(320, 0, 64, 64)
|
||||
|
||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wqfne"]
|
||||
atlas = ExtResource("2_qlg0r")
|
||||
region = Rect2(384, 0, 64, 64)
|
||||
|
||||
[sub_resource type="SpriteFrames" id="SpriteFrames_pf23h"]
|
||||
animations = [{
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_tuyoq")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"charging",
|
||||
"speed": 12.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_fjrip")
|
||||
}],
|
||||
"loop": false,
|
||||
@ -175,6 +204,23 @@ animations = [{
|
||||
"loop": true,
|
||||
"name": &"running",
|
||||
"speed": 12.0
|
||||
}, {
|
||||
"frames": [{
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_qlg0r")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_pf23h")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_dt7fs")
|
||||
}, {
|
||||
"duration": 1.0,
|
||||
"texture": SubResource("AtlasTexture_wqfne")
|
||||
}],
|
||||
"loop": false,
|
||||
"name": &"shoving",
|
||||
"speed": 12.0
|
||||
}]
|
||||
|
||||
[node name="Player" type="CharacterBody2D" unique_id=2145223914]
|
||||
@ -202,7 +248,7 @@ position = Vector2(-12.837839, -8.108109)
|
||||
texture_filter = 1
|
||||
position = Vector2(0, -6.081082)
|
||||
sprite_frames = SubResource("SpriteFrames_pf23h")
|
||||
animation = &"falling"
|
||||
animation = &"shoving"
|
||||
autoplay = "idle"
|
||||
|
||||
[connection signal="animation_finished" from="PlayerGraphic" to="." method="_on_animation_finished"]
|
||||
|
||||
@ -19,7 +19,7 @@ const JUMP_VELOCITY = -400.0
|
||||
enum FaceDirection {RIGHT,LEFT}
|
||||
var facing:FaceDirection = FaceDirection.RIGHT
|
||||
#State Handling
|
||||
enum PlayerState {IDLE, RUNNING, JUMPING, FALLING}
|
||||
enum PlayerState {IDLE, RUNNING, JUMPING, FALLING, CHARGING, SHOVING}
|
||||
var current_player_state:PlayerState = PlayerState.IDLE
|
||||
var upJump:bool = false
|
||||
|
||||
@ -43,15 +43,23 @@ func handle_input()->void:
|
||||
# Handle shove.
|
||||
if Input.is_action_just_pressed("shove"):
|
||||
print("I want to shove")
|
||||
pushTimer = Time.get_ticks_msec()
|
||||
if pushRightEnabled and facing==FaceDirection.RIGHT:
|
||||
pushTimer = Time.get_ticks_msec()
|
||||
current_player_state = PlayerState.CHARGING
|
||||
if pushLeftEnabled and facing==FaceDirection.LEFT:
|
||||
pushTimer = Time.get_ticks_msec()
|
||||
current_player_state = PlayerState.CHARGING
|
||||
|
||||
if Input.is_action_just_released("shove"):
|
||||
var pushForce = Time.get_ticks_msec() - pushTimer
|
||||
if pushForce>4000:
|
||||
pushForce=4000
|
||||
if pushRightEnabled and facing==FaceDirection.RIGHT:
|
||||
#deliver the boom
|
||||
current_player_state=PlayerState.SHOVING
|
||||
pushSignal.emit(pushTarget, Vector2(1,0)*100*(pushForce/100))
|
||||
if pushLeftEnabled and facing==FaceDirection.LEFT:
|
||||
current_player_state=PlayerState.SHOVING
|
||||
pushSignal.emit(pushTarget, Vector2(-1,0)*100*(pushForce/100))
|
||||
#Handle Shoot Bullet
|
||||
if Input.is_action_just_pressed("shoot"):
|
||||
@ -140,9 +148,15 @@ func handle_update_animation()->void:
|
||||
player_graphic.play("jumping")
|
||||
PlayerState.FALLING:
|
||||
player_graphic.play("falling")
|
||||
PlayerState.CHARGING:
|
||||
player_graphic.play("charging")
|
||||
PlayerState.SHOVING:
|
||||
player_graphic.play("shoving")
|
||||
|
||||
|
||||
func _on_animation_finished() -> void:
|
||||
match current_player_state:
|
||||
PlayerState.JUMPING:
|
||||
upJump = false
|
||||
PlayerState.SHOVING:
|
||||
current_player_state = PlayerState.IDLE
|
||||
|
||||
@ -58,7 +58,7 @@ func stash(bullet:Bullet)->void:
|
||||
func destroy(body)->void:
|
||||
match body:
|
||||
var bod when bod is Rocket:
|
||||
print("removing rocket")
|
||||
body.queue_free()
|
||||
var bod when bod is Crate:
|
||||
body.queue_free()
|
||||
var bod when bod is Bullet:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user