Skip to content

Commit

Permalink
Add unit tests for line of sight
Browse files Browse the repository at this point in the history
  • Loading branch information
pvcraven committed Apr 17, 2020
1 parent 2bd155b commit 66b4db9
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/unit2/test_line_of_sight.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import arcade

def test_line_of_sight():
player = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png")
player.center_x = 50
player.center_y = 350

enemy = arcade.Sprite(":resources:images/animated_characters/female_person/femalePerson_idle.png")
enemy.center_x = 150
enemy.center_y = 350

wall_list = arcade.SpriteList(use_spatial_hash=True)

result = arcade.has_line_of_sight(player.position, enemy.position, wall_list)
assert result

result = arcade.has_line_of_sight(player.position, enemy.position, wall_list, 2000)
assert result

result = arcade.has_line_of_sight(player.position, enemy.position, wall_list, 20)
assert not result

wall = arcade.Sprite(":resources:images/tiles/grassCenter.png")
wall.center_x = 0
wall.center_y = 0
wall_list.append(wall)

result = arcade.has_line_of_sight(player.position, enemy.position, wall_list)
assert result

wall.center_x = 100
wall.center_y = 350

result = arcade.has_line_of_sight(player.position, enemy.position, wall_list)
assert not result

wall.center_x = 100
wall.center_y = 450

result = arcade.has_line_of_sight(player.position, enemy.position, wall_list)
assert result

0 comments on commit 66b4db9

Please sign in to comment.