Skip to content

Commit

Permalink
refactor2
Browse files Browse the repository at this point in the history
  • Loading branch information
Numenter committed Jun 15, 2022
1 parent 5759870 commit bfeb592
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions game/games/asecondguy_connect/connect.gd
Original file line number Diff line number Diff line change
Expand Up @@ -71,18 +71,13 @@ func _spawn_chip(player_id := 0):


func _update_end_condition():
if _end_condition_line_checker(_last_chip, Vector2(-1, 0), Vector2(1, 0)) == 4: # vertical
if (
_end_condition_line_checker(_last_chip, Vector2(-1, 0), Vector2(1, 0)) == 4 # vertical
or _end_condition_line_checker(_last_chip, Vector2(0, -1), Vector2(0, 1)) == 4 # horizontal
or _end_condition_line_checker(_last_chip, Vector2(-1, -1), Vector2(1, 1)) == 4 # diagonal_plus
or _end_condition_line_checker(_last_chip, Vector2(-1, 1), Vector2(1, -1)) == 4
): # diagonal_minus
_end_condition = _last_chip.player_id + 1
return
if _end_condition_line_checker(_last_chip, Vector2(0, -1), Vector2(0, 1)) == 4: # horizontal
_end_condition = _last_chip.player_id + 1
return
if _end_condition_line_checker(_last_chip, Vector2(-1, -1), Vector2(1, 1)) == 4: # diagonal_plus
_end_condition = _last_chip.player_id + 1
return
if _end_condition_line_checker(_last_chip, Vector2(-1, 1), Vector2(1, -1)) == 4: # diagonal_minus
_end_condition = _last_chip.player_id + 1
return


func _end_condition_line_checker(chip: RigidBody2D, left_dir: Vector2, right_dir: Vector2):
Expand Down

0 comments on commit bfeb592

Please sign in to comment.