mirror of https://github.com/profan/ld-39-jam.git
position including velocity
This commit is contained in:
parent
d9ef9dde4f
commit
e29ab412b5
25
Game.tscn
25
Game.tscn
|
@ -72,6 +72,31 @@ region_rect = Rect2( 0, 0, 8192, 8192 )
|
||||||
transform/pos = Vector2( 127.878, -20.3627 )
|
transform/pos = Vector2( 127.878, -20.3627 )
|
||||||
transform/scale = Vector2( 1.5, 1.5 )
|
transform/scale = Vector2( 1.5, 1.5 )
|
||||||
|
|
||||||
|
[node name="EnemyGrunt1" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( -154.501, -21.5904 )
|
||||||
|
transform/scale = Vector2( 1.5, 1.5 )
|
||||||
|
|
||||||
|
[node name="EnemyGrunt2" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 361.148, -21.5904 )
|
||||||
|
transform/scale = Vector2( 1.5, 1.5 )
|
||||||
|
|
||||||
|
[node name="EnemyGrunt3" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 583.368, -24.0459 )
|
||||||
|
transform/scale = Vector2( 1.5, 1.5 )
|
||||||
|
|
||||||
|
[node name="EnemyGrunt4" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( 878.024, -24.0459 )
|
||||||
|
transform/scale = Vector2( 1.5, 1.5 )
|
||||||
|
|
||||||
|
[node name="EnemyGrunt5" parent="." instance=ExtResource( 7 )]
|
||||||
|
|
||||||
|
transform/pos = Vector2( -374.266, -24.0459 )
|
||||||
|
transform/scale = Vector2( 1.5, 1.5 )
|
||||||
|
|
||||||
[node name="Missile" parent="." instance=ExtResource( 8 )]
|
[node name="Missile" parent="." instance=ExtResource( 8 )]
|
||||||
|
|
||||||
transform/pos = Vector2( -494.716, 83.0652 )
|
transform/pos = Vector2( -494.716, 83.0652 )
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Kinematic:
|
||||||
max_speed = m
|
max_speed = m
|
||||||
|
|
||||||
func get_position():
|
func get_position():
|
||||||
return owner.get_global_pos()
|
return owner.get_kinematic_position()
|
||||||
|
|
||||||
func get_orientation():
|
func get_orientation():
|
||||||
return velocity.normalized()
|
return velocity.normalized()
|
||||||
|
@ -50,7 +50,7 @@ class Seek:
|
||||||
var tr = target.get_ref()
|
var tr = target.get_ref()
|
||||||
if tr:
|
if tr:
|
||||||
# update velocity
|
# update velocity
|
||||||
s.velocity = tr.get_global_pos() - owner.get_global_pos()
|
s.velocity = tr.get_kinematic_position() - owner.get_global_pos()
|
||||||
# update orientation
|
# update orientation
|
||||||
#if velocity.length() > 0:
|
#if velocity.length() > 0:
|
||||||
# rotation = clamp(velocity.normalized().angle(), -max_rot_speed, max_rot_speed)
|
# rotation = clamp(velocity.normalized().angle(), -max_rot_speed, max_rot_speed)
|
||||||
|
|
|
@ -29,6 +29,9 @@ func type():
|
||||||
func do_damage(v):
|
func do_damage(v):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
func get_kinematic_position():
|
||||||
|
return get_global_pos() + ship_vel
|
||||||
|
|
||||||
func turn_towards(delta, pos):
|
func turn_towards(delta, pos):
|
||||||
|
|
||||||
var target_dir = (pos - get_global_pos()).normalized()
|
var target_dir = (pos - get_global_pos()).normalized()
|
||||||
|
|
Loading…
Reference in New Issue