-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathobstackles.py
36 lines (29 loc) · 1.07 KB
/
obstackles.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
33
34
35
36
"""This module contains Obstackles class"""
from obstackle import Obstackle
import pygame as pg
class Obstackles():
"""This the Obstackles class which manages list of obstacles"""
def __init__(self):
"""Constructor"""
self.obstackles = []
def draw(self):
"""Display obstackles"""
for obs in self.obstackles:
obs.draw()
def add_obstackle(self, x, y, w, h):
"""Add an obstackle"""
self.obstackles.append(Obstackle(x, y, w, h))
def add_standart_obstackles(self):
w, _ = pg.display.get_surface().get_size()
self.add_obstackle(0, 200, 170, 20)
self.add_obstackle(230, 200, w - 230, 20)
self.add_obstackle(0, 400, 320, 20)
self.add_obstackle(380, 400, w - 380, 20)
self.add_obstackle(0, 600, 470, 20)
self.add_obstackle(530, 600, w - 530, 20)
def contains(self, rocket):
"""Test if rocket is inside any of the obstackles"""
for obs in self.obstackles:
if obs.contains(rocket):
return True
return False