setup for ai

This commit is contained in:
Jonas Mucke
2020-04-18 21:17:13 +02:00
parent b75cdf7a76
commit e7d5d9eacc
11 changed files with 345 additions and 94 deletions

94
src/Boss/Boss_template.gd Normal file
View File

@@ -0,0 +1,94 @@
extends KinematicBody2D
class_name Boss
"""
This is an example player controller script created by Paul
"""
var velocity := Vector2.ZERO
# This is how you export variables with ranges to the editor window
export(bool) var debug := false
export(int, 0, 500) var ACCELERATION := 450
# Reference for the current player
onready var player_stats := $Stats
onready var debug_label := $DebugLabel
#onready var animation_player := $AnimationPlayer
#var animation_tree := $AnimationTree
#onready var animation_state = animation_tree.get("parameters/playback")
enum moveState{
MOVE,
HIT
}
var movementState = moveState.MOVE
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"
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()
if debug == true:
match movementState:
moveState.MOVE:
movement_move(delta)
moveState.HIT:
movement_hit()
move()
# 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 movement_move(delta):
var input_vector = Vector2.ZERO
# This is a clever way to handle directional input
# Input.get_action_strength(...) returns a value between 0 and 1 depending
# on how strong the controller direction is pressed
# For keyboards it always returns 1 if pressed and 0 if not
# The actions are custom and defined in the project settings
input_vector.x = Input.get_action_strength("right") - Input.get_action_strength("left")
input_vector.y = Input.get_action_strength("down") - Input.get_action_strength("up")
input_vector = input_vector.normalized()
if input_vector == Vector2.ZERO:
#animation_state.travel("idle")
velocity = Vector2.ZERO
else:
velocity = velocity.move_toward(player_stats.speed * input_vector, ACCELERATION * delta)
if Input.is_action_just_pressed("roll"):
pass
elif Input.is_action_just_pressed("attack"):
pass
func movement_hit():
velocity = Vector2.ZERO
func hit_finished():
movementState = moveState.MOVE
func _on_Stats_no_health():
queue_free()
func _on_Hurtbox_area_entered(area):
player_stats.health-=area.damage
damage_per_second = damage_per_second + area.damage
func _on_Hurtbox_area_exited(area):
damage_per_second = damage_per_second - area.damage

View File

@@ -0,0 +1,67 @@
[gd_scene load_steps=9 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/Stats/Stats.tscn" type="PackedScene" id=3]
[ext_resource path="res://Boss/Boss_template.gd" type="Script" id=4]
[ext_resource path="res://testSprites/white_boss_dog.png" type="Texture" id=5]
[sub_resource type="CapsuleShape2D" id=1]
radius = 18.0
height = 18.0
[sub_resource type="CapsuleShape2D" id=2]
radius = 18.0
height = 18.0
[sub_resource type="CapsuleShape2D" id=3]
radius = 8.0
height = 15.0
[node name="Boss_template" type="KinematicBody2D"]
script = ExtResource( 4 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 3.13451, -20.1418 )
scale = Vector2( 2, 2 )
texture = ExtResource( 5 )
hframes = 60
[node name="Stats" parent="." instance=ExtResource( 3 )]
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
collision_layer = 0
[node name="CollisionShape2D" parent="Hitbox" index="0"]
position = Vector2( 0, -15 )
shape = SubResource( 1 )
[node name="Hurtbox" parent="." instance=ExtResource( 1 )]
collision_layer = 4
collision_mask = 0
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0, -15 )
shape = SubResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( -1.52588e-05, 0 )
rotation = 1.5708
shape = SubResource( 3 )
[node name="DebugLabel" type="Label" parent="."]
margin_left = -42.2456
margin_top = -65.04
margin_right = 42.7544
margin_bottom = -48.04
text = "Obermufti"
__meta__ = {
"_edit_use_anchors_": false
}
[connection signal="no_health" from="Stats" to="." method="_on_Stats_no_health"]
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[connection signal="area_exited" from="Hurtbox" to="." method="_on_Hurtbox_area_exited"]
[editable path="Hitbox"]
[editable path="Hurtbox"]

View File

@@ -17,7 +17,7 @@ func _on_Hurtbox_area_entered(area):
var Hearts = load("res://Objects/Heart/Heart.tscn")
#index of ysort
var world = get_tree().current_scene.get_child(4)
var world = get_tree().current_scene.get_child(2)
if(randf()<GreenDrop):
var green = GreenRubies.instance()
world.add_child(green)

View File

@@ -0,0 +1,23 @@
extends StaticBody2D
export(int, 1, 5) var lifePoints = 3
export(int, 1, 30) var spawnRate = 5
var elapsedTime = 0.0
func _physics_process(delta):
elapsedTime += delta
if(elapsedTime>=spawnRate):
elapsedTime-=spawnRate
var Minion = load("")
var world = get_tree().current_scene.get_child(2)
var minion = Minion.instance()
world.add_child(minion)
minion.global_position = global_position
func _on_Hurtbox_area_entered(area):
lifePoints -= area.damage
if(lifePoints<0):
queue_free()
pass

View File

@@ -0,0 +1,28 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://Overlap/HurtHit_Box/Hurtbox.tscn" type="PackedScene" id=1]
[ext_resource path="res://testSprites/fackel.png" type="Texture" id=2]
[ext_resource path="res://Objects/Torch/Torch.gd" type="Script" id=3]
[sub_resource type="CapsuleShape2D" id=1]
radius = 8.0
height = 12.0
[node name="Torch" type="StaticBody2D"]
script = ExtResource( 3 )
[node name="Sprite" type="Sprite" parent="."]
position = Vector2( 0, -8 )
texture = ExtResource( 2 )
[node name="Hurtbox" parent="." instance=ExtResource( 1 )]
collision_layer = 8
collision_mask = 0
script = null
[node name="CollisionShape2D" parent="Hurtbox" index="0"]
position = Vector2( 0, -8 )
shape = SubResource( 1 )
[connection signal="area_entered" from="Hurtbox" to="." method="_on_Hurtbox_area_entered"]
[editable path="Hurtbox"]

View File

@@ -6,6 +6,7 @@ This is an example player controller script created by Paul
var velocity := Vector2.ZERO
var rollvector := Vector2.ZERO
# This is how you export variables with ranges to the editor window
export(bool) var debug := false
export(int, 0, 500) var ROLL_SPEED := 150
export(int, 0, 500) var FRICTION := 200 # Speed at which the player deaccelarates
export(int, 0, 500) var ACCELERATION := 450
@@ -45,13 +46,14 @@ func _physics_process(delta):
totaldamage+=1
player_stats.health+=1
_debug_update()
match movementState:
moveState.MOVE:
movement_move(delta)
moveState.ROLL:
movement_roll()
moveState.HIT:
movement_hit()
if debug == true:
match movementState:
moveState.MOVE:
movement_move(delta)
moveState.ROLL:
movement_roll()
moveState.HIT:
movement_hit()
move()
@@ -104,6 +106,7 @@ func roll_finished():
func _on_Hurtbox_area_entered(area):
print("Hallo")
player_stats.health-=area.damage
damage_per_second = damage_per_second + area.damage

View File

@@ -700,7 +700,7 @@ margin_top = -21.2223
margin_right = 8.98804
margin_bottom = -9.22228
custom_fonts/font = SubResource( 49 )
text = "Ahh"
text = "Held"
__meta__ = {
"_edit_use_anchors_": false
}

View File

@@ -1,130 +1,126 @@
[gd_scene load_steps=17 format=2]
[gd_scene load_steps=18 format=2]
[ext_resource path="res://Player/Player.tscn" type="PackedScene" id=1]
[ext_resource path="res://World.gd" type="Script" id=2]
[ext_resource path="res://Maps/Tilesets/Room/tileset_room.tres" type="TileSet" id=3]
[ext_resource path="res://testSprites/dark.png" type="Texture" id=4]
[ext_resource path="res://Objects/Barrel/Barrel.tscn" type="PackedScene" id=5]
[ext_resource path="res://Objects/Traps/bear.tscn" type="PackedScene" id=5]
[ext_resource path="res://Objects/Banana/Banana.tscn" type="PackedScene" id=6]
[ext_resource path="res://Objects/Bonfire/Bonfire.tscn" type="PackedScene" id=7]
[ext_resource path="res://Objects/Traps/Sting.tscn" type="PackedScene" id=8]
[ext_resource path="res://Objects/Rubies/Blue.tscn" type="PackedScene" id=9]
[ext_resource path="res://Objects/Traps/Bear.tscn" type="PackedScene" id=10]
[ext_resource path="res://Objects/Barrel/Barrel.tscn" type="PackedScene" id=10]
[ext_resource path="res://Objects/Heart/Heart.tscn" type="PackedScene" id=11]
[ext_resource path="res://Objects/Rubies/Red.tscn" type="PackedScene" id=12]
[ext_resource path="res://Objects/Rubies/Green.tscn" type="PackedScene" id=13]
[ext_resource path="res://Objects/Traps/Flame.tscn" type="PackedScene" id=14]
[ext_resource path="res://Objects/Traps/Spike.tscn" type="PackedScene" id=15]
[ext_resource path="res://Objects/Slime/Slime.tscn" type="PackedScene" id=16]
[ext_resource path="res://Boss/Boss_template.tscn" type="PackedScene" id=17]
[node name="World" type="Node2D"]
script = ExtResource( 2 )
[node name="WallSprite" type="Sprite" parent="."]
position = Vector2( 112.785, 148.267 )
position = Vector2( 336, 160 )
texture = ExtResource( 4 )
region_enabled = true
region_rect = Rect2( 0, 0, 1280, 720 )
[node name="FloorTileMap" type="TileMap" parent="."]
position = Vector2( -16, 24 )
tile_set = ExtResource( 3 )
cell_size = Vector2( 32, 32 )
format = 1
tile_data = PoolIntArray( -131063, 47, 0, -131062, 47, 2, -65536, 47, 4, -65535, 47, 196609, -65534, 47, 196609, -65533, 47, 196609, -65532, 47, 196609, -65531, 47, 196609, -65530, 47, 196609, -65529, 47, 6, -65528, 47, 5, -65527, 47, 196614, -65526, 47, 196613, -65525, 47, 6, -65524, 47, 5, -65523, 47, 196609, -65522, 47, 7, 0, 47, 65539, 7, 47, 131072, 8, 47, 65543, 11, 47, 131072, 12, 47, 65543, 14, 47, 196612, 15, 47, 196610, 65536, 47, 65539, 65544, 47, 196612, 65545, 47, 7, 65548, 47, 65539, 131072, 47, 262148, 131073, 47, 196610, 131081, 47, 65539, 131084, 47, 65539, 131087, 47, 3, 196608, 47, 65539, 196615, 47, 196611, 196617, 47, 131075, 196619, 47, 4, 196620, 47, 196615, 196622, 47, 4, 196623, 47, 196615, 262144, 47, 65539, 262146, 47, 3, 262155, 47, 65539, 262158, 47, 65539, 327680, 47, 262148, 327681, 47, 196609, 327682, 47, 196616, 327683, 47, 196609, 327684, 47, 196609, 327685, 47, 196609, 327686, 47, 196609, 327687, 47, 7, 327691, 47, 131075, 327694, 47, 65539, 393216, 47, 65539, 393223, 47, 196612, 393224, 47, 196610, 393230, 47, 65539, 458752, 47, 196612, 458753, 47, 196609, 458754, 47, 7, 458766, 47, 65539, 524290, 47, 196612, 524291, 47, 196609, 524292, 47, 196609, 524293, 47, 196609, 524294, 47, 196609, 524295, 47, 196609, 524296, 47, 196609, 524297, 47, 196609, 524298, 47, 196609, 524299, 47, 196609, 524300, 47, 196609, 524301, 47, 196609, 524302, 47, 196615 )
[node name="Slime" parent="." instance=ExtResource( 16 )]
position = Vector2( 272.823, 72.281 )
[node name="Slime2" parent="." instance=ExtResource( 16 )]
position = Vector2( 239.993, 144.355 )
tile_data = PoolIntArray( -65537, 47, 0, -131072, 47, 1, -131071, 47, 1, -131070, 47, 1, -131069, 47, 1, -131068, 47, 1, -131067, 47, 1, -131066, 47, 1, -131065, 47, 1, -131064, 47, 1, -131063, 47, 1, -131062, 47, 1, -131061, 47, 1, -131060, 47, 1, -131059, 47, 1, -131058, 47, 1, -131057, 47, 1, -131056, 47, 2, -1, 47, 65536, -65536, 47, 65541, -65535, 47, 131073, -65534, 47, 131073, -65533, 47, 131073, -65532, 47, 131073, -65531, 47, 131073, -65530, 47, 131073, -65529, 47, 131073, -65528, 47, 131073, -65527, 47, 131073, -65526, 47, 65544, -65525, 47, 131073, -65524, 47, 131073, -65523, 47, 131073, -65522, 47, 131073, -65521, 47, 65542, -65520, 47, 65538, 65535, 47, 65536, 0, 47, 65538, 10, 47, 65539, 15, 47, 65536, 16, 47, 65538, 131071, 47, 65536, 65536, 47, 65538, 65546, 47, 65539, 65549, 47, 3, 65551, 47, 65536, 65552, 47, 65538, 196607, 47, 65536, 131072, 47, 65538, 131077, 47, 3, 131082, 47, 65539, 131085, 47, 65539, 131087, 47, 65536, 131088, 47, 65538, 262143, 47, 65536, 196608, 47, 65538, 196612, 47, 196608, 196613, 47, 262152, 196614, 47, 196610, 196618, 47, 65539, 196621, 47, 196612, 196622, 47, 196609, 196623, 47, 262150, 196624, 47, 65538, 327679, 47, 65536, 262144, 47, 65538, 262149, 47, 131075, 262154, 47, 65539, 262159, 47, 65536, 262160, 47, 65538, 393215, 47, 65536, 327680, 47, 65538, 327690, 47, 196612, 327691, 47, 196610, 327695, 47, 65536, 327696, 47, 65538, 458751, 47, 65536, 393216, 47, 65538, 393231, 47, 65536, 393232, 47, 65538, 524287, 47, 65536, 458752, 47, 131077, 458753, 47, 1, 458754, 47, 1, 458755, 47, 1, 458756, 47, 1, 458757, 47, 1, 458758, 47, 1, 458759, 47, 1, 458760, 47, 1, 458761, 47, 1, 458762, 47, 1, 458763, 47, 1, 458764, 47, 1, 458765, 47, 1, 458766, 47, 1, 458767, 47, 131078, 458768, 47, 65538, 589823, 47, 131072, 524288, 47, 131073, 524289, 47, 131073, 524290, 47, 131073, 524291, 47, 131073, 524292, 47, 131073, 524293, 47, 131073, 524294, 47, 131073, 524295, 47, 131073, 524296, 47, 131073, 524297, 47, 131073, 524298, 47, 131073, 524299, 47, 131073, 524300, 47, 131073, 524301, 47, 131073, 524302, 47, 131073, 524303, 47, 131073, 524304, 47, 131074 )
__meta__ = {
"_edit_group_": true
}
[node name="YSort" type="YSort" parent="."]
position = Vector2( 170.007, 112.118 )
position = Vector2( 152, 120 )
[node name="Barrel2" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -124.864, -87.4505 )
[node name="Barrel3" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -119.425, -59.8735 )
[node name="Barrel" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -57.3565, -65.1137 )
[node name="Barrel4" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -95.4691, -97.9434 )
[node name="Barrel5" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -88.6768, -25.4916 )
[node name="Barrel6" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -61.13, -36.8122 )
[node name="Barrel7" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -62.6394, -90.019 )
[node name="Barrel8" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -87.9221, -57.944 )
[node name="Barrel9" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( -81.8844, -74.1702 )
[node name="Boss_template" parent="YSort" instance=ExtResource( 17 )]
position = Vector2( -107.855, -54.5179 )
debug = true
[node name="Player" parent="YSort" instance=ExtResource( 1 )]
position = Vector2( -1.15936, -79.3532 )
position = Vector2( 296, -32 )
scale = Vector2( 2, 2 )
FRICTION = 200
[node name="Banana" parent="YSort" instance=ExtResource( 6 )]
position = Vector2( -122.709, 34.7666 )
[node name="minion" parent="YSort" instance=ExtResource( 17 )]
position = Vector2( 88, 24 )
scale = Vector2( 0.3, 0.3 )
collision_layer = 8
debug = true
[node name="Bonfire" parent="YSort" instance=ExtResource( 7 )]
position = Vector2( 283.515, -47.7461 )
[node name="Bear_trap" parent="YSort" instance=ExtResource( 5 )]
position = Vector2( 68.1447, -38.5179 )
[node name="Sting" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 68.6066, -28.1109 )
[node name="Sting2" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 68.6066, -18.9158 )
[node name="Sting3" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 108.936, 2.03768 )
[node name="Sting4" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 92.0694, 1.87637 )
[node name="Sting5" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 101.981, 2.46786 )
[node name="Flame2" parent="YSort" instance=ExtResource( 14 )]
position = Vector2( -31.1322, 103.722 )
[node name="Bear_trap" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( 197.579, -28.4036 )
[node name="Slime" parent="YSort" instance=ExtResource( 16 )]
position = Vector2( 68.1447, 57.4821 )
[node name="Flame" parent="YSort" instance=ExtResource( 14 )]
position = Vector2( -30.7141, 88.6697 )
position = Vector2( 124.145, 65.4821 )
[node name="Spike" parent="YSort" instance=ExtResource( 15 )]
position = Vector2( 225.593, 102.049 )
position = Vector2( 272, 88 )
[node name="Red" parent="YSort" instance=ExtResource( 12 )]
position = Vector2( -128.136, 91.1784 )
[node name="Green" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( -105.975, 105.394 )
[node name="Blue" parent="YSort" instance=ExtResource( 9 )]
position = Vector2( -89.2507, 105.394 )
[node name="Green2" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( -95.5225, 89.5059 )
[node name="Green3" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( -127.718, 103.722 )
[node name="Green4" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( -116.428, 91.5965 )
[node name="Sting" parent="YSort" instance=ExtResource( 8 )]
position = Vector2( 132.145, 17.4821 )
[node name="Heart" parent="YSort" instance=ExtResource( 11 )]
position = Vector2( 201.342, -60.5988 )
position = Vector2( -43.8553, 65.4821 )
[node name="Blue2" parent="YSort" instance=ExtResource( 9 )]
position = Vector2( 66.0861, -56.9466 )
[node name="Blue" parent="YSort" instance=ExtResource( 9 )]
position = Vector2( -3.8553, 81.4821 )
[node name="Red" parent="YSort" instance=ExtResource( 12 )]
position = Vector2( -51.8553, 41.4821 )
[node name="Green" parent="YSort" instance=ExtResource( 13 )]
position = Vector2( -19.8553, 73.4821 )
[node name="Barrel" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( 8.00002, -32 )
[node name="Barrel5" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -40, 16 )
[node name="Barrel6" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -40, 16 )
[node name="Barrel7" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -56, 16 )
[node name="Barrel8" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -72, 16 )
[node name="Barrel9" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -88, 16 )
[node name="Barrel10" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -104, 16 )
[node name="Barrel11" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( -120, 16 )
[node name="Barrel2" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( 8.00002, -48 )
[node name="Barrel3" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( 8.00002, -64 )
[node name="Barrel4" parent="YSort" instance=ExtResource( 10 )]
position = Vector2( 8.00002, -72 )
[node name="Banana" parent="YSort" instance=ExtResource( 6 )]
position = Vector2( -107.855, 73.4821 )
[node name="Bonfire" parent="." instance=ExtResource( 7 )]
position = Vector2( 448, 104 )
[editable path="YSort/minion"]
[editable path="YSort/minion/Hurtbox"]

View File

@@ -10,6 +10,11 @@ config_version=4
_global_script_classes=[ {
"base": "KinematicBody2D",
"class": "Boss",
"language": "GDScript",
"path": "res://Boss/Boss_template.gd"
}, {
"base": "KinematicBody2D",
"class": "Player",
"language": "GDScript",
"path": "res://Player/Player.gd"
@@ -25,6 +30,7 @@ _global_script_classes=[ {
"path": "res://Menus/TitleScreen/TitleScreen.gd"
} ]
_global_script_class_icons={
"Boss": "",
"Player": "",
"TitleSceenButton": "",
"TitleScreen": ""

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

View File

@@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/white_boss_dog.png-71758567a6659e328126f0647eb38c8d.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://testSprites/white_boss_dog.png"
dest_files=[ "res://.import/white_boss_dog.png-71758567a6659e328126f0647eb38c8d.stex" ]
[params]
compress/mode=0
compress/lossy_quality=0.7
compress/hdr_mode=0
compress/bptc_ldr=0
compress/normal_map=0
flags/repeat=0
flags/filter=false
flags/mipmaps=false
flags/anisotropic=false
flags/srgb=2
process/fix_alpha_border=true
process/premult_alpha=false
process/HDR_as_SRGB=false
process/invert_color=false
stream=false
size_limit=0
detect_3d=false
svg/scale=1.0