Added Spring scene
This commit is contained in:
parent
a72f97fd13
commit
e49e8b57f2
9 changed files with 141 additions and 17 deletions
BIN
assets/Items/Spring.png
Normal file
BIN
assets/Items/Spring.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 469 B |
34
assets/Items/Spring.png.import
Normal file
34
assets/Items/Spring.png.import
Normal file
|
@ -0,0 +1,34 @@
|
||||||
|
[remap]
|
||||||
|
|
||||||
|
importer="texture"
|
||||||
|
type="StreamTexture"
|
||||||
|
path="res://.import/Spring.png-a4e8614daee62218cb58dc3175bf6be3.stex"
|
||||||
|
metadata={
|
||||||
|
"vram_texture": false
|
||||||
|
}
|
||||||
|
|
||||||
|
[deps]
|
||||||
|
|
||||||
|
source_file="res://assets/Items/Spring.png"
|
||||||
|
dest_files=[ "res://.import/Spring.png-a4e8614daee62218cb58dc3175bf6be3.stex" ]
|
||||||
|
|
||||||
|
[params]
|
||||||
|
|
||||||
|
compress/mode=0
|
||||||
|
compress/lossy_quality=0.7
|
||||||
|
compress/hdr_mode=0
|
||||||
|
compress/bptc_ldr=0
|
||||||
|
compress/normal_map=0
|
||||||
|
flags/repeat=0
|
||||||
|
flags/filter=false
|
||||||
|
flags/mipmaps=false
|
||||||
|
flags/anisotropic=false
|
||||||
|
flags/srgb=2
|
||||||
|
process/fix_alpha_border=true
|
||||||
|
process/premult_alpha=false
|
||||||
|
process/HDR_as_SRGB=false
|
||||||
|
process/invert_color=false
|
||||||
|
stream=false
|
||||||
|
size_limit=0
|
||||||
|
detect_3d=false
|
||||||
|
svg/scale=1.0
|
|
@ -28,6 +28,7 @@ var _alive := true
|
||||||
var _can_dash := true
|
var _can_dash := true
|
||||||
var _is_jump_canceled := false
|
var _is_jump_canceled := false
|
||||||
var _direction := Vector2.ZERO
|
var _direction := Vector2.ZERO
|
||||||
|
var _boost_velocity :Vector2 = Vector2.ZERO
|
||||||
|
|
||||||
var _falling_start_position := .0
|
var _falling_start_position := .0
|
||||||
|
|
||||||
|
@ -62,14 +63,18 @@ func _physics_process(delta: float) -> void:
|
||||||
_update_state()
|
_update_state()
|
||||||
_input_check()
|
_input_check()
|
||||||
_velocity = calculate_move_velocity(_direction,_is_jump_canceled, delta)
|
_velocity = calculate_move_velocity(_direction,_is_jump_canceled, delta)
|
||||||
|
_velocity = _boost_velocity if _boost_velocity != Vector2.ZERO else _velocity
|
||||||
_velocity = move_and_slide(_velocity, Vector2.UP)
|
_velocity = move_and_slide(_velocity, Vector2.UP)
|
||||||
|
_boost_velocity = Vector2.ZERO
|
||||||
_check_collisions()
|
_check_collisions()
|
||||||
update_sprite(_direction)
|
update_sprite(_direction)
|
||||||
|
|
||||||
|
|
||||||
func _input_check() -> void:
|
func _input_check() -> void:
|
||||||
if self._alive and (GameState.get_state() == GameState.States.GAME or GameState.get_state() == GameState.States.NEW_GAME):
|
if self._alive and (GameState.get_state() == GameState.States.GAME or GameState.get_state() == GameState.States.NEW_GAME):
|
||||||
_is_jump_canceled = Input.is_action_just_released("jump") and !_is_wall_jumping and _velocity.y < 0.0;
|
_is_jump_canceled = Input.is_action_just_released("jump") and !_is_wall_jumping and _velocity.y < 0.0 and _velocity.y >= -jump_power;
|
||||||
|
if _boost_velocity != Vector2.ZERO:
|
||||||
|
_is_jump_canceled = false
|
||||||
_get_direction()
|
_get_direction()
|
||||||
_check_dash()
|
_check_dash()
|
||||||
if Input.is_action_just_pressed("attack") and abilities.attack:
|
if Input.is_action_just_pressed("attack") and abilities.attack:
|
||||||
|
@ -109,6 +114,7 @@ func _update_state(new_state:int = -1):
|
||||||
if is_on_floor() or not is_on_wall():
|
if is_on_floor() or not is_on_wall():
|
||||||
new_state = States.IDLE
|
new_state = States.IDLE
|
||||||
else: new_state = States.IDLE
|
else: new_state = States.IDLE
|
||||||
|
|
||||||
_transition_state(_state, new_state, auto_update)
|
_transition_state(_state, new_state, auto_update)
|
||||||
|
|
||||||
func _transition_state(old_state, new_state, auto_update):
|
func _transition_state(old_state, new_state, auto_update):
|
||||||
|
@ -313,3 +319,6 @@ func face_player(right:bool = true):
|
||||||
1 if right else -1,
|
1 if right else -1,
|
||||||
1
|
1
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func boost(velocity:Vector2):
|
||||||
|
_boost_velocity = velocity
|
||||||
|
|
|
@ -69,7 +69,7 @@ func start_scene(camera:CameraGame = null):
|
||||||
$Tween.interpolate_property(_camera, "position", _camera.position, _camera.get_parent().position, 2, Tween.TRANS_BOUNCE, Tween.EASE_OUT)
|
$Tween.interpolate_property(_camera, "position", _camera.position, _camera.get_parent().position, 2, Tween.TRANS_BOUNCE, Tween.EASE_OUT)
|
||||||
$Tween.start()
|
$Tween.start()
|
||||||
yield($Tween, "tween_completed")
|
yield($Tween, "tween_completed")
|
||||||
camera.get_parent()._velocity.y = -100
|
camera.get_parent().boost(Vector2(0,-100))
|
||||||
# Dialog 2
|
# Dialog 2
|
||||||
$AnimationPlayer.play("old_dude_slide_in")
|
$AnimationPlayer.play("old_dude_slide_in")
|
||||||
yield($AnimationPlayer, "animation_finished")
|
yield($AnimationPlayer, "animation_finished")
|
||||||
|
@ -89,10 +89,10 @@ func start_scene(camera:CameraGame = null):
|
||||||
_on_scene_exited()
|
_on_scene_exited()
|
||||||
pass
|
pass
|
||||||
|
|
||||||
func _input(event: InputEvent) -> void:
|
# func _input(event: InputEvent) -> void:
|
||||||
if not _started: return
|
# if not _started: return
|
||||||
if Input.is_action_just_pressed("jump"):
|
# if Input.is_action_just_pressed("jump"):
|
||||||
if allow_skip: _on_scene_exited()
|
# if allow_skip: _on_scene_exited()
|
||||||
|
|
||||||
|
|
||||||
func _on_scene_exited():
|
func _on_scene_exited():
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
[gd_scene load_steps=25 format=2]
|
[gd_scene load_steps=26 format=2]
|
||||||
|
|
||||||
[ext_resource path="res://src/GameWorld/Levels/PreGame.gd" type="Script" id=1]
|
[ext_resource path="res://src/GameWorld/Levels/PreGame.gd" type="Script" id=1]
|
||||||
[ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=2]
|
[ext_resource path="res://assets/Tiles/background_0.png" type="Texture" id=2]
|
||||||
|
@ -16,6 +16,7 @@
|
||||||
[ext_resource path="res://src/GameWorld/AmbiantLighting.tscn" type="PackedScene" id=14]
|
[ext_resource path="res://src/GameWorld/AmbiantLighting.tscn" type="PackedScene" id=14]
|
||||||
[ext_resource path="res://src/Scripts/WarpZone.tscn" type="PackedScene" id=15]
|
[ext_resource path="res://src/Scripts/WarpZone.tscn" type="PackedScene" id=15]
|
||||||
[ext_resource path="res://src/Hazards/SpikeTrap.tscn" type="PackedScene" id=16]
|
[ext_resource path="res://src/Hazards/SpikeTrap.tscn" type="PackedScene" id=16]
|
||||||
|
[ext_resource path="res://src/Items/Spring.tscn" type="PackedScene" id=17]
|
||||||
|
|
||||||
[sub_resource type="TileSet" id=1]
|
[sub_resource type="TileSet" id=1]
|
||||||
0/name = "tileset.png 0"
|
0/name = "tileset.png 0"
|
||||||
|
@ -269,4 +270,7 @@ to_level_coord = Vector2( 0, 1 )
|
||||||
|
|
||||||
[node name="SpikeTrap" parent="." instance=ExtResource( 16 )]
|
[node name="SpikeTrap" parent="." instance=ExtResource( 16 )]
|
||||||
position = Vector2( 352, 208 )
|
position = Vector2( 352, 208 )
|
||||||
|
|
||||||
|
[node name="Spring" parent="." instance=ExtResource( 17 )]
|
||||||
|
position = Vector2( 98, 240 )
|
||||||
[connection signal="body_entered" from="CutsceneAreas/OldDudeIntroArea" to="." method="_on_OldDudeIntroArea_body_entered"]
|
[connection signal="body_entered" from="CutsceneAreas/OldDudeIntroArea" to="." method="_on_OldDudeIntroArea_body_entered"]
|
||||||
|
|
|
@ -1,7 +1,11 @@
|
||||||
|
tool
|
||||||
extends Node2D
|
extends Node2D
|
||||||
|
|
||||||
var triggerd = false
|
var triggerd = false
|
||||||
|
|
||||||
|
export(int, -360, 360) var direction = 1 setget set_direction
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
func _on_DamageArea_body_entered(body: Node) -> void:
|
func _on_DamageArea_body_entered(body: Node) -> void:
|
||||||
if body.name == "Player":
|
if body.name == "Player":
|
||||||
body.die()
|
body.die()
|
||||||
|
@ -14,3 +18,5 @@ func _on_TriggerArea_body_entered(body: Node) -> void:
|
||||||
yield(get_tree().create_timer(.3), "timeout")
|
yield(get_tree().create_timer(.3), "timeout")
|
||||||
$AnimationPlayer.play_backwards("emit")
|
$AnimationPlayer.play_backwards("emit")
|
||||||
triggerd = false
|
triggerd = false
|
||||||
|
func set_direction(new_direction):
|
||||||
|
self.rotation_degrees = new_direction
|
||||||
|
|
|
@ -6,10 +6,10 @@
|
||||||
[sub_resource type="RectangleShape2D" id=1]
|
[sub_resource type="RectangleShape2D" id=1]
|
||||||
extents = Vector2( 5, 8 )
|
extents = Vector2( 5, 8 )
|
||||||
|
|
||||||
[sub_resource type="RectangleShape2D" id=3]
|
[sub_resource type="RectangleShape2D" id=2]
|
||||||
extents = Vector2( 10, 8 )
|
extents = Vector2( 10, 8 )
|
||||||
|
|
||||||
[sub_resource type="Animation" id=4]
|
[sub_resource type="Animation" id=3]
|
||||||
resource_name = "emit"
|
resource_name = "emit"
|
||||||
length = 0.5
|
length = 0.5
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
|
@ -37,8 +37,7 @@ tracks/1/keys = {
|
||||||
"values": [ Vector2( -11, -8 ), Vector2( -9, -8 ), Vector2( -3, -8 ), Vector2( 5, -8 ), Vector2( 5, -8 ) ]
|
"values": [ Vector2( -11, -8 ), Vector2( -9, -8 ), Vector2( -3, -8 ), Vector2( 5, -8 ), Vector2( 5, -8 ) ]
|
||||||
}
|
}
|
||||||
|
|
||||||
[sub_resource type="Animation" id=2]
|
[sub_resource type="Animation" id=4]
|
||||||
resource_name = "idle"
|
|
||||||
length = 0.1
|
length = 0.1
|
||||||
tracks/0/type = "value"
|
tracks/0/type = "value"
|
||||||
tracks/0/path = NodePath("Sprite:frame")
|
tracks/0/path = NodePath("Sprite:frame")
|
||||||
|
@ -87,11 +86,11 @@ collision_layer = 0
|
||||||
|
|
||||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="TriggerArea"]
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="TriggerArea"]
|
||||||
position = Vector2( 4, -8 )
|
position = Vector2( 4, -8 )
|
||||||
shape = SubResource( 3 )
|
shape = SubResource( 2 )
|
||||||
|
|
||||||
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
playback_speed = 2.5
|
playback_speed = 2.5
|
||||||
anims/emit = SubResource( 4 )
|
anims/emit = SubResource( 3 )
|
||||||
anims/idle = SubResource( 2 )
|
anims/idle = SubResource( 4 )
|
||||||
[connection signal="body_entered" from="DamageArea" to="." method="_on_DamageArea_body_entered"]
|
[connection signal="body_entered" from="DamageArea" to="." method="_on_DamageArea_body_entered"]
|
||||||
[connection signal="body_entered" from="TriggerArea" to="." method="_on_TriggerArea_body_entered"]
|
[connection signal="body_entered" from="TriggerArea" to="." method="_on_TriggerArea_body_entered"]
|
||||||
|
|
9
src/Items/Spring.gd
Normal file
9
src/Items/Spring.gd
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
extends Node2D
|
||||||
|
|
||||||
|
export var thrust:float = 250
|
||||||
|
|
||||||
|
|
||||||
|
func _on_Area2D_body_entered(body: Node) -> void:
|
||||||
|
if body.name == "Player":
|
||||||
|
body.boost(Vector2(body._velocity.x, -thrust))
|
||||||
|
$AnimationPlayer.play("activated")
|
63
src/Items/Spring.tscn
Normal file
63
src/Items/Spring.tscn
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
[gd_scene load_steps=6 format=2]
|
||||||
|
|
||||||
|
[ext_resource path="res://assets/Items/Spring.png" type="Texture" id=1]
|
||||||
|
[ext_resource path="res://src/Items/Spring.gd" type="Script" id=2]
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=1]
|
||||||
|
resource_name = "activated"
|
||||||
|
length = 0.6
|
||||||
|
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, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 ),
|
||||||
|
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1 ),
|
||||||
|
"update": 1,
|
||||||
|
"values": [ 0, 1, 2, 3, 4, 5, 6 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="Animation" id=2]
|
||||||
|
resource_name = "idle"
|
||||||
|
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": [ 0 ]
|
||||||
|
}
|
||||||
|
|
||||||
|
[sub_resource type="RectangleShape2D" id=3]
|
||||||
|
extents = Vector2( 7, 3 )
|
||||||
|
|
||||||
|
[node name="Spring" type="Node2D"]
|
||||||
|
script = ExtResource( 2 )
|
||||||
|
|
||||||
|
[node name="Sprite" type="Sprite" parent="."]
|
||||||
|
position = Vector2( 0, -8 )
|
||||||
|
texture = ExtResource( 1 )
|
||||||
|
hframes = 7
|
||||||
|
frame = 6
|
||||||
|
|
||||||
|
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
|
||||||
|
autoplay = "idle"
|
||||||
|
playback_speed = 2.0
|
||||||
|
anims/activated = SubResource( 1 )
|
||||||
|
anims/idle = SubResource( 2 )
|
||||||
|
|
||||||
|
[node name="Area2D" type="Area2D" parent="."]
|
||||||
|
collision_layer = 0
|
||||||
|
|
||||||
|
[node name="CollisionShape2D" type="CollisionShape2D" parent="Area2D"]
|
||||||
|
position = Vector2( 0, -3 )
|
||||||
|
shape = SubResource( 3 )
|
||||||
|
one_way_collision = true
|
||||||
|
[connection signal="body_entered" from="Area2D" to="." method="_on_Area2D_body_entered"]
|
Loading…
Reference in a new issue