forked from luizgiacomossi/Search_Drone_Swarms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
obstacle.py
32 lines (25 loc) · 956 Bytes
/
obstacle.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import random
import pygame as pg
from utils import Tree
vec2 = pg.math.Vector2
random.seed(3)
class Obstacles(object):
def __init__(self, num_of_obstacles, map_size):
super().__init__()
self.num_of_obstacles = num_of_obstacles
self.map_size = map_size
self.obst = []
# Variables to draw tree using Sprites
self.tree = Tree()
self.all_sprites = pg.sprite.Group()
self.all_sprites.add(self.tree)
def generate_obstacles(self):
self.obst = []
for _ in range(self.num_of_obstacles):
self.obst.append(vec2(random.uniform(0,self.map_size[0]),
random.uniform(100,self.map_size[1])))
def get_coordenates(self):
return self.obst
def draw(self):
self.all_sprites.draw(self.window)
self.all_sprites.update(self.location,self.rotation)