diff options
| author | Jan Tuomi <jan@jantuomi.fi> | 2025-11-14 10:45:04 +0200 |
|---|---|---|
| committer | Jan Tuomi <jan@jantuomi.fi> | 2025-11-14 10:45:04 +0200 |
| commit | cb5ddada498a44e8569bdf53359ee06ee11e3d44 (patch) | |
| tree | fc52d60d612067b2fa43f9f9b800f7fc44d531ad | |
| parent | bce80184961866e0efcc227becf15fe66bd99428 (diff) | |
Add coyote time
| -rw-r--r-- | docs/index.html | 2 | ||||
| -rw-r--r-- | docs/index.pck | bin | 1933540 -> 1933940 bytes | |||
| -rw-r--r-- | docs/index.service.worker.js | 2 | ||||
| -rw-r--r-- | player.gd | 12 | ||||
| -rw-r--r-- | root.tscn | 1 |
5 files changed, 14 insertions, 3 deletions
diff --git a/docs/index.html b/docs/index.html index 0b7ea7c..936d42e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -112,7 +112,7 @@ body { <script src="index.js"></script> <script> -const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":false,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":1933540,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; +const GODOT_CONFIG = {"args":[],"canvasResizePolicy":2,"emscriptenPoolSize":8,"ensureCrossOriginIsolationHeaders":false,"executable":"index","experimentalVK":false,"fileSizes":{"index.pck":1933940,"index.wasm":38034280},"focusCanvas":true,"gdextensionLibs":[],"godotPoolSize":4,"serviceWorker":"index.service.worker.js"}; const GODOT_THREADS_ENABLED = false; const engine = new Engine(GODOT_CONFIG); diff --git a/docs/index.pck b/docs/index.pck Binary files differindex 177f54d..aba560f 100644 --- a/docs/index.pck +++ b/docs/index.pck diff --git a/docs/index.service.worker.js b/docs/index.service.worker.js index b5be385..3c96be4 100644 --- a/docs/index.service.worker.js +++ b/docs/index.service.worker.js @@ -4,7 +4,7 @@ // Incrementing CACHE_VERSION will kick off the install event and force // previously cached resources to be updated from the network. /** @type {string} */ -const CACHE_VERSION = '1763108177|14024774539'; +const CACHE_VERSION = '1763109853|15701222846'; /** @type {string} */ const CACHE_PREFIX = 'MobileMetroidvan-sw-cache-'; const CACHE_NAME = CACHE_PREFIX + CACHE_VERSION; @@ -2,10 +2,15 @@ extends CharacterBody2D @export var speed: float @export var jump_strength: float +@export var coyote_max: int var gravity = ProjectSettings.get_setting("physics/2d/default_gravity") var prev_dir: float = 0.0 +# coyote = 0 indicates on floor +# coyote > 0 indicates frames since on floor +var coyote: int = 0 + # Called when the node enters the scene tree for the first time. func _ready() -> void: pass # Replace with function body. @@ -26,8 +31,13 @@ func _process(_delta: float) -> void: func _physics_process(delta: float): velocity.y += gravity * delta + if is_on_floor(): + coyote = 0 + else: + coyote += 1 - if Input.is_action_just_pressed("jump") and is_on_floor(): + var can_jump = coyote < coyote_max + if Input.is_action_just_pressed("jump") and can_jump: velocity.y = -jump_strength var direction: float @@ -448,6 +448,7 @@ position = Vector2(90, 64) collision_layer = 2 speed = 70.0 jump_strength = 320.0 +coyote_max = 10 [node name="Camera2D" type="Camera2D" parent="Player"] position = Vector2(0, -15) |
