halfway through overview of gem catcher
This commit is contained in:
parent
56f0748b57
commit
1385557298
1 changed files with 76 additions and 0 deletions
76
_subsections/sec03/lesson-30.org
Normal file
76
_subsections/sec03/lesson-30.org
Normal file
|
|
@ -0,0 +1,76 @@
|
||||||
|
#+title: Section 03 - Lesson 30 | Section Review
|
||||||
|
#+HTML_HEAD: <link rel="stylesheet" type="text/css" href="../../_share/media/css/godot.css" />
|
||||||
|
|
||||||
|
* Links
|
||||||
|
- [[../../toc.org][TOC - Godot Notes]]
|
||||||
|
- [[https://www.udemy.com/course/jumpstart-to-2d-game-development-godot-4-for-beginners/learn/lecture/45070537#overview][S03:L42.30 - Section Review]]
|
||||||
|
|
||||||
|
* Notes
|
||||||
|
|
||||||
|
** paddle scene
|
||||||
|
*** node composition
|
||||||
|
- root: Area2D
|
||||||
|
- Sprite2D
|
||||||
|
- CollisionShape2D
|
||||||
|
|
||||||
|
*** script view: paddle.gd
|
||||||
|
- extends Area2D
|
||||||
|
|
||||||
|
**** use *@export* to create speed variable
|
||||||
|
- can be modified in Inspector
|
||||||
|
- give default value
|
||||||
|
|
||||||
|
**** override _process function
|
||||||
|
- check if =Input.is_action_pressed=
|
||||||
|
- is 'left'
|
||||||
|
- is 'right'
|
||||||
|
|
||||||
|
- move paddle
|
||||||
|
- get the Node2D.position property
|
||||||
|
- multiply speed by delta and add or subtract it from position.x
|
||||||
|
- delta is number of seconds that elapsed since the previous frame
|
||||||
|
|
||||||
|
** gem scene
|
||||||
|
*** node composition
|
||||||
|
- root: Area2D
|
||||||
|
- Sprite2D
|
||||||
|
- CollisionShape2D
|
||||||
|
|
||||||
|
*** script view: gem.gd
|
||||||
|
- extends Area2D
|
||||||
|
|
||||||
|
**** set class name
|
||||||
|
- =class_name Gem=
|
||||||
|
- this allows us to instantiate Gem objects in scripts
|
||||||
|
|
||||||
|
**** set a signal property
|
||||||
|
- =signal on_gem_off_screen=
|
||||||
|
- allows us to attach listeners who will be notified when we emit a signal
|
||||||
|
|
||||||
|
**** set export property
|
||||||
|
- =@export var speed=
|
||||||
|
- lets us set the speed in the Inspector
|
||||||
|
|
||||||
|
*** modify _process
|
||||||
|
**** determine if the gem has gone out of bounds
|
||||||
|
- this is going to be the edge of the viewport
|
||||||
|
- check position property against the viewport rect property
|
||||||
|
#+begin_src gdscript
|
||||||
|
if position.y > get_viewport_rect().size.y
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
**** if gem went out of bounds
|
||||||
|
***** emit signal
|
||||||
|
#+begin_src gdscript
|
||||||
|
on_gem_off_screen.emit()
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
***** stop the gem and remove it from the node tree
|
||||||
|
- stop going through the process function
|
||||||
|
- delete node at the end of the current frame
|
||||||
|
#+begin_src gdscript
|
||||||
|
set_process(false)
|
||||||
|
queue_free()
|
||||||
|
#+end_src
|
||||||
|
|
||||||
|
** Game scene
|
||||||
Loading…
Add table
Reference in a new issue