add spawning

This commit is contained in:
fram3d 2024-07-02 23:32:18 +02:00
parent b654df9f35
commit 130a538509
Signed by: fram3d
GPG Key ID: 938920E709EEA32A
14 changed files with 387 additions and 81 deletions

55
src/NPCs/big_ooze.tscn Normal file
View File

@ -0,0 +1,55 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://NPCs/ooze.png" type="Texture" id=1]
[ext_resource path="res://NPCs/bigooze.gd" type="Script" id=2]
[ext_resource path="res://Audio/Hits/goblinattack.ogg" type="AudioStream" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 5.89857, 6.21018 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 5.81983, 5.97394 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 5.66234, 5.58022 )
[node name="big_ooze" type="KinematicBody2D"]
script = ExtResource( 2 )
[node name="ooze" type="Sprite" parent="."]
position = Vector2( 0.0170081, -0.0936285 )
scale = Vector2( 1.41341, 1.42326 )
texture = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=[
"ooze",
]]
shape = SubResource( 1 )
[node name="Hitbox" type="Area2D" parent="." groups=[
"ooze",
]]
collision_layer = 8
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" groups=[
"ooze",
]]
shape = SubResource( 2 )
[node name="Hurtbox" type="Area2D" parent="." groups=[
"ooze",
]]
collision_layer = 16
collision_mask = 32
[node name="death" type="AudioStreamPlayer" parent="Hurtbox"]
stream = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox" groups=[
"ooze",
]]
shape = SubResource( 3 )
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="finished" from="Hurtbox/death" to="." method="_on_death_finished"]

32
src/NPCs/bigooze.gd Normal file
View File

@ -0,0 +1,32 @@
extends KinematicBody2D
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
func _physics_process(_delta):
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play()
func _on_death_finished():
var ooze = load("res://NPCs/ooze.tscn")
var instance1 = ooze.instance()
var instance2 = ooze.instance()
instance1.position = position
instance2.position = position
get_parent().add_child(instance1)
get_parent().add_child(instance2)
queue_free()
func _on_Hitbox_area_entered(_area):
yield(get_tree().create_timer(2.0),"timeout")
var ooze = load("res://NPCs/ooze.tscn")
var instance = ooze.instance()
instance.position = position
get_parent().add_child(instance)

41
src/NPCs/femalegoblin.gd Normal file
View File

@ -0,0 +1,41 @@
extends KinematicBody2D
onready var pregnancy = 0
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
func _physics_process(_delta):
if pregnancy == 20:
var female = load("res://NPCs/femalegoblin.tscn")
var male = load("res://NPCs/malegoblin.tscn")
var femalechild1 = female.instance()
var femalechild2 = female.instance()
var malechild1 = male.instance()
var malechild2 = male.instance()
femalechild1.position = position
femalechild2.position = position
malechild1.position = position
malechild2.position = position
get_parent().add_child(femalechild1)
get_parent().add_child(femalechild2)
get_parent().add_child(malechild1)
get_parent().add_child(malechild2)
if pregnancy > 0:
pregnancy = pregnancy - 1
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play()
func _on_death_finished():
queue_free()
func _on_Romance_area_entered(area):
if area.is_in_group("malegoblin") and pregnancy == 0:
pregnancy = 100

View File

@ -0,0 +1,66 @@
[gd_scene load_steps=8 format=2]
[ext_resource path="res://NPCs/goblin.png" type="Texture" id=1]
[ext_resource path="res://Audio/Hits/goblininjured.ogg" type="AudioStream" id=2]
[ext_resource path="res://NPCs/femalegoblin.gd" type="Script" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 3.90875, 3.7602 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 4.13172, 3.98318 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 4.0574, 3.7602 )
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 4.875, 4.94941 )
[node name="femalegoblin" type="KinematicBody2D"]
script = ExtResource( 3 )
[node name="goblin" type="Sprite" parent="."]
position = Vector2( 0.380203, -0.127379 )
texture = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=[
"goblin",
]]
shape = SubResource( 1 )
[node name="Hitbox" type="Area2D" parent="." groups=[
"goblin",
]]
collision_layer = 32
collision_mask = 16
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" groups=[
"goblin",
]]
shape = SubResource( 2 )
[node name="Hurtbox" type="Area2D" parent="." groups=[
"goblin",
]]
collision_layer = 64
collision_mask = 2
[node name="death" type="AudioStreamPlayer" parent="Hurtbox"]
stream = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox" groups=[
"goblin",
]]
shape = SubResource( 3 )
[node name="Romance" type="Area2D" parent="." groups=[
"femalegoblin",
]]
collision_layer = 128
collision_mask = 128
[node name="CollisionShape2D" type="CollisionShape2D" parent="Romance"]
shape = SubResource( 4 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="finished" from="Hurtbox/death" to="." method="_on_death_finished"]
[connection signal="area_entered" from="Romance" to="." method="_on_Romance_area_entered"]

View File

@ -1,31 +0,0 @@
extends KinematicBody2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(_delta):
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
pass
func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play()
pass # Replace with function body.
func _on_death_finished():
queue_free()
pass # Replace with function body.

18
src/NPCs/malegoblin.gd Normal file
View File

@ -0,0 +1,18 @@
extends KinematicBody2D
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
func _physics_process(_delta):
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play()
func _on_death_finished():
queue_free()

View File

@ -1,8 +1,8 @@
[gd_scene load_steps=7 format=2]
[gd_scene load_steps=8 format=2]
[ext_resource path="res://NPCs/goblin.png" type="Texture" id=1]
[ext_resource path="res://NPCs/goblin.gd" type="Script" id=2]
[ext_resource path="res://Audio/Hits/goblininjured.ogg" type="AudioStream" id=3]
[ext_resource path="res://Audio/Hits/goblininjured.ogg" type="AudioStream" id=2]
[ext_resource path="res://NPCs/malegoblin.gd" type="Script" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 3.90875, 3.7602 )
@ -13,8 +13,11 @@ extents = Vector2( 4.13172, 3.98318 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 4.0574, 3.7602 )
[node name="goblin" type="KinematicBody2D"]
script = ExtResource( 2 )
[sub_resource type="RectangleShape2D" id=4]
extents = Vector2( 4.875, 4.94941 )
[node name="malegoblin" type="KinematicBody2D"]
script = ExtResource( 3 )
[node name="goblin" type="Sprite" parent="."]
position = Vector2( 0.380203, -0.127379 )
@ -43,11 +46,20 @@ collision_layer = 64
collision_mask = 2
[node name="death" type="AudioStreamPlayer" parent="Hurtbox"]
stream = ExtResource( 3 )
stream = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox" groups=[
"goblin",
]]
shape = SubResource( 3 )
[node name="Romance" type="Area2D" parent="." groups=[
"malegoblin",
]]
collision_layer = 128
collision_mask = 128
[node name="CollisionShape2D" type="CollisionShape2D" parent="Romance"]
shape = SubResource( 4 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="finished" from="Hurtbox/death" to="." method="_on_death_finished"]

View File

@ -1,20 +1,7 @@
extends Area2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
func _on_Hurtbox_area_entered(_area):
#if area.is_in_group("ooze"):
$Hurtbox/death.play()
pass # Replace with function body.
func _on_death_finished():
queue_free()
pass # Replace with function body.

View File

@ -1,9 +1,6 @@
extends KinematicBody2D
# Declare member variables here. Examples:
# var a = 2
# var b = "text"
onready var immunity = 500
const MOVEMENT_VECTORS = [
Vector2.UP,
@ -12,20 +9,30 @@ const MOVEMENT_VECTORS = [
Vector2.LEFT
]
# Called when the node enters the scene tree for the first time.
func _ready():
pass # Replace with function body.
# Called every frame. 'delta' is the elapsed time since the previous frame.
func _physics_process(_delta):
if immunity > 0:
immunity = immunity - 1
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
pass
func _on_Hurtbox_area_entered(_area):
$Hurtbox/death.play()
pass # Replace with function body.
if immunity == 0:
$Hurtbox/death.play()
func _on_death_finished():
var smallooze = load("res://NPCs/smallooze.tscn")
var instance1 = smallooze.instance()
var instance2 = smallooze.instance()
instance1.position = position
instance2.position = position
get_parent().add_child(instance1)
get_parent().add_child(instance2)
queue_free()
func _on_Hitbox_area_entered(_area):
yield(get_tree().create_timer(2.0),"timeout")
var bigooze = load("res://NPCs/big_ooze.tscn")
var instance = bigooze.instance()
instance.position = position
get_parent().add_child(instance)
queue_free()
pass # Replace with function body.

View File

@ -5,13 +5,13 @@
[ext_resource path="res://Audio/Hits/goblinattack.ogg" type="AudioStream" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 4.57893, 3.98952 )
extents = Vector2( 4.7174, 4.63528 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 4.69029, 4.54633 )
extents = Vector2( 4.79614, 4.55653 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 4.69029, 4.43497 )
extents = Vector2( 4.7174, 4.55653 )
[node name="ooze" type="KinematicBody2D"]
script = ExtResource( 2 )
@ -49,5 +49,6 @@ stream = ExtResource( 3 )
"ooze",
]]
shape = SubResource( 3 )
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="finished" from="Hurtbox/death" to="." method="_on_death_finished"]

31
src/NPCs/smallooze.gd Normal file
View File

@ -0,0 +1,31 @@
extends KinematicBody2D
onready var immunity = 5
const MOVEMENT_VECTORS = [
Vector2.UP,
Vector2.RIGHT,
Vector2.DOWN,
Vector2.LEFT
]
func _physics_process(_delta):
if immunity > 0:
immunity = immunity - 1
var movement = MOVEMENT_VECTORS[randi() % 4]
move_and_collide(movement * 2)
func _on_Hurtbox_area_entered(_area):
if immunity == 0:
$Hurtbox/death.play()
func _on_death_finished():
queue_free()
func _on_Hitbox_area_entered(_area):
yield(get_tree().create_timer(2.0),"timeout")
var ooze = load("res://NPCs/ooze.tscn")
var instance = ooze.instance()
instance.position = position
get_parent().add_child(instance)
queue_free()

57
src/NPCs/smallooze.tscn Normal file
View File

@ -0,0 +1,57 @@
[gd_scene load_steps=7 format=2]
[ext_resource path="res://NPCs/ooze.png" type="Texture" id=1]
[ext_resource path="res://NPCs/smallooze.gd" type="Script" id=2]
[ext_resource path="res://Audio/Hits/goblinattack.ogg" type="AudioStream" id=3]
[sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 2.51253, 2.43041 )
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 2.59128, 2.50916 )
[sub_resource type="RectangleShape2D" id=3]
extents = Vector2( 2.51253, 2.35167 )
[node name="small_ooze" type="KinematicBody2D"]
script = ExtResource( 2 )
[node name="ooze" type="Sprite" parent="."]
position = Vector2( 0.135125, 0.142608 )
scale = Vector2( 0.635804, 0.65549 )
texture = ExtResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="." groups=[
"ooze",
]]
shape = SubResource( 1 )
[node name="Hitbox" type="Area2D" parent="." groups=[
"ooze",
]]
collision_layer = 8
collision_mask = 4
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hitbox" groups=[
"ooze",
]]
shape = SubResource( 2 )
[node name="Hurtbox" type="Area2D" parent="." groups=[
"ooze",
]]
collision_layer = 16
collision_mask = 32
[node name="death" type="AudioStreamPlayer" parent="Hurtbox"]
stream = ExtResource( 3 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="Hurtbox" groups=[
"ooze",
]]
position = Vector2( -0.0787458, 0.0787449 )
shape = SubResource( 3 )
script = ExtResource( 2 )
[connection signal="area_entered" from="Hitbox" to="." method="_on_Hitbox_area_entered"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="finished" from="Hurtbox/death" to="." method="_on_death_finished"]

View File

@ -1,13 +1,15 @@
[gd_scene load_steps=16 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://Tilesets/stone.png" type="Texture" id=1]
[ext_resource path="res://Tilesets/dirt.png" type="Texture" id=2]
[ext_resource path="res://Tilesets/water.png" type="Texture" id=3]
[ext_resource path="res://NPCs/goblin.tscn" type="PackedScene" id=4]
[ext_resource path="res://NPCs/ooze.tscn" type="PackedScene" id=5]
[ext_resource path="res://NPCs/malegoblin.tscn" type="PackedScene" id=4]
[ext_resource path="res://NPCs/femalegoblin.tscn" type="PackedScene" id=5]
[ext_resource path="res://NPCs/moss.tscn" type="PackedScene" id=6]
[ext_resource path="res://Audio/Background/cave.ogg" type="AudioStream" id=7]
[ext_resource path="res://camera.gd" type="Script" id=8]
[ext_resource path="res://NPCs/big_ooze.tscn" type="PackedScene" id=9]
[ext_resource path="res://spaw.gd" type="Script" id=10]
[sub_resource type="ConvexPolygonShape2D" id=1]
points = PoolVector2Array( 0, 0, 8, 0, 8, 8, 0, 8 )
@ -157,20 +159,24 @@ position = Vector2( -4, 4 )
stream = ExtResource( 7 )
autoplay = true
[node name="goblin" parent="." instance=ExtResource( 4 )]
position = Vector2( 28, 52 )
[node name="moss" parent="." instance=ExtResource( 6 )]
position = Vector2( 44, 44 )
[node name="ooze" parent="." instance=ExtResource( 5 )]
position = Vector2( 28, 28 )
[node name="goblin2" parent="." instance=ExtResource( 4 )]
position = Vector2( 36, 36 )
[node name="moss2" parent="." instance=ExtResource( 6 )]
position = Vector2( 36, 20 )
[node name="ooze2" parent="." instance=ExtResource( 5 )]
position = Vector2( 36, 52 )
[node name="ooze" parent="." instance=ExtResource( 9 )]
position = Vector2( 36, 44 )
[node name="malegoblin" parent="." instance=ExtResource( 4 )]
position = Vector2( 12, 52 )
[node name="femalegoblin" parent="." instance=ExtResource( 5 )]
position = Vector2( 28, 52 )
[node name="Timer" type="Timer" parent="."]
process_mode = 0
wait_time = 10.0
autostart = true
script = ExtResource( 10 )
[connection signal="timeout" from="Timer" to="Timer" method="_on_Timer_timeout"]

24
src/spaw.gd Normal file
View File

@ -0,0 +1,24 @@
extends Timer
#onready var mapwidth = get("display/window/size/width")
#onready var mapheight = get("display/window/size/height")
onready var mapwidth = 80
onready var mapheight = 64
func _on_Timer_timeout():
var width = randi() % mapwidth
var height = randi() % mapheight
var random = randi() % 100
var scene = load("res://NPCs/moss.tscn")
if random in range(0, 10):
scene = load("res://NPCs/femalegoblin.tscn")
if random in range(10, 20):
scene = load("res://NPCs/malegoblin.tscn")
if random in range(20, 40):
scene = load("res://NPCs/ooze.tscn")
var instance = scene.instance()
instance.position = Vector2(width, height)
get_parent().add_child(instance)