New 1 life Ai

This commit is contained in:
Diego 2020-07-19 17:19:31 -05:00
parent 1a7fdfb310
commit c90373b9b9
19 changed files with 317 additions and 53 deletions

BIN
Sound Effects/Hit Wall.wav Normal file

Binary file not shown.

View file

@ -17,5 +17,5 @@ force/max_rate=false
force/max_rate_hz=44100 force/max_rate_hz=44100
edit/trim=false edit/trim=false
edit/normalize=false edit/normalize=false
edit/loop=true edit/loop=false
compress/mode=0 compress/mode=0

Binary file not shown.

View file

@ -17,5 +17,5 @@ force/max_rate=false
force/max_rate_hz=44100 force/max_rate_hz=44100
edit/trim=false edit/trim=false
edit/normalize=false edit/normalize=false
edit/loop=true edit/loop=false
compress/mode=0 compress/mode=0

View file

@ -1,34 +0,0 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/interface-bit-game-pixel-art-platformer-mobile-desktop-version-appearance-level-dark-dungeon-brick-walls-torches-126375076.jpg-cdec0b7f82f2b8c50604c5b31f7e0660.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://Sound Effects/interface-bit-game-pixel-art-platformer-mobile-desktop-version-appearance-level-dark-dungeon-brick-walls-torches-126375076.jpg"
dest_files=[ "res://.import/interface-bit-game-pixel-art-platformer-mobile-desktop-version-appearance-level-dark-dungeon-brick-walls-torches-126375076.jpg-cdec0b7f82f2b8c50604c5b31f7e0660.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

40
ai/BadFireball.tscn Normal file
View file

@ -0,0 +1,40 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://ai/Hell Projectile.gd" type="Script" id=1]
[ext_resource path="res://art/Bad Fireball.png" type="Texture" id=2]
[sub_resource type="Animation" id=1]
resource_name = "Fireeball"
length = 0.2
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Bad Fireball:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1 ),
"transitions": PoolRealArray( 1, 1 ),
"update": 1,
"values": [ 1, 0 ]
}
[sub_resource type="CircleShape2D" id=2]
radius = 4.54199
[node name="KinematicBody2D" type="KinematicBody2D"]
collision_layer = 8
collision_mask = 3
script = ExtResource( 1 )
[node name="BadFireball" type="Sprite" parent="."]
texture = ExtResource( 2 )
hframes = 2
[node name="AnimationPlayer" type="AnimationPlayer" parent="BadFireball"]
autoplay = "Fireeball"
anims/Fireeball = SubResource( 1 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 2 )

36
ai/Enemy.gd Normal file
View file

@ -0,0 +1,36 @@
extends KinematicBody2D
class_name Enemy
var speed = 60
var gravity =500
var health = 5
const UP = Vector2(0, -1)
var velocity = Vector2()
func apply_gravity(delta, modifier = 1):
velocity.y += gravity * delta * modifier
func _physics_process(_delta):
if Globals.player != null:
if $RayCast2D.get_collider() != null && $RayCast2D.get_collider().has_method("get_type") and $RayCast2D.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
elif $RayCast2D2.get_collider() != null && $RayCast2D2.get_collider().has_method("get_type") and $RayCast2D2.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
elif $RayCast2D3.get_collider() != null && $RayCast2D3.get_collider().has_method("get_type") and $RayCast2D3.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
elif $RayCast2D4.get_collider() != null && $RayCast2D4.get_collider().has_method("get_type") and $RayCast2D4.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
else:
velocity.x = position.direction_to(Globals.player).normalized().x
apply_gravity(_delta)
velocity.x *= speed
velocity = move_and_slide(velocity, UP)
if velocity.x > 0:
# $(Enemy Sprite).flip_h = false
elif velocity.x < 0:
# $(Enemy Sprite).flip_h = true
if is_on_wall() and is_on_floor():
velocity.y = -150

14
ai/Hell Projectile.gd Normal file
View file

@ -0,0 +1,14 @@
extends Projectile
func launch_right():
velocity = (Vector2.RIGHT * speed)
func launch_left():
velocity = (Vector2.LEFT * speed)
func launch_upleft():
velocity = (Vector2(-1, -1).normalized() * speed)
func launch_upright():
velocity = (Vector2(1, -1).normalized() * speed)
func on_impact(collision):
if collision.collider.has_method("get_type"):
collision.collider.set_health(collision.collider.get_health() - 1)
queue_free()

67
ai/Hell.gd Normal file
View file

@ -0,0 +1,67 @@
extends KinematicBody2D
var Hell_Projectile = preload("res://ai/BadFireball.tscn")
var speed = 60
var gravity =500
var health = 5
const UP = Vector2(0, -1)
onready var ShootDelay : Timer = $ShootDelay
onready var ProjectileSpawn: Node2D = $Position2D
var velocity = Vector2()
func apply_gravity(delta, modifier = 1):
velocity.y += gravity * delta * modifier
func _physics_process(_delta):
if Globals.player != null:
if $RayCast2D.get_collider() != null && $RayCast2D.get_collider().has_method("get_type") and $RayCast2D.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
if ShootDelay.is_stopped():
var temp = Hell_Projectile.instance()
get_tree().current_scene.add_child(temp)
temp.global_position = ProjectileSpawn.global_position
temp.launch_left()
ShootDelay.start()
queue_free()
elif $RayCast2D2.get_collider() != null && $RayCast2D2.get_collider().has_method("get_type") and $RayCast2D2.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
if ShootDelay.is_stopped():
var temp = Hell_Projectile.instance()
get_tree().current_scene.add_child(temp)
temp.global_position = ProjectileSpawn.global_position
temp.launch_right()
ShootDelay.start()
queue_free()
elif $RayCast2D3.get_collider() != null && $RayCast2D3.get_collider().has_method("get_type") and $RayCast2D3.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
if ShootDelay.is_stopped():
var temp = Hell_Projectile.instance()
get_tree().current_scene.add_child(temp)
temp.global_position = ProjectileSpawn.global_position
temp.launch_upleft()
ShootDelay.start()
queue_free()
elif $RayCast2D4.get_collider() != null && $RayCast2D4.get_collider().has_method("get_type") and $RayCast2D4.get_collider().get_type() == "player":
velocity = Vector2(0, 0)
if ShootDelay.is_stopped():
var temp = Hell_Projectile.instance()
get_tree().current_scene.add_child(temp)
temp.global_position = ProjectileSpawn.global_position
temp.launch_upright()
ShootDelay.start()
queue_free()
else:
velocity.x = position.direction_to(Globals.player).normalized().x
apply_gravity(_delta)
velocity.x *= speed
velocity = move_and_slide(velocity, UP)
if velocity.x > 0:
$Hell.flip_h = false
elif velocity.x < 0:
$Hell.flip_h = true
if is_on_wall() and is_on_floor():
velocity.y = -150

73
ai/Hell.tscn Normal file
View file

@ -0,0 +1,73 @@
[gd_scene load_steps=5 format=2]
[ext_resource path="res://art/Hell Dude.png" type="Texture" id=1]
[ext_resource path="res://ai/Hell.gd" type="Script" id=2]
[sub_resource type="RectangleShape2D" id=2]
extents = Vector2( 5.06709, 5.78183 )
[sub_resource type="Animation" id=1]
resource_name = "Devil"
length = 0.6
loop = true
tracks/0/type = "value"
tracks/0/path = NodePath("Hell:frame")
tracks/0/interp = 1
tracks/0/loop_wrap = true
tracks/0/imported = false
tracks/0/enabled = true
tracks/0/keys = {
"times": PoolRealArray( 0, 0.1, 0.2, 0.3, 0.4, 0.5, 0.6 ),
"transitions": PoolRealArray( 1, 1, 1, 1, 1, 1, 1 ),
"update": 1,
"values": [ 1, 2, 3, 4, 5, 6, 7 ]
}
[node name="KinematicBody2D" type="KinematicBody2D"]
collision_layer = 4
collision_mask = 3
script = ExtResource( 2 )
[node name="CollisionShape2D" type="CollisionShape2D" parent="."]
position = Vector2( 0, 1.87833 )
shape = SubResource( 2 )
[node name="RayCast2D" type="RayCast2D" parent="."]
position = Vector2( 0, 1.87833 )
enabled = true
cast_to = Vector2( -80, 0 )
collision_mask = 3
[node name="RayCast2D2" type="RayCast2D" parent="."]
position = Vector2( 0, 1.87833 )
enabled = true
cast_to = Vector2( 80, 0 )
collision_mask = 3
[node name="RayCast2D3" type="RayCast2D" parent="."]
position = Vector2( 0, 1.87833 )
enabled = true
cast_to = Vector2( 80, -25 )
collision_mask = 3
[node name="RayCast2D4" type="RayCast2D" parent="."]
position = Vector2( 0, 1.87833 )
enabled = true
cast_to = Vector2( -80, -25 )
collision_mask = 3
[node name="Hell" type="Sprite" parent="."]
position = Vector2( -7.56425, -7.87261 )
texture = ExtResource( 1 )
centered = false
hframes = 8
frame = 4
[node name="AnimationPlayer" type="AnimationPlayer" parent="."]
autoplay = "Devil"
anims/Devil = SubResource( 1 )
[node name="ShootDelay" type="Timer" parent="."]
wait_time = 1.239
[node name="Position2D" type="Position2D" parent="."]

View file

@ -1,9 +1,7 @@
[gd_scene load_steps=7 format=2] [gd_scene load_steps=5 format=2]
[ext_resource path="res://art/SpinningBone.png" type="Texture" id=1] [ext_resource path="res://art/SpinningBone.png" type="Texture" id=1]
[ext_resource path="res://ai/SpinningBone.gd" type="Script" id=2] [ext_resource path="res://ai/SpinningBone.gd" type="Script" id=2]
[ext_resource path="res://Sound Effects/Hit.wav" type="AudioStream" id=3]
[ext_resource path="res://Sound Effects/Hit Wall.wav" type="AudioStream" id=4]
[sub_resource type="Animation" id=1] [sub_resource type="Animation" id=1]
resource_name = "Bone Throw" resource_name = "Bone Throw"
@ -46,13 +44,3 @@ autoplay = "Bone Throw"
[node name="CollisionShape2D" type="CollisionShape2D" parent="."] [node name="CollisionShape2D" type="CollisionShape2D" parent="."]
shape = SubResource( 2 ) shape = SubResource( 2 )
[node name="Node" type="Node" parent="."]
[node name="Hit Wall" type="AudioStreamPlayer" parent="Node"]
stream = ExtResource( 3 )
pitch_scale = 0.77
[node name="Hit" type="AudioStreamPlayer" parent="Node"]
stream = ExtResource( 4 )
pitch_scale = 0.54

BIN
art/Bad Fireball.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 280 B

View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Bad Fireball.png-b8d2f205bab3eba50d8e3057a8d2bbfa.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/Bad Fireball.png"
dest_files=[ "res://.import/Bad Fireball.png-b8d2f205bab3eba50d8e3057a8d2bbfa.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

BIN
art/Hell Dude.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 573 B

34
art/Hell Dude.png.import Normal file
View file

@ -0,0 +1,34 @@
[remap]
importer="texture"
type="StreamTexture"
path="res://.import/Hell Dude.png-3a79ccc71e7c6c23716b1e57c1bce4c9.stex"
metadata={
"vram_texture": false
}
[deps]
source_file="res://art/Hell Dude.png"
dest_files=[ "res://.import/Hell Dude.png-3a79ccc71e7c6c23716b1e57c1bce4c9.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

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=17 format=2] [gd_scene load_steps=18 format=2]
[ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=1] [ext_resource path="res://meta/DungeonTilemap.tscn" type="PackedScene" id=1]
[ext_resource path="res://characters/Player.tscn" type="PackedScene" id=2] [ext_resource path="res://characters/Player.tscn" type="PackedScene" id=2]
@ -8,6 +8,7 @@
[ext_resource path="res://Music and Fonts(Misc.)/Keb3q1.png" type="Texture" id=6] [ext_resource path="res://Music and Fonts(Misc.)/Keb3q1.png" type="Texture" id=6]
[ext_resource path="res://art/Pedestal.png" type="Texture" id=7] [ext_resource path="res://art/Pedestal.png" type="Texture" id=7]
[ext_resource path="res://ai/Skeleton Enemy.tscn" type="PackedScene" id=8] [ext_resource path="res://ai/Skeleton Enemy.tscn" type="PackedScene" id=8]
[ext_resource path="res://ai/Hell.tscn" type="PackedScene" id=9]
[sub_resource type="RectangleShape2D" id=1] [sub_resource type="RectangleShape2D" id=1]
extents = Vector2( 169.977, 24.8286 ) extents = Vector2( 169.977, 24.8286 )
@ -148,9 +149,6 @@ __meta__ = {
"_edit_group_": true "_edit_group_": true
} }
[node name="Skeleton Enemy" parent="." instance=ExtResource( 8 )]
position = Vector2( 371.515, 139.784 )
[node name="Player" parent="." instance=ExtResource( 2 )] [node name="Player" parent="." instance=ExtResource( 2 )]
position = Vector2( -38.2158, 143.114 ) position = Vector2( -38.2158, 143.114 )
@ -253,4 +251,10 @@ __meta__ = {
[node name="AnimationPlayer2" type="AnimationPlayer" parent="text/Text3"] [node name="AnimationPlayer2" type="AnimationPlayer" parent="text/Text3"]
autoplay = "Type Writer" autoplay = "Type Writer"
"anims/Type Writer" = SubResource( 8 ) "anims/Type Writer" = SubResource( 8 )
[node name="Hell" parent="." instance=ExtResource( 9 )]
position = Vector2( 280.961, 130.283 )
[node name="Skeleton Enemy" parent="." instance=ExtResource( 8 )]
position = Vector2( 417.222, 131.88 )
[connection signal="body_entered" from="Area2D" to="text/Text2" method="_on_body_entered"] [connection signal="body_entered" from="Area2D" to="text/Text2" method="_on_body_entered"]

View file

@ -15,6 +15,11 @@ _global_script_classes=[ {
"path": "res://script/ItemPickup.gd" "path": "res://script/ItemPickup.gd"
}, { }, {
"base": "KinematicBody2D", "base": "KinematicBody2D",
"class": "Enemy",
"language": "GDScript",
"path": "res://ai/Enemy.gd"
}, {
"base": "KinematicBody2D",
"class": "Projectile", "class": "Projectile",
"language": "GDScript", "language": "GDScript",
"path": "res://script/Projectile.gd" "path": "res://script/Projectile.gd"
@ -26,6 +31,7 @@ _global_script_classes=[ {
} ] } ]
_global_script_class_icons={ _global_script_class_icons={
"Collectable": "", "Collectable": "",
"Enemy": "",
"Projectile": "", "Projectile": "",
"StateMachine": "" "StateMachine": ""
} }

View file

@ -3,6 +3,8 @@ class_name Projectile
export var speed = 300 export var speed = 300
var velocity = Vector2.ZERO var velocity = Vector2.ZERO
onready var Hit = get_node("Node/Hit")
onready var Hit_Wall = get_node("Node/Hit Wall")
func _physics_process(delta): func _physics_process(delta):
var collision = move_and_collide(velocity * delta) var collision = move_and_collide(velocity * delta)