-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #8 from KartikWatts/2d-survivors-course
improving game features
- Loading branch information
Showing
11 changed files
with
142 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
extends Node | ||
|
||
const SPAWN_RADIUS = 350 | ||
|
||
@export var basic_enemy_scene: PackedScene | ||
|
||
# Called when the node enters the scene tree for the first time. | ||
func _ready(): | ||
$Timer.timeout.connect(on_timer_timeout) | ||
|
||
func on_timer_timeout(): | ||
var player = get_tree().get_first_node_in_group("player") as Node2D | ||
if player == null: | ||
return | ||
|
||
var random_direction = Vector2.RIGHT.rotated(randf_range(0, TAU)) | ||
var spawn_position = player.global_position + (random_direction * SPAWN_RADIUS) | ||
|
||
var enemy = basic_enemy_scene.instantiate() as Node2D | ||
get_parent().add_child(enemy) | ||
enemy.global_position = spawn_position |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
[gd_scene load_steps=3 format=3 uid="uid://dyy6q3goih542"] | ||
|
||
[ext_resource type="Script" path="res://scenes/manager/enemy_manager.gd" id="1_1cnff"] | ||
[ext_resource type="PackedScene" uid="uid://dlsoablcbbnbn" path="res://scenes/basic_enemy/basic_enemy.tscn" id="2_rsw1k"] | ||
|
||
[node name="EnemyManager" type="Node"] | ||
script = ExtResource("1_1cnff") | ||
basic_enemy_scene = ExtResource("2_rsw1k") | ||
|
||
[node name="Timer" type="Timer" parent="."] | ||
autostart = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters