should've called this game Boogit add objects/enemy/! Haunted Housegit add objects/enemy/!
This commit is contained in:
parent
9864a042dd
commit
892c3c80f9
2 changed files with 68 additions and 0 deletions
33
objects/enemy/ghost_scholar.gd
Normal file
33
objects/enemy/ghost_scholar.gd
Normal file
|
@ -0,0 +1,33 @@
|
|||
tool
|
||||
extends "res://objects/enemy/enemy.gd"
|
||||
|
||||
## the radius the ghost orbits around
|
||||
export var radius: float = 0.0
|
||||
## initital rotation offset in full circles
|
||||
export var initial_angle: float = 0.0
|
||||
## speed the ghost revolves in cycles/second
|
||||
export var speed: float = 0.0
|
||||
|
||||
onready var pivot: Node2D = $Pivot
|
||||
onready var remote_transform: RemoteTransform2D = $Pivot/RemoteTransform
|
||||
|
||||
func _ready() -> void:
|
||||
pivot.rotation = TAU * initial_angle
|
||||
|
||||
func _physics_process(delta: float) -> void:
|
||||
if Engine.editor_hint:
|
||||
return
|
||||
# update radius
|
||||
remote_transform.position.x = radius * 8.0
|
||||
# process rotation
|
||||
pivot.rotation += speed * delta * 0.785398 # TAU / l8.0
|
||||
|
||||
func _process(delta: float) -> void:
|
||||
if Engine.editor_hint and Engine.get_frames_drawn() % 10 == 0:
|
||||
get_node("Pivot").rotation = TAU * initial_angle
|
||||
get_node("Pivot/RemoteTransform").position.x = radius * 8.0
|
||||
update()
|
||||
|
||||
func _draw() -> void:
|
||||
if Engine.editor_hint:
|
||||
draw_arc(Vector2(4.0, 4.0), radius * 8.0, 0.0, TAU, 13, Color(0.0, 1.0, 1.0, 0.1), 1.5)
|
35
objects/enemy/ghost_scholar.tscn
Normal file
35
objects/enemy/ghost_scholar.tscn
Normal file
|
@ -0,0 +1,35 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://objects/enemy/ghost_scholar.gd" type="Script" id=1]
|
||||
[ext_resource path="res://graphics/enemy/ghost.png" type="Texture" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 3, 3.5 )
|
||||
|
||||
[node name="Ghost" type="Node2D"]
|
||||
script = ExtResource( 1 )
|
||||
radius = 4.0
|
||||
speed = 2.0
|
||||
|
||||
[node name="Hitbox" type="Area2D" parent="." groups=["enemy_hitbox"]]
|
||||
position = Vector2( 36, 4 )
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="Hitbox"]
|
||||
unique_name_in_owner = true
|
||||
texture = ExtResource( 2 )
|
||||
hframes = 2
|
||||
|
||||
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox"]
|
||||
position = Vector2( 0, -0.5 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Pivot" type="Node2D" parent="."]
|
||||
position = Vector2( 4, 4 )
|
||||
|
||||
[node name="RemoteTransform" type="RemoteTransform2D" parent="Pivot"]
|
||||
position = Vector2( 32, 0 )
|
||||
remote_path = NodePath("../../Hitbox")
|
||||
update_rotation = false
|
||||
update_scale = false
|
||||
|
||||
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
|
Loading…
Add table
Add a link
Reference in a new issue