From 38c24431857e31a4606631aed41adb56d9038f11 Mon Sep 17 00:00:00 2001 From: ronny abraham Date: Mon, 10 Mar 2025 03:33:49 +0200 Subject: [PATCH] added flying --- _subsections/sec04/lesson-08.org | 48 ++++++++++++++++++++++++++++++++ _subsections/sec04/lesson-09.org | 9 ++++++ toc.org | 1 + 3 files changed, 58 insertions(+) create mode 100644 _subsections/sec04/lesson-09.org diff --git a/_subsections/sec04/lesson-08.org b/_subsections/sec04/lesson-08.org index 993171a..45990e7 100644 --- a/_subsections/sec04/lesson-08.org +++ b/_subsections/sec04/lesson-08.org @@ -7,3 +7,51 @@ - [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45069817#overview][S04:L53.08 - video]] * Notes + +** when a character body2d hits the floor + - velocity is set to 0 + - is_on_floor is set to true + +** create a floor +to create a floor we are going to use a StaticBody2D + + +1. make this as a seperate scene +2. add root node StaticBody2D +3. add CollisionShape2D as child +4. in collisionshape2D inspector go to shape and pick rectangle shape +5. stretch the rectangle across the scene +6. save scene + +** add barrier to game +1. add the barrier scene to the game scene +2. put it at top of screen or whereever you like +3. Ctrl+D to create another one and move it to the floor + +** when plane hits floor stop it from moving +- in physics process func check if 'in on floor' +- if so than invoke die + +#+BEGIN_SRC gdscript +# Called every frame. 'delta' is the elapsed time since the previous frame. +func _physics_process(delta: float) -> void: + + # ... + + if is_on_floor() == true: + die() + +func die() -> void: + set_physics_process(false) +#+end_src + +** end properller animation +- switch to plane scene +- Cmd + drag AnimationSprite to script +- in die set the variable to the sprite to 'stop()' + +#+BEGIN_SRC gdscript +func die() -> void: + set_physics_process(false) + animated_spirte_2d.stop() +#+end_src diff --git a/_subsections/sec04/lesson-09.org b/_subsections/sec04/lesson-09.org new file mode 100644 index 0000000..c908b60 --- /dev/null +++ b/_subsections/sec04/lesson-09.org @@ -0,0 +1,9 @@ +#+title:Flyin#+title: Section 14 - Lesson 09 | Animation Player +#+HTML_HEAD: +#+OPTIONS: H:6 + +* Links +- [[../../toc.org][TOC - Godot Notes]] +- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45069817#overview][S14:L09 - video]] + +* Notes diff --git a/toc.org b/toc.org index 876e46f..5158a6b 100644 --- a/toc.org +++ b/toc.org @@ -32,3 +32,4 @@ - [[./_subsections/sec04/lesson-05.org][Lesson 05, 06 | Collision Shapes and Resources, Falling]] - [[./_subsections/sec04/lesson-07.org][Lesson 07 | Flying]] - [[./_subsections/sec04/lesson-08.org][Lesson 08 | Collisions: Hitting the Floor]] +- [[./_subsections/sec04/lesson-09.org][Lesson 09 | Animation Player]]