Skip to content

Commit

Permalink
FIRST BUILD
Browse files Browse the repository at this point in the history
  • Loading branch information
amenrio committed Dec 15, 2023
1 parent 563e898 commit c86338e
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 17 deletions.
2 changes: 1 addition & 1 deletion 02_scenes/01_characters/enemy01.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ radius = 16.0
[sub_resource type="CircleShape2D" id="CircleShape2D_ndhcc"]
radius = 319.039

[node name="enemy" type="CharacterBody2D"]
[node name="enemy" type="CharacterBody2D" groups=["enemy"]]
collision_layer = 2
collision_mask = 10
script = ExtResource("1_kn3i3")
Expand Down
2 changes: 1 addition & 1 deletion 02_scenes/01_characters/enemy02.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ radius = 96.2549
[sub_resource type="CircleShape2D" id="CircleShape2D_oj4wm"]
radius = 244.008

[node name="enemyExplode" type="CharacterBody2D"]
[node name="enemyExplode" type="CharacterBody2D" groups=["enemy"]]
collision_layer = 2
collision_mask = 10
motion_mode = 1
Expand Down
38 changes: 28 additions & 10 deletions 02_scenes/02_objects/spawner.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,40 @@ extends Node2D
@export var enemies: PackedScene
@export var enemy_names: Array[String]
@export var spawn_timer: float = 4.0
@onready var timer_node = $timer
@onready var current_level = get_tree().current_scene
@onready var player = get_parent().get_node("player")
@onready var spawn_min = $area.global_position
@onready var spawn_max = $area.global_position + $area.size

var spawn_count: int = 0
var limit: int = 5
# Called when the node enters the scene tree for the first time.
func _ready():
pass
timer_node.wait_time = spawn_timer
print(timer_node.wait_time)

func _on_spawn_timer_timeout():
var new_enemy_name = enemy_scene_dict.keys()[randi_range(0,2)]
var new_enemy_scene = load(enemy_scene_dict[new_enemy_name])
var new_enemy = new_enemy_scene.instantiate()
# var new_enemy = enemies.instantiate()
new_enemy._name = new_enemy_name
var spawn_position = Vector2(randf_range(spawn_min.x,spawn_max.x),randf_range(spawn_min.y,spawn_max.y))
new_enemy.position = spawn_position
current_level.add_child(new_enemy)
new_enemy.get_node('HealthComponent').connect('death',current_level.pickup_system) # Replace with function body.
if spawn_count < limit:
var new_enemy_name:String
var spawn_weight = randi_range(0,100)
if spawn_weight < 75:
new_enemy_name = enemy_names[0]
elif spawn_weight < 90:
new_enemy_name = enemy_names[1]
elif spawn_weight >= 90:
new_enemy_name = enemy_names[2]
var new_enemy_scene = load(enemy_scene_dict[new_enemy_name])
var new_enemy = new_enemy_scene.instantiate()
# var new_enemy = enemies.instantiate()
new_enemy._name = new_enemy_name
var spawn_position = Vector2(randf_range(spawn_min.x,spawn_max.x),randf_range(spawn_min.y,spawn_max.y))
new_enemy.position = spawn_position
current_level.add_child(new_enemy)
new_enemy.get_node('HealthComponent').connect('death',current_level.pickup_system) # Replace with function body.
spawn_count += 1
new_enemy.get_node('HealthComponent').connect('death',queue_spawner) # Replace with function body.

func queue_spawner(_parent):
spawn_count-=1

10 changes: 9 additions & 1 deletion 02_scenes/02_objects/spawner.tscn
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
[gd_scene load_steps=2 format=3 uid="uid://do7t4aw2geyt5"]
[gd_scene load_steps=3 format=3 uid="uid://do7t4aw2geyt5"]

[ext_resource type="Script" path="res://02_scenes/02_objects/spawner.gd" id="1_irp44"]

[sub_resource type="RectangleShape2D" id="RectangleShape2D_dxh81"]
size = Vector2(300, 300)

[node name="spawner" type="Node2D"]
script = ExtResource("1_irp44")
spawn_timer = 2.0
Expand All @@ -24,4 +27,9 @@ autostart = true

[node name="weight" type="Marker2D" parent="."]

[node name="detection_zone" type="Area2D" parent="."]

[node name="CollisionShape2D" type="CollisionShape2D" parent="detection_zone"]
shape = SubResource("RectangleShape2D_dxh81")

[connection signal="timeout" from="timer" to="." method="_on_spawn_timer_timeout"]
4 changes: 2 additions & 2 deletions 02_scenes/02_objects/weapon.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ extends Node2D
@export var weapon_sprite: Texture2D
@export var bullet_scene: PackedScene

var bullet_number = 3
var bullet_piercing = 2
var bullet_number = 1
var bullet_piercing = 0

@onready var level = get_tree().current_scene
@onready var bulletSpawn = $bullet_spawn_point
Expand Down
12 changes: 11 additions & 1 deletion 02_scenes/03_levels/level_alpha.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ enemy_scene_dict = {
"naranja": "res://02_scenes/01_characters/enemy03.tscn"
}
enemies = ExtResource("4_4xnrs")
enemy_names = Array[String](["chocolate", "naranja", "masa"])
enemy_names = Array[String](["masa", "naranja", "chocolate"])
spawn_timer = 3.0

[node name="timer" parent="spawner" index="1"]
wait_time = 4.0
Expand All @@ -84,6 +85,9 @@ max_speed = 300
drag = 0.1
dash_velocity = 1000.0

[node name="HealthComponent" parent="player" index="1"]
MAX_HEALTH = 50000.0

[node name="Camera2D" parent="player" index="3"]
zoom = Vector2(1.65, 1.65)

Expand Down Expand Up @@ -123,6 +127,8 @@ enemy_scene_dict = {
"masa": "res://02_scenes/01_characters/enemy01.tscn",
"naranja": "res://02_scenes/01_characters/enemy03.tscn"
}
enemy_names = Array[String](["chocolate", "masa", "naranja"])
spawn_timer = 3.0

[node name="spawner3" parent="." index="9" instance=ExtResource("7_wmyyt")]
position = Vector2(2038, 931)
Expand All @@ -132,6 +138,8 @@ enemy_scene_dict = {
"masa": "res://02_scenes/01_characters/enemy01.tscn",
"naranja": "res://02_scenes/01_characters/enemy03.tscn"
}
enemy_names = Array[String](["naranja", "masa", "chocolate"])
spawn_timer = 3.0

[editable path="spawner"]
[editable path="player"]
Expand All @@ -140,3 +148,5 @@ enemy_scene_dict = {
[editable path="player/weapon"]
[editable path="player/GUI"]
[editable path="player/GUI/cronometro"]
[editable path="spawner2"]
[editable path="spawner3"]
4 changes: 4 additions & 0 deletions 02_scenes/05_components/followplayer_behaviour.gd
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ var following_player = false
#func _on_detection_area_body_entered(body):
# if body.is_in_group('player'):
# following_player=true


func _on_detection_area_body_entered(_body):
pass # Replace with function body.
2 changes: 1 addition & 1 deletion 02_scenes/05_components/pickup_component.gd
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ var special_list = ['2shot','3shot','health']

func _ready():
$sprite.texture=load(textures[_name])
func _process(delta):
func _process(_delta):
if play_animation:
position += position.direction_to(player_instance.position).normalized() * 5
func _on_body_entered(body):
Expand Down

0 comments on commit c86338e

Please sign in to comment.