Compare commits
4 Commits
614ee06c34
...
11b0e77b48
Author | SHA1 | Date |
---|---|---|
Felipe M | 11b0e77b48 | |
Felipe M | ef19463d6e | |
Felipe M | 7f8aabadcf | |
Felipe M | abb03863b9 |
|
@ -0,0 +1,18 @@
|
|||
extends ColorRect
|
||||
|
||||
var paused = false setget set_paused
|
||||
|
||||
func set_paused(value):
|
||||
paused = value
|
||||
get_tree().paused = paused
|
||||
visible = paused
|
||||
|
||||
func _on_ResumeButton_pressed():
|
||||
self.paused = false
|
||||
|
||||
func _on_QuitButton_pressed():
|
||||
get_tree().quit()
|
||||
|
||||
func _process(_delta):
|
||||
if Input.is_action_just_pressed("pause"):
|
||||
self.paused = !paused
|
|
@ -0,0 +1,57 @@
|
|||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/UI/DefaultTheme.tres" type="Theme" id=1]
|
||||
[ext_resource path="res://Scenes/Menus/PauseMenu.gd" type="Script" id=2]
|
||||
|
||||
[node name="PauseMenu" type="ColorRect"]
|
||||
pause_mode = 2
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
theme = ExtResource( 1 )
|
||||
color = Color( 0, 0, 0, 1 )
|
||||
script = ExtResource( 2 )
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="CenterContainer" type="CenterContainer" parent="."]
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="CenterContainer"]
|
||||
margin_left = 128.0
|
||||
margin_top = 54.0
|
||||
margin_right = 192.0
|
||||
margin_bottom = 125.0
|
||||
|
||||
[node name="PauseLabel" type="Label" parent="CenterContainer/VBoxContainer"]
|
||||
margin_right = 64.0
|
||||
margin_bottom = 15.0
|
||||
theme = ExtResource( 1 )
|
||||
text = "GAME PAUSED"
|
||||
align = 1
|
||||
|
||||
[node name="Gap" type="Control" parent="CenterContainer/VBoxContainer"]
|
||||
margin_top = 19.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 31.0
|
||||
rect_min_size = Vector2( 12, 12 )
|
||||
|
||||
[node name="ResumeButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
||||
margin_top = 35.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 51.0
|
||||
rect_min_size = Vector2( 64, 16 )
|
||||
text = "Resume game"
|
||||
|
||||
[node name="QuitButton" type="Button" parent="CenterContainer/VBoxContainer"]
|
||||
margin_top = 55.0
|
||||
margin_right = 64.0
|
||||
margin_bottom = 71.0
|
||||
rect_min_size = Vector2( 64, 16 )
|
||||
text = "Quit"
|
||||
[connection signal="pressed" from="CenterContainer/VBoxContainer/ResumeButton" to="." method="_on_ResumeButton_pressed"]
|
||||
[connection signal="pressed" from="CenterContainer/VBoxContainer/QuitButton" to="." method="_on_QuitButton_pressed"]
|
|
@ -11,13 +11,22 @@ export (int) var max_speed = 64
|
|||
export (float) var friction = 0.25
|
||||
export (int) var gravity = 200
|
||||
export (int) var jump_force = 128
|
||||
export (int) var wall_slide_speed = 48
|
||||
export (int) var max_wall_slide_speed = 128
|
||||
export (int) var max_slope = 46
|
||||
export (int) var bullet_speed = 250
|
||||
|
||||
enum {
|
||||
MOVE,
|
||||
WALL_SLIDE
|
||||
}
|
||||
|
||||
var state = MOVE
|
||||
var invincible = false setget set_invincible
|
||||
var motion = Vector2.ZERO
|
||||
var snap_vector = Vector2.ZERO
|
||||
var just_jumped= false
|
||||
var just_jumped = false
|
||||
var double_jump = true
|
||||
|
||||
onready var sprite = $Sprite
|
||||
onready var animation = $Animation
|
||||
|
@ -36,15 +45,33 @@ func _ready():
|
|||
|
||||
func _physics_process(delta):
|
||||
just_jumped = false
|
||||
var input_vector = get_input_vector()
|
||||
apply_horizontal_force(input_vector, delta)
|
||||
apply_friction(input_vector)
|
||||
update_snap_vector()
|
||||
jump_check()
|
||||
apply_gravity(delta)
|
||||
update_animations(input_vector)
|
||||
move()
|
||||
|
||||
match state:
|
||||
MOVE:
|
||||
var input_vector = get_input_vector()
|
||||
apply_horizontal_force(input_vector, delta)
|
||||
apply_friction(input_vector)
|
||||
update_snap_vector()
|
||||
jump_check()
|
||||
apply_gravity(delta)
|
||||
update_animations(input_vector)
|
||||
move()
|
||||
|
||||
wall_slide_check()
|
||||
|
||||
WALL_SLIDE:
|
||||
animation.play("WallSlide")
|
||||
|
||||
var wall_axis = get_wall_axis()
|
||||
if wall_axis != 0:
|
||||
sprite.scale.x = wall_axis
|
||||
|
||||
wall_slide_jump_check(wall_axis)
|
||||
wall_slide_drop_check(delta)
|
||||
wall_slide_fast_slide_check(delta)
|
||||
move()
|
||||
wall_detach_check(wall_axis)
|
||||
|
||||
if Input.is_action_pressed("fire") and fireBulletTimer.time_left == 0:
|
||||
fire_bullet()
|
||||
|
||||
|
@ -78,16 +105,23 @@ func update_snap_vector():
|
|||
if is_on_floor():
|
||||
snap_vector = Vector2.DOWN
|
||||
|
||||
func jump(force):
|
||||
Utils.instance_scene_on_main(JumpEffect, global_position)
|
||||
motion.y = -force
|
||||
snap_vector = Vector2.ZERO
|
||||
|
||||
func jump_check():
|
||||
if is_on_floor() or coyoteJumpTimer.time_left > 0:
|
||||
if Input.is_action_just_pressed("ui_select"):
|
||||
Utils.instance_scene_on_main(JumpEffect, global_position)
|
||||
motion.y = -jump_force
|
||||
snap_vector = Vector2.ZERO
|
||||
jump(jump_force)
|
||||
just_jumped = true
|
||||
else:
|
||||
if Input.is_action_just_released("ui_select") and motion.y < -jump_force/2:
|
||||
motion.y = motion.y/2
|
||||
|
||||
if Input.is_action_just_pressed("ui_select") and double_jump:
|
||||
jump(jump_force * .75)
|
||||
double_jump = false
|
||||
|
||||
func apply_gravity(delta):
|
||||
if not is_on_floor():
|
||||
|
@ -121,6 +155,7 @@ func move():
|
|||
motion.x = last_motion.x
|
||||
#create_dust_effect()
|
||||
Utils.instance_scene_on_main(JumpEffect, global_position)
|
||||
double_jump = true
|
||||
|
||||
|
||||
# Just left ground
|
||||
|
@ -135,11 +170,45 @@ func move():
|
|||
if is_on_floor() and get_floor_velocity().length() == 0 and abs(motion.x) < 1:
|
||||
position.x = last_position.x
|
||||
|
||||
func wall_slide_check():
|
||||
if !is_on_floor() and is_on_wall():
|
||||
state = WALL_SLIDE
|
||||
double_jump = true
|
||||
|
||||
func get_wall_axis():
|
||||
var is_right_wall = test_move(transform, Vector2.RIGHT)
|
||||
var is_left_wall = test_move(transform, Vector2.LEFT)
|
||||
return int(is_left_wall) - int(is_right_wall)
|
||||
|
||||
func wall_slide_jump_check(wall_axis):
|
||||
if Input.is_action_just_pressed("ui_select"):
|
||||
motion.x = wall_axis * max_speed
|
||||
motion.y = -jump_force/1.25
|
||||
state = MOVE
|
||||
|
||||
func wall_slide_drop_check(delta):
|
||||
if Input.is_action_just_pressed("ui_right"):
|
||||
motion.x = acceleration * delta
|
||||
state = MOVE
|
||||
|
||||
if Input.is_action_just_pressed("ui_left"):
|
||||
motion.x = -acceleration * delta
|
||||
state = MOVE
|
||||
|
||||
func wall_slide_fast_slide_check(delta):
|
||||
var max_slide_speed = wall_slide_speed
|
||||
if Input.is_action_just_pressed("ui_down"):
|
||||
max_slide_speed = max_wall_slide_speed
|
||||
motion.y = min(motion.y + gravity * delta, max_wall_slide_speed)
|
||||
|
||||
func wall_detach_check(wall_axis):
|
||||
if wall_axis == 0 or is_on_floor():
|
||||
state = MOVE
|
||||
|
||||
func _on_Hurtbox_hit(damage):
|
||||
if not invincible:
|
||||
PlayerStats.health -= damage
|
||||
blinkAnimator.play("Blink")
|
||||
|
||||
|
||||
func _on_died():
|
||||
queue_free()
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=11 format=2]
|
||||
[gd_scene load_steps=12 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Player/Player.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Scenes/Player/Player.gd" type="Script" id=2]
|
||||
|
@ -7,7 +7,7 @@
|
|||
[ext_resource path="res://Scenes/Objects/Hurtbox.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://Scenes/Player/PlayerCollider.tres" type="Shape2D" id=6]
|
||||
|
||||
[sub_resource type="Animation" id=2]
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "Idle"
|
||||
length = 1.2
|
||||
loop = true
|
||||
|
@ -24,7 +24,7 @@ tracks/0/keys = {
|
|||
"values": [ 0, 1, 2, 3 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=3]
|
||||
[sub_resource type="Animation" id=2]
|
||||
resource_name = "Jump"
|
||||
length = 0.1
|
||||
tracks/0/type = "value"
|
||||
|
@ -40,7 +40,7 @@ tracks/0/keys = {
|
|||
"values": [ 11 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
[sub_resource type="Animation" id=3]
|
||||
resource_name = "Run"
|
||||
length = 0.6
|
||||
loop = true
|
||||
|
@ -75,6 +75,22 @@ tracks/1/keys = {
|
|||
}
|
||||
|
||||
[sub_resource type="Animation" id=5]
|
||||
resource_name = "WallSlide"
|
||||
length = 0.1
|
||||
tracks/0/type = "value"
|
||||
tracks/0/path = NodePath("Sprite:frame")
|
||||
tracks/0/interp = 1
|
||||
tracks/0/loop_wrap = true
|
||||
tracks/0/imported = false
|
||||
tracks/0/enabled = true
|
||||
tracks/0/keys = {
|
||||
"times": PoolRealArray( 0 ),
|
||||
"transitions": PoolRealArray( 1 ),
|
||||
"update": 1,
|
||||
"values": [ 10 ]
|
||||
}
|
||||
|
||||
[sub_resource type="Animation" id=4]
|
||||
resource_name = "Blink"
|
||||
length = 0.9
|
||||
tracks/0/type = "value"
|
||||
|
@ -115,7 +131,7 @@ script = ExtResource( 2 )
|
|||
position = Vector2( 0, -12 )
|
||||
texture = ExtResource( 1 )
|
||||
hframes = 12
|
||||
frame = 4
|
||||
frame = 11
|
||||
|
||||
[node name="PlayerGun" parent="Sprite" instance=ExtResource( 4 )]
|
||||
show_behind_parent = true
|
||||
|
@ -126,12 +142,13 @@ position = Vector2( 0, -7 )
|
|||
shape = ExtResource( 6 )
|
||||
|
||||
[node name="Animation" type="AnimationPlayer" parent="."]
|
||||
anims/Idle = SubResource( 2 )
|
||||
anims/Jump = SubResource( 3 )
|
||||
anims/Run = SubResource( 4 )
|
||||
anims/Idle = SubResource( 1 )
|
||||
anims/Jump = SubResource( 2 )
|
||||
anims/Run = SubResource( 3 )
|
||||
anims/WallSlide = SubResource( 5 )
|
||||
|
||||
[node name="BlinkAnimator" type="AnimationPlayer" parent="."]
|
||||
anims/Blink = SubResource( 5 )
|
||||
anims/Blink = SubResource( 4 )
|
||||
|
||||
[node name="Debug" parent="." instance=ExtResource( 3 )]
|
||||
visible = false
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,7 @@
|
|||
[gd_scene load_steps=2 format=2]
|
||||
[gd_scene load_steps=3 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/UI/HealthMeter.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Scenes/Menus/PauseMenu.tscn" type="PackedScene" id=2]
|
||||
|
||||
[node name="UI" type="CanvasLayer"]
|
||||
|
||||
|
@ -9,3 +10,6 @@ margin_left = 4.0
|
|||
margin_top = 4.0
|
||||
margin_right = 25.0
|
||||
margin_bottom = 16.0
|
||||
|
||||
[node name="PauseMenu" parent="." instance=ExtResource( 2 )]
|
||||
visible = false
|
||||
|
|
|
@ -21,7 +21,7 @@ _global_script_class_icons={
|
|||
[application]
|
||||
|
||||
config/name="Metroidvania"
|
||||
run/main_scene="res://Scenes/UI/StarMenu.tscn"
|
||||
run/main_scene="res://Scenes/World/World.tscn"
|
||||
config/icon="res://icon.png"
|
||||
|
||||
[autoload]
|
||||
|
@ -98,6 +98,12 @@ fire={
|
|||
"events": [ Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"button_mask":0,"position":Vector2( 0, 0 ),"global_position":Vector2( 0, 0 ),"factor":1.0,"button_index":1,"pressed":false,"doubleclick":false,"script":null)
|
||||
]
|
||||
}
|
||||
pause={
|
||||
"deadzone": 0.5,
|
||||
"events": [ Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":69,"unicode":0,"echo":false,"script":null)
|
||||
, Object(InputEventKey,"resource_local_to_scene":false,"resource_name":"","device":0,"alt":false,"shift":false,"control":false,"meta":false,"command":false,"pressed":false,"scancode":16777217,"unicode":0,"echo":false,"script":null)
|
||||
]
|
||||
}
|
||||
|
||||
[layer_names]
|
||||
|
||||
|
|
Loading…
Reference in New Issue