A rising level now kills the player

main
Ervan Lefevre 2 years ago
parent 8152546bf2
commit 50fb9e9496
  1. BIN
      assets/placeholders/map.png
  2. 34
      assets/placeholders/map.png.import
  3. 16
      nodes/player/player.gd
  4. 4
      nodes/player/player.tscn
  5. 31
      scenes/poc.tscn
  6. 13
      scripts/gameplay/rising_level.gd
  7. 1
      scripts/ia/fsm.gd

Binary file not shown.

After

Width:  |  Height:  |  Size: 491 KiB

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="CompressedTexture2D"
uid="uid://ccqiabs4p3ryl"
path="res://.godot/imported/map.png-2da3fc7424b1263a875c0fcdadfc0bc5.ctex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://assets/placeholders/map.png"
dest_files=["res://.godot/imported/map.png-2da3fc7424b1263a875c0fcdadfc0bc5.ctex"]
[params]
compress/mode=0
compress/high_quality=false
compress/lossy_quality=0.7
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/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,8 +1,9 @@
extends CharacterBody2D
class_name Player
const SPEED = 300.0
const JUMP_VELOCITY = -400.0
const JUMP_VELOCITY = -300.0
const STATES= [
"spawn",
@ -17,6 +18,7 @@ var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _ready():
$fsm.set_states(STATES)
add_to_group("player")
func _enter_spawn():
$fsm.set_next_state("idle")
@ -58,8 +60,16 @@ func jump_state(_delta):
$fsm.set_next_state("idle")
func after_state(delta):
if $fsm.current_state in ["idle", "walk"]:
move_and_slide()
move_and_slide()
if not is_on_floor():
velocity.y += gravity * delta
func die():
$fsm.set_next_state("die")
func on_enter_die_state():
velocity = Vector2(0, -500)
$shape.disabled = true
# $AnimationPlayer.play("die")

@ -6,7 +6,7 @@
[sub_resource type="CapsuleShape2D" id="CapsuleShape2D_w17ly"]
radius = 7.9984
height = 31.9936
height = 24.0
[node name="player" type="CharacterBody2D"]
script = ExtResource("1_exx2i")
@ -19,7 +19,7 @@ root = NodePath("..")
texture = ExtResource("1_s33dc")
[node name="shape" type="CollisionShape2D" parent="."]
rotation = 1.55081
rotation = 1.5708
shape = SubResource("CapsuleShape2D_w17ly")
metadata/_edit_group_ = true

File diff suppressed because one or more lines are too long

@ -0,0 +1,13 @@
extends Area2D
class_name RisingLevel
@export var RISING_SPEED = 30
func _physics_process(delta):
$shape.position.y -= RISING_SPEED * delta
self.position = self.position
body_entered.connect(_body_entered)
func _body_entered(body):
if body.is_in_group("player"):
body.die()

@ -36,6 +36,7 @@ func _transition():
previous_state = current_state
current_state = next_state
next_state = null
print(self.name + " transitioning to " + current_state)
var on_exit_state_method = "on_exit_" + current_state + "_state"
if on_exit_state_method in root:

Loading…
Cancel
Save