fixes, maps
This commit is contained in:
parent
15b4c5d320
commit
60ca7e6ca8
33
Map.gd
33
Map.gd
@ -66,7 +66,30 @@ func spawn(pos,vol):
|
||||
min_distance = distance
|
||||
closest_node = node
|
||||
controlling=closest_node
|
||||
|
||||
if tool.name=="Impulse":
|
||||
if tool.get_node("Type").selected==0: # linear
|
||||
for node in %Map.get_children():
|
||||
if node is Player:
|
||||
var direction = vol.normalized()
|
||||
var distance = pos.distance_to(node.position)
|
||||
var dropOff = int(tool.get_node("DropOff").text)
|
||||
var power = int(tool.get_node("Power").text)
|
||||
var magnitude = power * vol.length()
|
||||
if dropOff:
|
||||
magnitude/= distance * dropOff
|
||||
node.apply_impulse(direction * magnitude)
|
||||
if tool.get_node("Type").selected==1: # radial
|
||||
for node in %Map.get_children():
|
||||
if node is Player:
|
||||
var direction = pos.direction_to(node.position)
|
||||
var distance = pos.distance_to(node.position)
|
||||
var dropOff = int(tool.get_node("DropOff").text)
|
||||
var power = int(tool.get_node("Power").text)
|
||||
var magnitude = power * vol.length()
|
||||
if dropOff:
|
||||
magnitude/= distance * dropOff
|
||||
node.apply_impulse(direction * magnitude)
|
||||
|
||||
func spawm_pool(pos,red,green,blue):
|
||||
var new_pool: Pool = load("res://pool.tscn").instantiate()
|
||||
new_pool.position = pos
|
||||
@ -139,9 +162,12 @@ func load_map(filename):
|
||||
return # Error! We don't have a save to load.
|
||||
|
||||
# deleting saveable objects.
|
||||
var save_nodes = get_tree().get_nodes_in_group("Persist")
|
||||
var save_nodes = get_tree().root.get_node("Sim/Map").get_children()
|
||||
for i in save_nodes:
|
||||
i.queue_free()
|
||||
if i is Player or i is Pool:
|
||||
i.collision_layer = 0
|
||||
i.collision_mask = 0
|
||||
i.queue_free()
|
||||
|
||||
# Load the file line by line and process
|
||||
var save_game = FileAccess.open(filename, FileAccess.READ)
|
||||
@ -171,6 +197,7 @@ func load_map(filename):
|
||||
add_child(new_object)
|
||||
|
||||
func _on_new_dialog_confirmed():
|
||||
await get_tree().process_frame
|
||||
var save_nodes = get_tree().get_nodes_in_group("Persist")
|
||||
for i in save_nodes:
|
||||
i.queue_free()
|
||||
|
23
Player.gd
23
Player.gd
@ -29,21 +29,6 @@ var carrying_g=0
|
||||
var carrying_b=0
|
||||
|
||||
func _process(_delta):
|
||||
if $CollisionShape2D.disabled:
|
||||
# Prepare the shape query parameters
|
||||
var query_parameters = PhysicsShapeQueryParameters2D.new()
|
||||
var collision_shape = $CollisionShape2D.shape
|
||||
query_parameters.set_shape(collision_shape)
|
||||
query_parameters.set_transform(Transform2D(0, position))
|
||||
query_parameters.set_collision_mask(2) #2=pools
|
||||
|
||||
# Get the Physics2DDirectSpaceState for collision checking
|
||||
var space_state = get_world_2d().direct_space_state
|
||||
|
||||
# Check for collision
|
||||
var collision_results = space_state.intersect_shape(query_parameters)
|
||||
if collision_results.size() == 0:
|
||||
$CollisionShape2D.disabled=false
|
||||
|
||||
var controlling=get_tree().root.get_node("Sim/Map").controlling
|
||||
if controlling and is_instance_valid(controlling) and controlling==self:
|
||||
@ -56,16 +41,15 @@ func _process(_delta):
|
||||
controlling.apply_impulse(Vector2(-1,0)*s)
|
||||
if Input.is_action_pressed('move_right'):
|
||||
controlling.apply_impulse(Vector2(1,0)*s)
|
||||
|
||||
|
||||
func drop():
|
||||
if not is_carrying():
|
||||
return
|
||||
var new_pool: Pool = load("res://pool.tscn").instantiate()
|
||||
new_pool.position = position
|
||||
new_pool.position = position-(linear_velocity.normalized()*15)
|
||||
new_pool.mana_r=carrying_r
|
||||
new_pool.mana_g=carrying_g
|
||||
new_pool.mana_b=carrying_b
|
||||
#new_pool.get_node("CollisionShape2D2").disabled=true;
|
||||
carrying_r=0
|
||||
carrying_g=0
|
||||
carrying_b=0
|
||||
@ -81,7 +65,6 @@ func doubledrop(player: Player):
|
||||
new_pool.mana_r=carrying_r+player.carrying_r
|
||||
new_pool.mana_g=carrying_g+player.carrying_g
|
||||
new_pool.mana_b=carrying_b+player.carrying_b
|
||||
new_pool.get_node("CollisionShape2D2").disabled=true;
|
||||
carrying_r=0
|
||||
carrying_g=0
|
||||
carrying_b=0
|
||||
@ -91,7 +74,7 @@ func doubledrop(player: Player):
|
||||
can_pickup=false
|
||||
$PickupTimer.start()
|
||||
player.can_pickup=false
|
||||
player.getNode("PickupTimer").start()
|
||||
player.get_node("PickupTimer").start()
|
||||
get_tree().root.get_node("Sim/Map").call_deferred("add_child",new_pool)
|
||||
update()
|
||||
player.update()
|
||||
|
75
hud.tscn
75
hud.tscn
@ -58,6 +58,29 @@ text = "100"
|
||||
placeholder_text = "0"
|
||||
max_length = 5
|
||||
|
||||
[node name="Create Player Circle" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label2" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "Radius:"
|
||||
|
||||
[node name="Radius" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "50"
|
||||
placeholder_text = "0"
|
||||
max_length = 5
|
||||
|
||||
[node name="Label3" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "Count:"
|
||||
|
||||
[node name="Count" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "16"
|
||||
placeholder_text = "0"
|
||||
max_length = 5
|
||||
|
||||
[node name="Create Pool Circle" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
@ -111,35 +134,41 @@ text = "16"
|
||||
placeholder_text = "0"
|
||||
max_length = 5
|
||||
|
||||
[node name="Create Player Circle" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Label2" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "Radius:"
|
||||
|
||||
[node name="Radius" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "50"
|
||||
placeholder_text = "0"
|
||||
max_length = 5
|
||||
|
||||
[node name="Label3" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "Count:"
|
||||
|
||||
[node name="Count" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Create Player Circle"]
|
||||
layout_mode = 2
|
||||
text = "16"
|
||||
placeholder_text = "0"
|
||||
max_length = 5
|
||||
|
||||
[node name="Paste" type="OptionButton" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Delete" type="VBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Impulse" type="HBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
[node name="Type" type="OptionButton" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
|
||||
layout_mode = 2
|
||||
item_count = 2
|
||||
selected = 0
|
||||
popup/item_0/text = "Linear"
|
||||
popup/item_0/id = 0
|
||||
popup/item_1/text = "Radial"
|
||||
popup/item_1/id = 1
|
||||
|
||||
[node name="Label2" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
|
||||
layout_mode = 2
|
||||
text = "Power
|
||||
"
|
||||
|
||||
[node name="Power" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
|
||||
layout_mode = 2
|
||||
text = "1"
|
||||
|
||||
[node name="Label" type="Label" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
|
||||
layout_mode = 2
|
||||
text = "Dampening"
|
||||
|
||||
[node name="DropOff" type="LineEdit" parent="HBoxContainer/ToolSelect/VBoxContainer/Impulse"]
|
||||
layout_mode = 2
|
||||
text = "1"
|
||||
|
||||
[node name="Control Player" type="VBoxContainer" parent="HBoxContainer/ToolSelect/VBoxContainer"]
|
||||
layout_mode = 2
|
||||
|
||||
|
1068
saves/atoms24
Normal file
1068
saves/atoms24
Normal file
File diff suppressed because it is too large
Load Diff
3884
saves/atoms24_running
Normal file
3884
saves/atoms24_running
Normal file
File diff suppressed because it is too large
Load Diff
2707
saves/trippy
Normal file
2707
saves/trippy
Normal file
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue
Block a user