1
0
Fork 0

small fixes

This commit is contained in:
Michaël Lemaire 2022-10-20 00:02:02 +02:00
parent 34bd8531b9
commit 93dc2d1ef5
4 changed files with 21 additions and 7 deletions

View file

@ -34,8 +34,9 @@ func spawn():
if unit_type:
var unit := unit_type.instantiate()
if unit is Unit:
unit.position = delivery
unit.player = player
_spawning_since = min(0.0, _spawning_since - spawn_duration)
# FIXME add to battlefield
unit.player = player
add_child(unit)
unit.global_position = global_position
unit.move_to(delivery)

View file

@ -43,9 +43,9 @@ func _physics_process(delta):
var previous = global_position
global_position += (target_position - global_position).normalized() * 100.0 * delta
var diff = global_position - previous
if diff.length() > 0.001:
if diff.length() > 0.01:
$sprite.rotation = rotation_offset + diff.angle()
if global_position == target_position:
if global_position.distance_to(target_position) < 5.0:
target_reached = true
func move_to(pos: Vector2):

View file

@ -1,4 +1,4 @@
[gd_scene load_steps=6 format=3 uid="uid://c6omib6txy3qh"]
[gd_scene load_steps=7 format=3 uid="uid://c6omib6txy3qh"]
[ext_resource type="PackedScene" uid="uid://brbtq46uk18gg" path="res://core/battlefield.tscn" id="1_x63ik"]
[ext_resource type="PackedScene" uid="uid://dqaabctftkakr" path="res://core/player.tscn" id="2_o4smw"]
@ -36,6 +36,15 @@ func _gui_input(event):
zoomed.emit(-signf(event.factor))
"
[sub_resource type="GDScript" id="GDScript_0x6ru"]
script/source = "extends Control
func _gui_input(event):
if event is InputEventMouseButton:
if event.button_mask & MOUSE_BUTTON_LEFT:
pass
"
[node name="main" type="Node2D"]
[node name="camera" type="Camera2D" parent="."]
@ -57,12 +66,10 @@ code = "p2"
[node name="factory1" parent="battlefield" node_paths=PackedStringArray("player") instance=ExtResource("2_wnc50")]
position = Vector2(270, 222)
player = NodePath("../player1")
rotation_offset = null
[node name="factory2" parent="battlefield" node_paths=PackedStringArray("player") instance=ExtResource("2_wnc50")]
position = Vector2(929, 429)
player = NodePath("../player2")
rotation_offset = null
[node name="ui" type="CanvasLayer" parent="."]
@ -78,5 +85,10 @@ size_flags_vertical = 3
mouse_force_pass_scroll_events = false
script = SubResource("GDScript_0auct")
[node name="orders" type="Control" parent="ui"]
layout_mode = 3
anchors_preset = 0
script = SubResource("GDScript_0x6ru")
[connection signal="scrolled" from="ui/camcontrol" to="camera" method="scroll"]
[connection signal="zoomed" from="ui/camcontrol" to="camera" method="change_zoom"]

View file

@ -11,6 +11,7 @@ script = ExtResource("2_r2sw4")
produced_unit = ExtResource("3_u6npr")
sprite = ExtResource("2_43eyp")
hitpoints = 150
rotation_offset = null
[node name="spawner" parent="." index="0" instance=ExtResource("2_ulexw")]
unit_type = ExtResource("3_u6npr")