Skip to content

Commit

Permalink
Merge pull request #51 from rafaelcastrocouto/main
Browse files Browse the repository at this point in the history
small 1 lane map
  • Loading branch information
rafaelcastrocouto authored Aug 17, 2022
2 parents 5ca4339 + 4fc961c commit 031ddce
Show file tree
Hide file tree
Showing 31 changed files with 1,029 additions and 310 deletions.
4 changes: 2 additions & 2 deletions prototype/buildings/blacksmith.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -179,9 +179,11 @@ lane = ""

[node name="symbol" parent="." index="1"]
position = Vector2( 0, -1.78814e-07 )
offset = Vector2( 0, -1 )

[node name="symbol_border" parent="symbol" index="0"]
scale = Vector2( 1.4, 1.4 )
offset = Vector2( 0, -0.71 )

[node name="state" parent="hud" index="0"]
margin_top = -79.0
Expand All @@ -203,10 +205,8 @@ anims/idle = SubResource( 25 )
visible = false

[node name="body" parent="sprites" index="1"]
visible = true
use_parent_material = false
frames = SubResource( 43 )
animation = "default"
offset = Vector2( 0, -30 )

[node name="flags" type="Node2D" parent="sprites" index="2"]
Expand Down
4 changes: 2 additions & 2 deletions prototype/buildings/castle.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,11 @@ projectile_speed = 220.0
[node name="symbol" parent="." index="1"]
position = Vector2( 0, -1.90735e-06 )
scale = Vector2( 24, 24 )
offset = Vector2( 0, -1 )

[node name="symbol_border" parent="symbol" index="0"]
scale = Vector2( 1.33333, 1.33333 )
offset = Vector2( 0, -0.75 )

[node name="state" parent="hud" index="0"]
margin_top = -118.0
Expand All @@ -225,11 +227,9 @@ anims/idle = SubResource( 25 )
visible = false

[node name="body" parent="sprites" index="1"]
visible = true
use_parent_material = false
position = Vector2( 0, 11 )
frames = SubResource( 46 )
animation = "default"
offset = Vector2( 0, -51 )

[node name="flags" type="Node2D" parent="sprites" index="2"]
Expand Down
2 changes: 0 additions & 2 deletions prototype/buildings/tower.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -224,10 +224,8 @@ anims/idle = SubResource( 25 )
visible = false

[node name="body" parent="sprites" index="1"]
visible = true
use_parent_material = false
frames = SubResource( 44 )
animation = "default"
offset = Vector2( 0, -36 )

[node name="flags" type="Node2D" parent="sprites" index="2"]
Expand Down
19 changes: 14 additions & 5 deletions prototype/controls/camera.gd
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ var game:Node

var is_panning:bool = false
var pan_position:Vector2 = Vector2.ZERO
var zoom_default = Vector2.ONE
var zoom_limit:Vector2 = Vector2(0.5,3.52)
var zoom_default:Vector2 = Vector2.ONE
var zoom_limit:Vector2 = Vector2.ONE
var margin:int = limit_right;
var position_limit:int = 756
var arrow_keys_speed:int = 4
Expand All @@ -17,7 +17,6 @@ func _ready():
game = get_tree().get_current_scene()
zoom = zoom_default
yield(get_tree(), "idle_frame")
zoom_limit.y = game.map_camera.zoom.y


func _unhandled_input(event):
Expand Down Expand Up @@ -84,14 +83,24 @@ func _unhandled_input(event):
if event.is_action_pressed("zoom_in"):
if zoom.x >= 1:
var point = game.camera.get_global_mouse_position()
var h = game.map.size / 2
game.camera.global_position = point - Vector2(h,h)
game.camera.global_position = point - game.map.mid
if zoom.x == zoom_limit.y: zoom_reset()
elif zoom == zoom_default: zoom_in()
if event.is_action_pressed("zoom_out"):
if zoom.x == zoom_limit.x: zoom_reset()
elif zoom == zoom_default: zoom_out()


func start():
offset = game.map.mid
var h = offset.x
limit_left = -h
limit_top = -h
limit_right = h
limit_bottom = h
margin = h


func focus_leader(index):
if game.player_leaders.size() >= index:
var leader = game.player_leaders[index-1]
Expand Down
17 changes: 5 additions & 12 deletions prototype/controls/orders/orders_window.gd
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,6 @@ func _ready():

hide()
clear()

yield(get_tree(), "idle_frame")

for neutral in game.map.neutrals:
self[neutral].append( game.map.get_node("buildings/blue/" + neutral) )
self[neutral].append( game.map.get_node("buildings/red/" + neutral) )

update()



Expand All @@ -110,11 +102,12 @@ func clear():

func build():
setup_lanes()
build_mines()
build_blacksmiths()
build_lumbermills()
build_camps()
build_outposts()
if game.map.neutrals.size() > 1:
build_mines()
build_lumbermills()
build_camps()
build_outposts()


# LEADERS
Expand Down
2 changes: 1 addition & 1 deletion prototype/controls/orders/unit_orders.gd
Original file line number Diff line number Diff line change
Expand Up @@ -519,7 +519,7 @@ func retreat(unit):
else: order = enemy_leaders_orders[unit.name]
set_leader(unit, order)
var lane = unit.lane
var path = game.map[lane].duplicate()
var path = game.map.lanes_paths[lane].duplicate()
if unit.team == "blue": path.invert()
game.unit.follow.smart(unit, path, "move")

Expand Down
8 changes: 3 additions & 5 deletions prototype/controls/selection.gd
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ func _unhandled_input(event):
match event.button_index:
BUTTON_LEFT:
game.camera.zoom_reset()
var h = game.map.size / 2
game.camera.global_position = point - Vector2(h,h)
game.camera.global_position = point - game.map.mid


# TOUCH SELECTION
Expand All @@ -69,8 +68,7 @@ func _unhandled_input(event):
# MAP TOUCH ZOOM IN
else:
game.camera.zoom_reset()
var h = game.map.size / 2
game.camera.global_position = point - Vector2(h,h)
game.camera.global_position = point - game.map.mid

func setup_selection(unit):
if unit.selectable: game.selectable_units.append(unit)
Expand Down Expand Up @@ -132,7 +130,7 @@ func get_sel_unit_at_point(point):


func advance(unit, point):
if unit.attacks and unit.moves and game.can_control(unit):
if unit and unit.attacks and unit.moves and game.can_control(unit):
var order_point = order(unit, point)
game.unit.advance.smart(unit, order_point)

Expand Down
35 changes: 11 additions & 24 deletions prototype/game.gd
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ var teams = ["blue", "red"]

var rng = RandomNumberGenerator.new()

onready var map = get_node("map")
onready var maps = get_node("maps")
onready var camera = get_node("camera")
onready var unit = get_node("unit")
onready var collision = get_node("collision")
onready var ui = get_node("ui")
onready var selection = get_node("selection")
onready var collision = get_node("collision")
onready var utils = get_node("utils")
onready var test = get_node("test")

var unit:Node
var utils:Node
var test:Node
var map_camera:Node
var map:Node

var control_state = "selection"

Expand All @@ -48,50 +48,37 @@ var started:bool = false


func _ready():
unit = get_node("map/unit")
map_camera = get_node("map_camera")
utils = get_node("utils")
test = get_node("test")

map.setup_buildings()
map.blocks.setup_quadtree()
get_tree().paused = true


func _process(delta: float) -> void:
if started: camera.process()
ui.process()
# build called after ui.minimap get_texture



func build():

if not built:
built = true

if test.unit: # debug units
ui.main_menu.get_node("container/play_button").play_down()
start()
else:
get_tree().paused = true
ui.main_menu.visible = true


func start():
if not started:
started = true
paused = false

maps.setup_buildings()
map.blocks.setup_quadtree()
#Engine.time_scale = 3

rng.randomize()
map.setup_lanes()
maps.setup_lanes()
ui.orders.build()
unit.follow.setup_pathfind()
unit.spawn.choose_leaders()

map.get_node("fog").visible = true

if test.unit:
test.spawn_unit()
elif test.stress:
Expand All @@ -100,7 +87,7 @@ func start():
unit.spawn.start()
yield(get_tree().create_timer(4), "timeout")
unit.spawn.leaders()
map.setup_leaders()
maps.setup_leaders()


func _physics_process(delta):
Expand Down
28 changes: 14 additions & 14 deletions prototype/game.tscn
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
[gd_scene load_steps=10 format=2]
[gd_scene load_steps=12 format=2]

[ext_resource path="res://map/map.tscn" type="PackedScene" id=1]
[ext_resource path="res://map/maps/3lane_map.tscn" type="PackedScene" id=1]
[ext_resource path="res://game.gd" type="Script" id=2]
[ext_resource path="res://controls/camera.gd" type="Script" id=3]
[ext_resource path="res://ui/ui.tscn" type="PackedScene" id=4]
[ext_resource path="res://unit/unit.tscn" type="PackedScene" id=5]
[ext_resource path="res://map/maps.gd" type="Script" id=6]
[ext_resource path="res://controls/selection.gd" type="Script" id=7]
[ext_resource path="res://utils/utils.gd" type="Script" id=8]
[ext_resource path="res://utils/test.gd" type="Script" id=9]
[ext_resource path="res://unit/collision.gd" type="Script" id=10]
[ext_resource path="res://map/maps/1lane_map.tscn" type="PackedScene" id=11]

[node name="game" type="Node2D"]
script = ExtResource( 2 )

[node name="map" parent="." instance=ExtResource( 1 )]
[node name="unit" parent="." instance=ExtResource( 5 )]
visible = false

[node name="maps" type="Node2D" parent="."]
script = ExtResource( 6 )

[node name="unit" parent="map" instance=ExtResource( 5 )]
[node name="1lane_map" parent="maps" instance=ExtResource( 11 )]
visible = false

[node name="camera" type="Camera2D" parent="."]
offset = Vector2( 1056, 1056 )
limit_left = -1056
limit_top = -1056
limit_right = 1056
limit_bottom = 1056
script = ExtResource( 3 )
[node name="3lane_map" parent="maps" instance=ExtResource( 1 )]
visible = false

[node name="map_camera" type="Camera2D" parent="."]
offset = Vector2( 1056, 1056 )
[node name="camera" type="Camera2D" parent="."]
current = true
zoom = Vector2( 3.52, 3.52 )
script = ExtResource( 3 )

[node name="ui" parent="." instance=ExtResource( 4 )]

Expand Down
5 changes: 0 additions & 5 deletions prototype/items/shop.gd
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ func _ready():
disable_all()

yield(get_tree(), "idle_frame")

blacksmiths = [
game.map.get_node("buildings/blue/blacksmith"),
game.map.get_node("buildings/red/blacksmith")
]


func clear():
Expand Down
5 changes: 1 addition & 4 deletions prototype/leaders/lorne.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -625,18 +625,15 @@ anims/stun = SubResource( 33 )
visible = false

[node name="big_shadow" type="Sprite" parent="sprites" index="1"]
modulate = Color( 0, 0, 0, 0.294118 )
light_mask = 0
modulate = Color( 0, 0, 0, 0.117647 )
use_parent_material = true
position = Vector2( 0, 8 )
scale = Vector2( 1.3, 1.4 )
texture = ExtResource( 4 )

[node name="body" parent="sprites" index="2"]
visible = true
position = Vector2( 2, 9 )
frames = SubResource( 36 )
animation = "default"
offset = Vector2( 4, -22 )

[node name="weapon" type="AnimatedSprite" parent="sprites" index="3"]
Expand Down
6 changes: 2 additions & 4 deletions prototype/leaders/takoda.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -639,16 +639,14 @@ anims/stun = SubResource( 33 )
visible = false

[node name="big_shadow" type="Sprite" parent="sprites" index="1"]
modulate = Color( 0, 0, 0, 0.294118 )
light_mask = 0
modulate = Color( 0, 0, 0, 0.117647 )
use_parent_material = true
position = Vector2( 0, 8 )
scale = Vector2( 1.3, 1.4 )
texture = ExtResource( 4 )

[node name="body" parent="sprites" index="2"]
visible = true
frames = SubResource( 36 )
animation = "default"
offset = Vector2( 5, -24 )

[node name="axe" type="AnimatedSprite" parent="sprites" index="3"]
Expand Down
6 changes: 2 additions & 4 deletions prototype/leaders/tomyris.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -725,17 +725,15 @@ anims/stun = SubResource( 33 )
visible = false

[node name="big_shadow" type="Sprite" parent="sprites" index="1"]
modulate = Color( 0, 0, 0, 0.294118 )
light_mask = 0
modulate = Color( 0, 0, 0, 0.117647 )
use_parent_material = true
position = Vector2( 0, 8 )
scale = Vector2( 1.3, 1.4 )
texture = ExtResource( 4 )

[node name="body" parent="sprites" index="2"]
visible = true
position = Vector2( 3, 9 )
frames = SubResource( 36 )
animation = "default"
offset = Vector2( 2, -24 )

[node name="weapon" type="Node2D" parent="sprites" index="3"]
Expand Down
Loading

0 comments on commit 031ddce

Please sign in to comment.