mirror of
https://github.com/creyD/ludum_dare_46.git
synced 2026-06-13 05:52:24 +02:00
torch, minion, ai attack
This commit is contained in:
@@ -31,6 +31,7 @@ hframes = 60
|
||||
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
|
||||
collision_layer = 0
|
||||
collision_mask = 65
|
||||
|
||||
[node name="CollisionShape2D" parent="Hitbox" index="0"]
|
||||
position = Vector2( 0, -15 )
|
||||
|
||||
47
src/Boss/Minion.gd
Normal file
47
src/Boss/Minion.gd
Normal file
@@ -0,0 +1,47 @@
|
||||
extends KinematicBody2D
|
||||
|
||||
var velocity := Vector2.ZERO
|
||||
|
||||
# This is how you export variables with ranges to the editor window
|
||||
export(int, 0, 500) var ACCELERATION := 450
|
||||
# Reference for the current player
|
||||
|
||||
onready var player_stats := $Stats
|
||||
onready var debug_label := $DebugLabel
|
||||
|
||||
var damage_per_second := 0.0
|
||||
var totaldamage := 0.0
|
||||
|
||||
func _debug_update():
|
||||
debug_label.text = str(player_stats.health) + "/" + str(player_stats.max_health) + " HP\n"
|
||||
|
||||
# IMPORTANT: If you are using move_and_slide don't multiply by delta
|
||||
# Godots physics system does that internally
|
||||
# In move_and_collide(...) you have to multiply by delta.
|
||||
func move():
|
||||
move_and_slide(velocity)
|
||||
|
||||
func _physics_process(delta):
|
||||
totaldamage += damage_per_second * delta
|
||||
player_stats.speed += 10 * delta
|
||||
while (totaldamage > 1):
|
||||
totaldamage -= 1
|
||||
player_stats.health -= 1
|
||||
while (totaldamage <- 1):
|
||||
totaldamage += 1
|
||||
player_stats.health += 1
|
||||
_debug_update()
|
||||
move()
|
||||
|
||||
|
||||
func _on_Stats_no_health():
|
||||
queue_free()
|
||||
|
||||
|
||||
func _on_Hurtbox_area_entered(area):
|
||||
player_stats.health -= area.damage
|
||||
damage_per_second += area.damage
|
||||
|
||||
|
||||
func _on_Hurtbox_area_exited(area):
|
||||
damage_per_second -= area.damage
|
||||
69
src/Boss/Minion.tscn
Normal file
69
src/Boss/Minion.tscn
Normal file
@@ -0,0 +1,69 @@
|
||||
[gd_scene load_steps=10 format=2]
|
||||
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Overlap/HurtHit_Box/Hitbox.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Overlap/Kind.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Overlap/Stats/Stats.tscn" type="PackedScene" id=4]
|
||||
[ext_resource path="res://testSprites/white_minion_dog.png" type="Texture" id=5]
|
||||
[ext_resource path="res://Boss/Minion.gd" type="Script" id=6]
|
||||
|
||||
[sub_resource type="CircleShape2D" id=1]
|
||||
radius = 6.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=2]
|
||||
radius = 11.0
|
||||
height = 11.0
|
||||
|
||||
[sub_resource type="CapsuleShape2D" id=3]
|
||||
radius = 11.0
|
||||
height = 11.0
|
||||
|
||||
[node name="Minion" type="KinematicBody2D"]
|
||||
script = ExtResource( 6 )
|
||||
|
||||
[node name="Kind" parent="." instance=ExtResource( 3 )]
|
||||
kind = 3
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
position = Vector2( 0, -10.2123 )
|
||||
texture = ExtResource( 5 )
|
||||
hframes = 60
|
||||
|
||||
[node name="Body" type="CollisionShape2D" parent="."]
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
|
||||
collision_layer = 0
|
||||
collision_mask = 65
|
||||
|
||||
[node name="CollisionShape2D" parent="Hitbox" index="0"]
|
||||
position = Vector2( 0, -9 )
|
||||
shape = SubResource( 2 )
|
||||
|
||||
[node name="Hurtbox" parent="." instance=ExtResource( 1 )]
|
||||
collision_layer = 8
|
||||
collision_mask = 0
|
||||
|
||||
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
|
||||
position = Vector2( 0, -9 )
|
||||
shape = SubResource( 3 )
|
||||
|
||||
[node name="DebugLabel" type="Label" parent="."]
|
||||
margin_left = -50.8637
|
||||
margin_top = -41.3944
|
||||
margin_right = 51.1363
|
||||
margin_bottom = -27.3944
|
||||
text = "the white dog"
|
||||
__meta__ = {
|
||||
"_edit_use_anchors_": false
|
||||
}
|
||||
|
||||
[node name="Stats" parent="." instance=ExtResource( 4 )]
|
||||
max_health = 2
|
||||
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
|
||||
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
|
||||
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]
|
||||
|
||||
[editable path="Hitbox"]
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
Reference in New Issue
Block a user