Add cannons as characters instead
This commit is contained in:
parent
539982ef10
commit
0a87bce20d
48
World/Map.gd
48
World/Map.gd
|
@ -79,18 +79,40 @@ func parse_map_file(file_name):
|
||||||
for ix in range(MapConfig.mapwidth):
|
for ix in range(MapConfig.mapwidth):
|
||||||
var letter_code = MapConfig.mapdata[iy * MapConfig.mapwidth + ix]
|
var letter_code = MapConfig.mapdata[iy * MapConfig.mapwidth + ix]
|
||||||
if tile_dictionary.has(letter_code):
|
if tile_dictionary.has(letter_code):
|
||||||
set_cell(0, Vector2i(ix, iy), 0, tile_dictionary[letter_code])
|
match letter_code:
|
||||||
if "_0123456789".contains(letter_code):
|
# Cannon
|
||||||
base_positions.push_back(Vector2i(ix, iy))
|
"c", "d", "r", "f":
|
||||||
if MapConfig.edgewrap:
|
var cannon = preload("res://World/cannon.tscn").instantiate()
|
||||||
if ix < MapConfig.mapwidth / 2:
|
cannon.position = 64*Vector2i(ix, iy) + Vector2i(32, 32)
|
||||||
base_positions[-1].x += MapConfig.mapwidth
|
match letter_code:
|
||||||
if iy < MapConfig.mapheight / 2:
|
"c":
|
||||||
base_positions[-1].y += MapConfig.mapheight
|
cannon.rotation_degrees = 180
|
||||||
if MapConfig.edgewrap:
|
"d":
|
||||||
set_cell(0, Vector2i(ix + MapConfig.mapwidth, iy), 0, tile_dictionary[letter_code])
|
cannon.rotation_degrees = 270
|
||||||
set_cell(0, Vector2i(ix + MapConfig.mapwidth, iy + MapConfig.mapheight), 0, tile_dictionary[letter_code])
|
"r":
|
||||||
set_cell(0, Vector2i(ix, iy + MapConfig.mapheight), 0, tile_dictionary[letter_code])
|
cannon.rotation_degrees = 0
|
||||||
|
"f":
|
||||||
|
cannon.rotation_degrees = 90
|
||||||
|
if MapConfig.edgewrap:
|
||||||
|
if ix < MapConfig.mapwidth / 2:
|
||||||
|
cannon.position.x += 64*MapConfig.mapwidth
|
||||||
|
if iy < MapConfig.mapheight / 2:
|
||||||
|
cannon.position.y += 64*MapConfig.mapheight
|
||||||
|
$"../Cannons".add_child(cannon, true)
|
||||||
|
|
||||||
|
_:
|
||||||
|
set_cell(0, Vector2i(ix, iy), 0, tile_dictionary[letter_code])
|
||||||
|
if "_0123456789".contains(letter_code):
|
||||||
|
base_positions.push_back(Vector2i(ix, iy))
|
||||||
|
if MapConfig.edgewrap:
|
||||||
|
if ix < MapConfig.mapwidth / 2:
|
||||||
|
base_positions[-1].x += MapConfig.mapwidth
|
||||||
|
if iy < MapConfig.mapheight / 2:
|
||||||
|
base_positions[-1].y += MapConfig.mapheight
|
||||||
|
if MapConfig.edgewrap:
|
||||||
|
set_cell(0, Vector2i(ix + MapConfig.mapwidth, iy), 0, tile_dictionary[letter_code])
|
||||||
|
set_cell(0, Vector2i(ix + MapConfig.mapwidth, iy + MapConfig.mapheight), 0, tile_dictionary[letter_code])
|
||||||
|
set_cell(0, Vector2i(ix, iy + MapConfig.mapheight), 0, tile_dictionary[letter_code])
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Map data or dimensions missing")
|
print("Map data or dimensions missing")
|
||||||
|
@ -104,3 +126,5 @@ func apply_options():
|
||||||
else:
|
else:
|
||||||
if $"../Map boundaries".is_connected("body_exited", $".."._on_map_boundaries_body_exited):
|
if $"../Map boundaries".is_connected("body_exited", $".."._on_map_boundaries_body_exited):
|
||||||
$"../Map boundaries".disconnect("body_exited", $".."._on_map_boundaries_body_exited)
|
$"../Map boundaries".disconnect("body_exited", $".."._on_map_boundaries_body_exited)
|
||||||
|
|
||||||
|
# Engine.physics_ticks_per_second = MapConfig.framespersecond
|
||||||
|
|
|
@ -178,7 +178,13 @@ shape = SubResource("RectangleShape2D_hjo0t")
|
||||||
|
|
||||||
[node name="Players" type="Node2D" parent="."]
|
[node name="Players" type="Node2D" parent="."]
|
||||||
|
|
||||||
[node name="MultiplayerSpawner" type="MultiplayerSpawner" parent="."]
|
[node name="PlayerSpawner" type="MultiplayerSpawner" parent="."]
|
||||||
_spawnable_scenes = PackedStringArray("res://World/PlayerShip.tscn")
|
_spawnable_scenes = PackedStringArray("res://World/PlayerShip.tscn")
|
||||||
spawn_path = NodePath("../Players")
|
spawn_path = NodePath("../Players")
|
||||||
spawn_limit = 4
|
spawn_limit = 4
|
||||||
|
|
||||||
|
[node name="Cannons" type="Node2D" parent="."]
|
||||||
|
|
||||||
|
[node name="CannonSpawner" type="MultiplayerSpawner" parent="."]
|
||||||
|
_spawnable_scenes = PackedStringArray("res://World/cannon.tscn")
|
||||||
|
spawn_path = NodePath("../Cannons")
|
||||||
|
|
Loading…
Reference in New Issue