This commit is contained in:
1 parent
c40cbc4574
commit
231629d91e
28 files changed
+434
-91
No files matched your search
@@ -0,0 +1,49 @@
|
||||
class_name Block_Simple
|
||||
|
||||
extends RigidBody2D
|
||||
|
||||
# Last known sprite. In edge cases involving states.
|
||||
|
||||
# Block type refers to our specific block script.
|
||||
# They should always extend eventually from block_simple.
|
||||
@export var block_type:Script
|
||||
|
||||
# Set the animation (sprite sheet) to the specfied block types.
|
||||
func SetSpriteSheet(animation):
|
||||
$Sprite.animation = animation
|
||||
|
||||
# If this is false (default) then the block is horizontally facing.
|
||||
@export var is_vertical:bool
|
||||
|
||||
# Tags the block has. These dictate interactions.
|
||||
# These must be strings.
|
||||
@export var tags:Array = [str]
|
||||
|
||||
# Rotate the block in a way that we can control.
|
||||
# Default to 90 because that's a common use case.
|
||||
func rotate_block(degrees:int = 90):
|
||||
rotate(degrees)
|
||||
|
||||
# This runs BEFORE the instance is loaded.
|
||||
# There's a lot you can't do here, as it doesn't exist yet.
|
||||
func _init():
|
||||
pass
|
||||
#SetSpriteSheet(str(block_type))
|
||||
#set_script(block_type)
|
||||
|
||||
# This runs AFTER the instance is loaded.
|
||||
# This runs BEFORE the instance is added to the scene tree.
|
||||
func _ready() -> void:
|
||||
if is_vertical:
|
||||
rotate_block(90)
|
||||
set_script(block_type)
|
||||
|
||||
# This runs every frame. Expensive.
|
||||
func _process(delta: float) -> void:
|
||||
var _last_known_delta = delta
|
||||
|
||||
func on_player_near(body: Node2D) -> void:
|
||||
print("Player is touching block with tags: " + str(tags))
|
||||
|
||||
func on_player_leave(body: Node2D) -> void:
|
||||
print("Player is leaving block with tags: " + str(tags))
|
||||
Reference in new issue
Block a user