mirror of https://github.com/profan/ld-39-jam.git
v bad player explosions
This commit is contained in:
parent
f9c1f1380d
commit
1d1d2b4439
87
Game.tscn
87
Game.tscn
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=9 format=1]
|
||||
[gd_scene load_steps=8 format=1]
|
||||
|
||||
[ext_resource path="res://Game.gd" type="Script" id=1]
|
||||
[ext_resource path="res://Minimap.tscn" type="PackedScene" id=2]
|
||||
|
@ -7,7 +7,6 @@
|
|||
[ext_resource path="res://Player.tscn" type="PackedScene" id=5]
|
||||
[ext_resource path="res://raw/space.png" type="Texture" id=6]
|
||||
[ext_resource path="res://EnemyGrunt.tscn" type="PackedScene" id=7]
|
||||
[ext_resource path="res://Missile.tscn" type="PackedScene" id=8]
|
||||
|
||||
[node name="Game" type="Node"]
|
||||
|
||||
|
@ -72,88 +71,4 @@ region_rect = Rect2( 0, 0, 8192, 8192 )
|
|||
transform/pos = Vector2( 127.878, -20.3627 )
|
||||
transform/scale = Vector2( 1.5, 1.5 )
|
||||
|
||||
[node name="Missile" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -185.011, -27.2074 )
|
||||
|
||||
[node name="Missile1" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -406.751, 14.9641 )
|
||||
|
||||
[node name="Missile2" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -529.185, 130.596 )
|
||||
|
||||
[node name="Missile3" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -635.294, 254.39 )
|
||||
|
||||
[node name="Missile4" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -681.546, 423.076 )
|
||||
|
||||
[node name="Missile5" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -872.16, 532.262 )
|
||||
|
||||
[node name="Missile6" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -935.081, 743.232 )
|
||||
|
||||
[node name="Missile7" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -935.081, 743.232 )
|
||||
|
||||
[node name="Missile8" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 491.753, 33.61 )
|
||||
|
||||
[node name="Missile9" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 802.924, 120.89 )
|
||||
|
||||
[node name="Missile10" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 954.715, 219.554 )
|
||||
|
||||
[node name="Missile11" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1106.51, 299.244 )
|
||||
|
||||
[node name="Missile12" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1227.94, 420.677 )
|
||||
|
||||
[node name="Missile13" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1356.96, 576.262 )
|
||||
|
||||
[node name="Missile14" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1459.42, 716.669 )
|
||||
|
||||
[node name="Missile15" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1573.26, 906.407 )
|
||||
|
||||
[node name="Missile16" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1675.72, 1020.25 )
|
||||
|
||||
[node name="Missile17" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( 1804.74, 1206.19 )
|
||||
|
||||
[node name="Missile18" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -274.79, 48.7891 )
|
||||
|
||||
[node name="Missile19" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -532.835, 348.576 )
|
||||
|
||||
[node name="Missile20" parent="." instance=ExtResource( 8 )]
|
||||
|
||||
transform/pos = Vector2( -631.499, 591.441 )
|
||||
|
||||
|
||||
|
|
|
@ -48,6 +48,7 @@ class Seek:
|
|||
owner = o
|
||||
|
||||
func get_steering(s):
|
||||
if target == null: return
|
||||
var tr = target.get_ref()
|
||||
if tr:
|
||||
# update velocity
|
||||
|
@ -79,6 +80,7 @@ class Arrive:
|
|||
time_to_target = a
|
||||
|
||||
func get_steering(s):
|
||||
if target == null: return
|
||||
var tr = target.get_ref()
|
||||
if tr:
|
||||
if s.velocity.length() < radius:
|
||||
|
|
|
@ -18,7 +18,6 @@ var cur_kinematic
|
|||
var steering
|
||||
var s_seek
|
||||
var s_arrive
|
||||
var s_avoid
|
||||
|
||||
# is dead?
|
||||
var is_dead = false
|
||||
|
@ -37,7 +36,6 @@ func _ready():
|
|||
|
||||
s_seek = km.Seek.new(self)
|
||||
s_arrive = km.Arrive.new(self, missile_arrive_radius, missile_arrive_speed)
|
||||
s_avoid = km.Avoid.new(self, avoid_area)
|
||||
|
||||
var player = get_tree().get_root().get_node("Game/Player")
|
||||
s_seek.set_target(player)
|
||||
|
@ -91,7 +89,6 @@ func _fixed_process(delta):
|
|||
|
||||
s_seek.get_steering(steering)
|
||||
s_arrive.get_steering(steering)
|
||||
s_avoid.get_steering(steering)
|
||||
cur_kinematic.update(steering, delta)
|
||||
|
||||
if is_colliding():
|
||||
|
|
44
Missile.tscn
44
Missile.tscn
|
@ -1,4 +1,4 @@
|
|||
[gd_scene load_steps=6 format=1]
|
||||
[gd_scene load_steps=4 format=1]
|
||||
|
||||
[ext_resource path="res://Missile.gd" type="Script" id=1]
|
||||
[ext_resource path="res://raw/missile_one.png" type="Texture" id=2]
|
||||
|
@ -8,18 +8,6 @@
|
|||
custom_solver_bias = 0.0
|
||||
extents = Vector2( 0.531269, 3.07443 )
|
||||
|
||||
[sub_resource type="SegmentShape2D" id=2]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
a = Vector2( 0, 0 )
|
||||
b = Vector2( 0, 10 )
|
||||
|
||||
[sub_resource type="SegmentShape2D" id=3]
|
||||
|
||||
custom_solver_bias = 0.0
|
||||
a = Vector2( 0, 0 )
|
||||
b = Vector2( 0, 10 )
|
||||
|
||||
[node name="Missile" type="KinematicBody2D"]
|
||||
|
||||
transform/scale = Vector2( 2, 2 )
|
||||
|
@ -67,34 +55,4 @@ shape = SubResource( 1 )
|
|||
trigger = false
|
||||
_update_shape_index = 0
|
||||
|
||||
[node name="AvoidCone" type="Area2D" parent="."]
|
||||
|
||||
input/pickable = true
|
||||
shapes/0/shape = SubResource( 2 )
|
||||
shapes/0/transform = Matrix32( -0.92388, 0.382683, -0.382683, -0.92388, 0, 0 )
|
||||
shapes/0/trigger = true
|
||||
shapes/1/shape = SubResource( 3 )
|
||||
shapes/1/transform = Matrix32( -0.92388, -0.382683, 0.382683, -0.92388, 0, 0 )
|
||||
shapes/1/trigger = true
|
||||
gravity_vec = Vector2( 0, 1 )
|
||||
gravity = 98.0
|
||||
linear_damp = 0.1
|
||||
angular_damp = 1.0
|
||||
collision/layers = 4
|
||||
collision/mask = 6
|
||||
|
||||
[node name="LeftFeeler" type="CollisionShape2D" parent="AvoidCone"]
|
||||
|
||||
transform/rot = 202.5
|
||||
shape = SubResource( 2 )
|
||||
trigger = true
|
||||
_update_shape_index = 0
|
||||
|
||||
[node name="RightFeeler" type="CollisionShape2D" parent="AvoidCone"]
|
||||
|
||||
transform/rot = 157.5
|
||||
shape = SubResource( 3 )
|
||||
trigger = true
|
||||
_update_shape_index = 1
|
||||
|
||||
|
||||
|
|
20
Player.gd
20
Player.gd
|
@ -1,5 +1,7 @@
|
|||
extends KinematicBody2D
|
||||
|
||||
var ExplosionEffect = load("res://ExplosionEffect.tscn")
|
||||
|
||||
onready var sprite = get_node("Sprite")
|
||||
onready var camera = get_node("Camera2D")
|
||||
onready var left_particles = get_node("Sprite/LeftThruster")
|
||||
|
@ -17,6 +19,9 @@ var ship_turn_speed = deg2rad(180) # degrees per second.. i guess?
|
|||
var ship_dir = Vector2(1, 0)
|
||||
var ship_mass = 61
|
||||
|
||||
var ship_health = 100
|
||||
var player_is_dead = false
|
||||
|
||||
var is_moving = false
|
||||
var missiles_locked_on = 0
|
||||
var is_engine_playing = false
|
||||
|
@ -34,7 +39,7 @@ func type():
|
|||
return "Player"
|
||||
|
||||
func do_damage(v):
|
||||
pass
|
||||
ship_health -= v
|
||||
|
||||
func get_kinematic_position():
|
||||
return get_global_pos() + ship_vel
|
||||
|
@ -80,8 +85,21 @@ func get_closest_missile_distance():
|
|||
min_dist = mis_dist
|
||||
return min_dist
|
||||
|
||||
func player_explode():
|
||||
# create explosion effect
|
||||
var new_ee = ExplosionEffect.instance()
|
||||
get_tree().get_root().add_child(new_ee)
|
||||
new_ee.set_global_pos(get_global_pos())
|
||||
player_is_dead = true
|
||||
|
||||
func _fixed_process(delta):
|
||||
|
||||
if ship_health <= 0 and not player_is_dead:
|
||||
player_explode()
|
||||
|
||||
if player_is_dead:
|
||||
return
|
||||
|
||||
var mov_delta = Vector2(0, 0)
|
||||
turn_towards(delta, get_global_mouse_pos())
|
||||
|
||||
|
|
Loading…
Reference in New Issue