Boss encounter
This commit is contained in:
parent
bdd9f2ea2c
commit
2b90d087c4
|
@ -1,9 +1,10 @@
|
|||
[gd_scene load_steps=5 format=2]
|
||||
[gd_scene load_steps=6 format=2]
|
||||
|
||||
[ext_resource path="res://Levels/Level.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Scenes/Enemies/BossEnemy.tscn" type="PackedScene" id=2]
|
||||
[ext_resource path="res://Levels/Door.tscn" type="PackedScene" id=3]
|
||||
[ext_resource path="res://Levels/DoorConnections/01_99.tres" type="Resource" id=4]
|
||||
[ext_resource path="res://Scenes/Objects/Spikes.tscn" type="PackedScene" id=5]
|
||||
|
||||
[node name="Level_99" instance=ExtResource( 1 )]
|
||||
|
||||
|
@ -14,7 +15,33 @@ connection = ExtResource( 4 )
|
|||
new_level_path = "res://Levels/Level_01.tscn"
|
||||
|
||||
[node name="BossEnemy" parent="." index="1" instance=ExtResource( 2 )]
|
||||
position = Vector2( 162, 23 )
|
||||
position = Vector2( 167, -25 )
|
||||
|
||||
[node name="TileMap" parent="." index="2"]
|
||||
tile_data = PoolIntArray( -589821, 0, 4, -589820, 0, 196609, -589819, 0, 196609, -589818, 0, 196609, -589817, 0, 196609, -589816, 0, 196609, -589815, 0, 196609, -589814, 0, 196609, -589813, 0, 196609, -589812, 0, 196609, -589811, 0, 196609, -589810, 0, 196609, -589809, 0, 196609, -589808, 0, 196609, -589807, 0, 7, -524286, 0, 4, -524285, 0, 196615, -524271, 0, 196612, -524270, 0, 7, -458750, 0, 65539, -458734, 0, 65539, -393215, 0, 4, -393214, 0, 196615, -393198, 0, 196612, -393197, 0, 7, -327679, 0, 65539, -327661, 0, 65539, -262144, 0, 4, -262143, 0, 196615, -262125, 0, 196612, -262124, 0, 7, -196608, 0, 65539, -196588, 0, 65539, -131072, 0, 65539, -131052, 0, 65539, -1, 0, 196608, -65536, 0, 196615, -65516, 0, 65539, 20, 0, 65539, 65556, 0, 65539, 196607, 0, 196608, 131072, 0, 7, 131091, 0, 4, 131092, 0, 196615, 196608, 0, 196612, 196609, 0, 7, 196626, 0, 4, 196627, 0, 196615, 262145, 0, 196612, 262146, 0, 196609, 262147, 0, 196609, 262148, 0, 196609, 262149, 0, 196609, 262150, 0, 196609, 262151, 0, 196609, 262152, 0, 196609, 262153, 0, 196609, 262154, 0, 196609, 262155, 0, 196609, 262156, 0, 196609, 262157, 0, 196609, 262158, 0, 196609, 262159, 0, 196609, 262160, 0, 196609, 262161, 0, 196609, 262162, 0, 196615 )
|
||||
tile_data = PoolIntArray( -589821, 0, 4, -589820, 0, 196609, -589819, 0, 196609, -589818, 0, 196609, -589817, 0, 196609, -589816, 0, 196609, -589815, 0, 196609, -589814, 0, 196609, -589813, 0, 196609, -589812, 0, 196609, -589811, 0, 196609, -589810, 0, 196609, -589809, 0, 196609, -589808, 0, 196609, -589807, 0, 7, -524286, 0, 4, -524285, 0, 196615, -524271, 0, 196612, -524270, 0, 7, -458750, 0, 65539, -458734, 0, 65539, -393215, 0, 4, -393214, 0, 196615, -393198, 0, 196612, -393197, 0, 7, -327679, 0, 65539, -327661, 0, 65539, -262144, 0, 4, -262143, 0, 196615, -262125, 0, 196612, -262124, 0, 7, -196608, 0, 65539, -196588, 0, 65539, -131072, 0, 65539, -131052, 0, 65539, -1, 0, 196608, -65536, 0, 196615, -65516, 0, 65539, 20, 0, 65539, 65556, 0, 65539, 196607, 0, 196608, 131072, 0, 7, 131091, 0, 4, 131092, 0, 196615, 196608, 0, 196612, 196609, 0, 7, 196612, 0, 0, 196613, 0, 1, 196614, 0, 2, 196616, 0, 0, 196617, 0, 2, 196621, 0, 3, 196623, 0, 3, 196626, 0, 4, 196627, 0, 196615, 262145, 0, 196612, 262146, 0, 196609, 262147, 0, 196609, 262148, 0, 196614, 262149, 0, 131073, 262150, 0, 196613, 262151, 0, 196609, 262152, 0, 196614, 262153, 0, 196613, 262154, 0, 196609, 262155, 0, 196609, 262156, 0, 196609, 262157, 0, 196616, 262158, 0, 196609, 262159, 0, 196616, 262160, 0, 196609, 262161, 0, 196609, 262162, 0, 196615 )
|
||||
|
||||
[node name="Spikes" type="Node2D" parent="." index="3"]
|
||||
|
||||
[node name="Spikes" parent="Spikes" index="0" instance=ExtResource( 5 )]
|
||||
position = Vector2( 32, -48 )
|
||||
rotation = 1.5708
|
||||
|
||||
[node name="Spikes2" parent="Spikes" index="1" instance=ExtResource( 5 )]
|
||||
position = Vector2( 32, -16 )
|
||||
rotation = 1.5708
|
||||
|
||||
[node name="Spikes3" parent="Spikes" index="2" instance=ExtResource( 5 )]
|
||||
position = Vector2( 32, -32 )
|
||||
rotation = 1.5708
|
||||
|
||||
[node name="Spikes4" parent="Spikes" index="3" instance=ExtResource( 5 )]
|
||||
position = Vector2( 304, -22 )
|
||||
rotation = -1.5708
|
||||
|
||||
[node name="Spikes5" parent="Spikes" index="4" instance=ExtResource( 5 )]
|
||||
position = Vector2( 304, 10 )
|
||||
rotation = -1.5708
|
||||
|
||||
[node name="Spikes6" parent="Spikes" index="5" instance=ExtResource( 5 )]
|
||||
position = Vector2( 304, -6 )
|
||||
rotation = -1.5708
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
extends "res://Scenes/Enemies/Enemy.gd"
|
||||
|
||||
var MainInstances = ResourceLoader.MainInstances
|
||||
|
||||
const Bullet = preload("res://Scenes/Objects/EnemyBullet.tscn")
|
||||
|
||||
export (int) var ACCELERATION = 70
|
||||
|
||||
onready var rightWallCheck = $RightWallCheck
|
||||
onready var leftWallCheck = $LeftWallCheck
|
||||
|
||||
func _process(delta):
|
||||
chase_player(delta)
|
||||
|
||||
func chase_player(delta):
|
||||
var player = MainInstances.Player
|
||||
if player != null: # We not dead
|
||||
var direction_to_move = sign(player.global_position.x - global_position.x)
|
||||
motion.x += ACCELERATION * delta * direction_to_move
|
||||
motion.x = clamp(motion.x, -MAX_SPEED, MAX_SPEED)
|
||||
global_position.x += motion.x * delta
|
||||
rotation_degrees = lerp(rotation_degrees, (motion.x / MAX_SPEED) * 10, 0.3)
|
||||
|
||||
if rightWallCheck.is_colliding() and motion.x > 0:
|
||||
motion.x *= -0.5
|
||||
|
||||
if rightWallCheck.is_colliding() and motion.x <= 0:
|
||||
motion.x *= -0.5
|
||||
|
||||
func fire_bullet() -> void:
|
||||
var bullet = Utils.instance_scene_on_main(Bullet, global_position)
|
||||
var velocity = Vector2.DOWN * 50
|
||||
velocity = velocity.rotated(deg2rad(rand_range(-30, 30)))
|
||||
bullet.velocity = velocity
|
||||
|
||||
func _on_Timer_timeout():
|
||||
fire_bullet()
|
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=13 format=2]
|
||||
[gd_scene load_steps=14 format=2]
|
||||
|
||||
[ext_resource path="res://Scenes/Enemies/Enemy.tscn" type="PackedScene" id=1]
|
||||
[ext_resource path="res://Assets/Enemies/BossEnemyHead.png" type="Texture" id=2]
|
||||
|
@ -8,6 +8,7 @@
|
|||
[ext_resource path="res://Assets/Enemies/BossEnemyLeg1.png" type="Texture" id=6]
|
||||
[ext_resource path="res://Assets/Enemies/BossEnemyLeg2.png" type="Texture" id=7]
|
||||
[ext_resource path="res://Assets/Enemies/BossEnemyLeg3.png" type="Texture" id=8]
|
||||
[ext_resource path="res://Scenes/Enemies/BossEnemy.gd" type="Script" id=9]
|
||||
|
||||
[sub_resource type="Animation" id=1]
|
||||
resource_name = "Base"
|
||||
|
@ -816,8 +817,11 @@ radius = 18.0
|
|||
length = 16.0
|
||||
|
||||
[node name="BossEnemy" instance=ExtResource( 1 )]
|
||||
script = ExtResource( 9 )
|
||||
MAX_SPEED = 50
|
||||
|
||||
[node name="OnionLayer" type="Sprite" parent="." index="0"]
|
||||
visible = false
|
||||
modulate = Color( 1, 1, 1, 0.113725 )
|
||||
position = Vector2( 0, -11 )
|
||||
texture = ExtResource( 5 )
|
||||
|
@ -1005,5 +1009,19 @@ shape = SubResource( 4 )
|
|||
[node name="EnemyStats" parent="." index="6"]
|
||||
max_health = 100
|
||||
|
||||
[node name="RightWallCheck" type="RayCast2D" parent="." index="7"]
|
||||
cast_to = Vector2( 0, 16 )
|
||||
collision_mask = 2
|
||||
|
||||
[node name="LeftWallCheck" type="RayCast2D" parent="." index="8"]
|
||||
cast_to = Vector2( 0, -16 )
|
||||
collision_mask = 2
|
||||
|
||||
[node name="Timer" type="Timer" parent="." index="9"]
|
||||
wait_time = 0.3
|
||||
autostart = true
|
||||
|
||||
[connection signal="timeout" from="Timer" to="." method="_on_Timer_timeout"]
|
||||
|
||||
[editable path="Hurtbox"]
|
||||
[editable path="Hitbox"]
|
||||
|
|
|
@ -6,6 +6,8 @@ export (int) var MAX_SPEED = 15
|
|||
|
||||
onready var stats = $EnemyStats
|
||||
|
||||
signal died
|
||||
|
||||
var motion = Vector2.ZERO
|
||||
|
||||
func _on_Hurtbox_hit(damage):
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
[gd_scene load_steps=4 format=2]
|
||||
|
||||
[ext_resource path="res://Assets/Enemies/Spikes.png" type="Texture" id=1]
|
||||
[ext_resource path="res://Scenes/Objects/Hitbox.tscn" type="PackedScene" id=2]
|
||||
|
||||
[sub_resource type="RectangleShape2D" id=1]
|
||||
extents = Vector2( 8, 8 )
|
||||
|
||||
[node name="Spikes" type="Node2D"]
|
||||
|
||||
[node name="Sprite" type="Sprite" parent="."]
|
||||
texture = ExtResource( 1 )
|
||||
centered = false
|
||||
|
||||
[node name="Hitbox" parent="." instance=ExtResource( 2 )]
|
||||
collision_mask = 4
|
||||
|
||||
[node name="Collider" parent="Hitbox" index="0"]
|
||||
position = Vector2( 8, 8 )
|
||||
shape = SubResource( 1 )
|
||||
|
||||
[editable path="Hitbox"]
|
|
@ -21,6 +21,7 @@ position = Vector2( 9, 88 )
|
|||
[node name="UI" parent="." instance=ExtResource( 7 )]
|
||||
|
||||
[node name="Level_00" parent="." instance=ExtResource( 1 )]
|
||||
position = Vector2( -132, -35 )
|
||||
|
||||
[editable path="Player"]
|
||||
[editable path="Player/Hurtbox"]
|
||||
|
|
Loading…
Reference in New Issue