cleaned up player code and animations a bit; mapped new colours onto veg assets
This commit is contained in:
parent
f1d7c8968a
commit
a57003ec24
Binary file not shown.
|
Before Width: | Height: | Size: 1.2 KiB After Width: | Height: | Size: 1.1 KiB |
Binary file not shown.
|
Before Width: | Height: | Size: 675 B After Width: | Height: | Size: 291 B |
@ -22,10 +22,10 @@ GameController="*res://scripts/game_controller.gd"
|
|||||||
|
|
||||||
[display]
|
[display]
|
||||||
|
|
||||||
window/size/viewport_width=320
|
window/size/viewport_width=480
|
||||||
window/size/viewport_height=180
|
window/size/viewport_height=270
|
||||||
window/size/window_width_override=640
|
window/size/window_width_override=1280
|
||||||
window/size/window_height_override=360
|
window/size/window_height_override=720
|
||||||
window/stretch/mode="viewport"
|
window/stretch/mode="viewport"
|
||||||
|
|
||||||
[file_customization]
|
[file_customization]
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
[gd_scene load_steps=58 format=3 uid="uid://d3y1iqmpknpyo"]
|
[gd_scene load_steps=56 format=3 uid="uid://d3y1iqmpknpyo"]
|
||||||
|
|
||||||
[ext_resource type="Script" uid="uid://d3hp5rjoph7hg" path="res://scripts/player.gd" id="1_3vyb7"]
|
[ext_resource type="Script" uid="uid://d3hp5rjoph7hg" path="res://scripts/player.gd" id="1_3vyb7"]
|
||||||
[ext_resource type="Texture2D" uid="uid://dr3rp5hv7rexv" path="res://graphics/animations/player_idle/Player Idle 48x48.png" id="2_g2els"]
|
[ext_resource type="Texture2D" uid="uid://dr3rp5hv7rexv" path="res://graphics/animations/player_idle/Player Idle 48x48.png" id="2_g2els"]
|
||||||
@ -132,10 +132,6 @@ region = Rect2(288, 0, 48, 48)
|
|||||||
atlas = ExtResource("4_qlg0r")
|
atlas = ExtResource("4_qlg0r")
|
||||||
region = Rect2(336, 0, 48, 48)
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"]
|
|
||||||
atlas = ExtResource("5_tuyoq")
|
|
||||||
region = Rect2(0, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_l71n6"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_l71n6"]
|
||||||
atlas = ExtResource("5_tuyoq")
|
atlas = ExtResource("5_tuyoq")
|
||||||
region = Rect2(48, 0, 48, 48)
|
region = Rect2(48, 0, 48, 48)
|
||||||
@ -164,6 +160,10 @@ region = Rect2(288, 0, 48, 48)
|
|||||||
atlas = ExtResource("5_tuyoq")
|
atlas = ExtResource("5_tuyoq")
|
||||||
region = Rect2(336, 0, 48, 48)
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
|
[sub_resource type="AtlasTexture" id="AtlasTexture_f1ej7"]
|
||||||
|
atlas = ExtResource("5_tuyoq")
|
||||||
|
region = Rect2(0, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"]
|
[sub_resource type="AtlasTexture" id="AtlasTexture_wnwbv"]
|
||||||
atlas = ExtResource("6_fjrip")
|
atlas = ExtResource("6_fjrip")
|
||||||
region = Rect2(0, 0, 48, 48)
|
region = Rect2(0, 0, 48, 48)
|
||||||
@ -196,14 +196,6 @@ region = Rect2(288, 0, 48, 48)
|
|||||||
atlas = ExtResource("6_fjrip")
|
atlas = ExtResource("6_fjrip")
|
||||||
region = Rect2(336, 0, 48, 48)
|
region = Rect2(336, 0, 48, 48)
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_j2b1d"]
|
|
||||||
atlas = ExtResource("6_fjrip")
|
|
||||||
region = Rect2(384, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="AtlasTexture" id="AtlasTexture_cs1tg"]
|
|
||||||
atlas = ExtResource("6_fjrip")
|
|
||||||
region = Rect2(432, 0, 48, 48)
|
|
||||||
|
|
||||||
[sub_resource type="SpriteFrames" id="SpriteFrames_3vyb7"]
|
[sub_resource type="SpriteFrames" id="SpriteFrames_3vyb7"]
|
||||||
animations = [{
|
animations = [{
|
||||||
"frames": [{
|
"frames": [{
|
||||||
@ -323,9 +315,6 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"frames": [{
|
"frames": [{
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_f1ej7")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_l71n6")
|
"texture": SubResource("AtlasTexture_l71n6")
|
||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
@ -345,6 +334,9 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_wqfne")
|
"texture": SubResource("AtlasTexture_wqfne")
|
||||||
|
}, {
|
||||||
|
"duration": 1.0,
|
||||||
|
"texture": SubResource("AtlasTexture_f1ej7")
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": &"shoot_run",
|
"name": &"shoot_run",
|
||||||
@ -374,12 +366,6 @@ animations = [{
|
|||||||
}, {
|
}, {
|
||||||
"duration": 1.0,
|
"duration": 1.0,
|
||||||
"texture": SubResource("AtlasTexture_t4otl")
|
"texture": SubResource("AtlasTexture_t4otl")
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_j2b1d")
|
|
||||||
}, {
|
|
||||||
"duration": 1.0,
|
|
||||||
"texture": SubResource("AtlasTexture_cs1tg")
|
|
||||||
}],
|
}],
|
||||||
"loop": false,
|
"loop": false,
|
||||||
"name": &"shoot_still",
|
"name": &"shoot_still",
|
||||||
@ -411,13 +397,12 @@ position = Vector2(-16, -7)
|
|||||||
|
|
||||||
[node name="PlayerSprite" type="AnimatedSprite2D" parent="."]
|
[node name="PlayerSprite" type="AnimatedSprite2D" parent="."]
|
||||||
sprite_frames = SubResource("SpriteFrames_3vyb7")
|
sprite_frames = SubResource("SpriteFrames_3vyb7")
|
||||||
animation = &"punch"
|
animation = &"shoot_still"
|
||||||
autoplay = "idle"
|
autoplay = "idle"
|
||||||
frame = 9
|
|
||||||
frame_progress = 1.0
|
|
||||||
|
|
||||||
[node name="Camera2D" type="Camera2D" parent="."]
|
[node name="Camera2D" type="Camera2D" parent="."]
|
||||||
offset = Vector2(0, -50)
|
offset = Vector2(0, -50)
|
||||||
|
position_smoothing_enabled = true
|
||||||
|
|
||||||
[node name="DebugInfo" type="CanvasLayer" parent="."]
|
[node name="DebugInfo" type="CanvasLayer" parent="."]
|
||||||
|
|
||||||
|
|||||||
@ -2,7 +2,7 @@ extends Node2D
|
|||||||
|
|
||||||
var coins_collected : int = 0
|
var coins_collected : int = 0
|
||||||
var total_coins : int = 0
|
var total_coins : int = 0
|
||||||
var levels = ["res://scenes/game.tscn", "res://scenes/level_2.tscn", "res://scenes/level_3.tscn"]
|
var levels = ["res://scenes/level_1.tscn", "res://scenes/level_2.tscn", "res://scenes/level_3.tscn"]
|
||||||
var timers = [10, 15, 20]
|
var timers = [10, 15, 20]
|
||||||
var time_available : int = 0
|
var time_available : int = 0
|
||||||
var current_level = 0
|
var current_level = 0
|
||||||
|
|||||||
@ -18,16 +18,16 @@ enum State {
|
|||||||
PUNCH
|
PUNCH
|
||||||
}
|
}
|
||||||
|
|
||||||
const JUMP_VELOCITY = -500.0
|
const JUMP_VELOCITY := -500.0 ## Power applied for jumping
|
||||||
const SPEED = 200.0
|
const SPEED := 200.0 ## (Max) movement speed
|
||||||
|
|
||||||
@export var BUMP_POWER := 50 ## Power from bumping into objects
|
@export var BUMP_POWER := 50 ## Power from bumping into objects
|
||||||
@export var PUNCH_POWER := 300 ## Power from shoving objects
|
@export var PUNCH_POWER := 300 ## Power from shoving objects
|
||||||
@export var ACCELERATION := 10 ## Amount of "slide-y-ness" in side-to-side-movement
|
@export var ACCELERATION := 10 ## Amount of "slide-y-ness" in side-to-side-movement
|
||||||
@export var HARD_GRAVITY := 2 ## Factor applied during FALL state
|
@export var HARD_GRAVITY := 2 ## Factor applied during FALL state
|
||||||
|
|
||||||
var current_state: State = State.IDLE
|
var current_state: State = State.IDLE ## Player state for FSM
|
||||||
var facing : FaceDirection = FaceDirection.RIGHT
|
var facing : FaceDirection = FaceDirection.RIGHT ## Facing direction for animation orientation
|
||||||
var direction : float = 0.0
|
var direction : float = 0.0
|
||||||
var punch_target : RigidBody2D
|
var punch_target : RigidBody2D
|
||||||
var punch_enabled : bool = false
|
var punch_enabled : bool = false
|
||||||
@ -42,6 +42,7 @@ var shoot_cooldown_timer : Timer
|
|||||||
|
|
||||||
func _ready() -> void:
|
func _ready() -> void:
|
||||||
jump_buffer_timer = Timer.new()
|
jump_buffer_timer = Timer.new()
|
||||||
|
jump_buffer_timer.one_shot = true
|
||||||
add_child(jump_buffer_timer)
|
add_child(jump_buffer_timer)
|
||||||
shoot_cooldown_timer = Timer.new()
|
shoot_cooldown_timer = Timer.new()
|
||||||
shoot_cooldown_timer.one_shot = true
|
shoot_cooldown_timer.one_shot = true
|
||||||
@ -95,28 +96,22 @@ func handle_input() -> void:
|
|||||||
current_state = State.SHOOT_RUN
|
current_state = State.SHOOT_RUN
|
||||||
else:
|
else:
|
||||||
current_state = State.SHOOT_STILL
|
current_state = State.SHOOT_STILL
|
||||||
print("pew-pew")
|
|
||||||
match facing:
|
match facing:
|
||||||
FaceDirection.RIGHT:
|
FaceDirection.RIGHT:
|
||||||
%SceneManager.make_bullet(right_spawn.global_transform, 700)
|
%SceneManager.make_bullet(right_spawn.global_transform, 700)
|
||||||
print("shoot right")
|
|
||||||
FaceDirection.LEFT:
|
FaceDirection.LEFT:
|
||||||
%SceneManager.make_bullet(left_spawn.global_transform, -700)
|
%SceneManager.make_bullet(left_spawn.global_transform, -700)
|
||||||
print("shoot left")
|
|
||||||
shoot_cooldown_timer.start(0.2)
|
shoot_cooldown_timer.start(0.2)
|
||||||
else:
|
else:
|
||||||
print("can't shoot right now because there are %s seconds left in the cooldown timer" % shoot_cooldown_timer.time_left)
|
print("can't shoot right now because there are %s seconds left in the cooldown timer" % shoot_cooldown_timer.time_left)
|
||||||
|
|
||||||
# Handle throwing grenades
|
# Handle throwing grenades
|
||||||
if Input.is_action_just_pressed("throw"):
|
if Input.is_action_just_pressed("throw"):
|
||||||
print("grenade!")
|
|
||||||
match facing:
|
match facing:
|
||||||
FaceDirection.RIGHT:
|
FaceDirection.RIGHT:
|
||||||
%SceneManager.make_grenade(right_spawn.global_transform, 1.0)
|
%SceneManager.make_grenade(right_spawn.global_transform, 1.0)
|
||||||
print("throwing right")
|
|
||||||
FaceDirection.LEFT:
|
FaceDirection.LEFT:
|
||||||
%SceneManager.make_grenade(left_spawn.global_transform, -1.0)
|
%SceneManager.make_grenade(left_spawn.global_transform, -1.0)
|
||||||
print("throwing left")
|
|
||||||
|
|
||||||
func handle_movement(delta) -> void:
|
func handle_movement(delta) -> void:
|
||||||
# Left-right movement. Use acceleration for smoothing
|
# Left-right movement. Use acceleration for smoothing
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user