Skip to content

Commit

Permalink
Merge branch 'master' of github.com:BUG-inc/ant
Browse files Browse the repository at this point in the history
  • Loading branch information
diogoalmeida committed Nov 30, 2021
2 parents 0168ac9 + 50fe373 commit af9fc8d
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 21 deletions.
1 change: 1 addition & 0 deletions entities/ant_master.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ script = ExtResource( 1 )
[node name="PheromoneMap" parent="." instance=ExtResource( 2 )]
width = 1000
height = 1000
pheromone_cleaning_radius = 0
1 change: 0 additions & 1 deletion entities/base_ant.gd
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,6 @@ func hit(direction: Vector2):
set_state(State.HURTING)

func die():
# print("Ant die!")
rotation = 0.0 # PI/2.0
emit_signal("ant_dead")
set_state(State.DEAD)
Expand Down
5 changes: 4 additions & 1 deletion entities/enemy_npc_ant.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@ speed = 40

[node name="interaction_field" parent="base_ant" index="1"]
collision_layer = 0
collision_mask = 3
collision_mask = 2

[node name="CollisionPolygon2D" parent="base_ant/interaction_field" index="0"]
polygon = PoolVector2Array( -15, -34.4474, -2.5, -4.97369, 5, -4.97369, 17.5, -34.4474 )

[node name="Default" parent="base_ant" index="2"]
visible = false
Expand Down
8 changes: 4 additions & 4 deletions entities/pheromone_map.gd
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export var cell_height = 10
export var cell_width = 10
export var PHEROMONE_INCREMENT = 0.1
export var debug_mode = false
export var pheromone_cleaning_radius = 2 # radius for cleaning pheromones in a grid (e.g.: if 2, cleans in a 2x2 square)
export var pheromone_cleaning_radius = 1 # radius for cleaning pheromones in a grid (e.g.: if 2, cleans in a 2x2 square)
# each cell stores pheromones
var cells = []
var nonzero_cells = []
Expand Down Expand Up @@ -63,16 +63,16 @@ func add_pheromone(position: Vector2, increment: float = PHEROMONE_INCREMENT):
cells[cell_index[0]][cell_index[1]] = clamp(cells[cell_index[0]][cell_index[1]] + increment, 0, 0.5)
if not pheromones.has(cell_index):
var new_particles = _pheromone.instance()
new_particles.position = position
new_particles.position = get_cell_position(cell_index[0], cell_index[1])
pheromones[cell_index] = new_particles
add_child(new_particles)
#update()

func remove_pheromone(position: Vector2):
var cell_index = get_cell_index(position)
if cell_index != null:
for i in range(-pheromone_cleaning_radius, pheromone_cleaning_radius):
for j in range(-pheromone_cleaning_radius, pheromone_cleaning_radius):
for i in range(-pheromone_cleaning_radius, pheromone_cleaning_radius + 1):
for j in range(-pheromone_cleaning_radius, pheromone_cleaning_radius + 1):
var y_index: int = cell_index[0] + i
var x_index: int = cell_index[1] + j
cells[y_index][x_index] = 0.0
Expand Down
3 changes: 2 additions & 1 deletion entities/todeskaefer.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,15 @@ shape = SubResource( 4 )

[node name="BiteArea" type="Area2D" parent="."]
collision_layer = 0
collision_mask = 19
collision_mask = 18

[node name="CollisionPolygon2D" type="CollisionPolygon2D" parent="BiteArea"]
position = Vector2( -0.351671, 0 )
scale = Vector2( 1.70334, 1 )
polygon = PoolVector2Array( -5, -12, -9, -21, 10, -21, 6, -12 )

[node name="SenseArea" type="Area2D" parent="."]
visible = false
collision_layer = 0
collision_mask = 19

Expand Down
17 changes: 9 additions & 8 deletions levels/game_logic.gd
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ extends Node2D
export var _player_mode = true
onready var _player = $AntMaster/player
onready var _camera = $camera

var _num_ants: int = 0

func set_player_mode(val: bool):
if _player:
Expand All @@ -15,7 +15,7 @@ func set_player_mode(val: bool):

func _ready():
set_player_mode(true)
_update_ant_no()
_init_ant_no()

func _process(delta):
if Input.is_action_just_pressed("pause_menu") && !get_tree().paused:
Expand Down Expand Up @@ -46,10 +46,10 @@ func hide_menu():
get_tree().paused = false


func _update_ant_no():
func _init_ant_no():
var ants = get_tree().get_nodes_in_group("ants")
var num_ants = len(ants)
$HUD/AntNo.text = str(num_ants)
_num_ants = len(ants)
$HUD/AntNo.text = str(_num_ants)


func _management_loop(_delta):
Expand All @@ -76,8 +76,9 @@ func _on_main_menu_Button_pressed() -> void:


func _on_AntMaster_ant_spawn() -> void:
_update_ant_no()

_num_ants += 1
$HUD/AntNo.text = str(_num_ants)

func _on_AntMaster_ant_dead() -> void:
_update_ant_no()
_num_ants -= 1
$HUD/AntNo.text = str(_num_ants)
59 changes: 53 additions & 6 deletions levels/production_levels/intro_level.tscn
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,14 @@ total_resources = 100.0
position = Vector2( 1072.26, 68.2646 )
total_resources = 100.0

[node name="coins27" parent="Items" instance=ExtResource( 1 )]
position = Vector2( 1120, 905 )
total_resources = 100.0

[node name="coins28" parent="Items" instance=ExtResource( 1 )]
position = Vector2( 1256, 913 )
total_resources = 100.0

[node name="coins16" parent="Items" instance=ExtResource( 1 )]
position = Vector2( 956.401, 105.895 )
total_resources = 100.0
Expand Down Expand Up @@ -235,7 +243,7 @@ position = Vector2( 1174.5, 897.202 )
position = Vector2( 1194.66, 900.031 )

[node name="enemy_npc_ant23" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1047.83, 914.293 )
position = Vector2( 228, 659 )

[node name="enemy_npc_ant24" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1219.3, 964.144 )
Expand All @@ -259,10 +267,10 @@ position = Vector2( 1222.46, 811.975 )
position = Vector2( 1278.7, 819.54 )

[node name="enemy_npc_ant31" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 978.883, 894.841 )
position = Vector2( 251, 665 )

[node name="enemy_npc_ant32" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 999.036, 897.669 )
position = Vector2( 278, 622 )

[node name="enemy_npc_ant33" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 942.821, 910.044 )
Expand All @@ -277,11 +285,29 @@ position = Vector2( 1147.88, 947.167 )
position = Vector2( 1212.04, 909.476 )

[node name="enemy_npc_ant37" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1176.98, 891.539 )
position = Vector2( 249, 597 )

[node name="enemy_npc_ant38" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1213.73, 743.455 )

[node name="enemy_npc_ant69" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1189, 778 )

[node name="enemy_npc_ant70" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1214, 703 )

[node name="enemy_npc_ant71" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1213, 671 )

[node name="enemy_npc_ant72" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1200, 635 )

[node name="enemy_npc_ant73" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1161, 598 )

[node name="enemy_npc_ant74" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1193, 593 )

[node name="enemy_npc_ant39" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1201.62, 955.652 )

Expand All @@ -304,7 +330,7 @@ position = Vector2( 1204.78, 803.483 )
position = Vector2( 1238.37, 790.755 )

[node name="enemy_npc_ant46" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 992.318, 897.669 )
position = Vector2( 194, 630 )

[node name="enemy_npc_ant47" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1196.05, 738.152 )
Expand Down Expand Up @@ -340,7 +366,28 @@ position = Vector2( 1226.55, 858.534 )
position = Vector2( 1246.7, 861.362 )

[node name="enemy_npc_ant58" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1151.79, 846.836 )
position = Vector2( 87, 690 )

[node name="enemy_npc_ant62" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 60, 697 )

[node name="enemy_npc_ant63" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 69, 766 )

[node name="enemy_npc_ant64" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 82, 790 )

[node name="enemy_npc_ant65" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 347, 861 )

[node name="enemy_npc_ant68" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 343, 918 )

[node name="enemy_npc_ant66" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 392, 859 )

[node name="enemy_npc_ant67" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 442, 860 )

[node name="enemy_npc_ant59" parent="EnemyAntMaster" instance=ExtResource( 15 )]
position = Vector2( 1218.21, 806.312 )
Expand Down

0 comments on commit af9fc8d

Please sign in to comment.