-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbombs.py
72 lines (52 loc) · 1.67 KB
/
bombs.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Copyright (c) 2013 by Joel Odom & Alex Odom, Marietta, GA All Rights Reserved
import pygame
import colors
import sounds
class Bomb:
exploded = False
def play_sound(self):
self.SOUND.play()
def draw(self, surface): # note that x and y must be bound
pygame.draw.rect(surface, colors.SOLID_RED,
(self.constants.CELL_WIDTH*self.x + self.constants.WALL_WIDTH,
self.constants.CELL_HEIGHT*self.y + self.constants.WALL_WIDTH,
self.constants.CELL_WIDTH - 2*self.constants.WALL_WIDTH,
self.constants.CELL_HEIGHT - 2*self.constants.WALL_WIDTH), 0)
class CherryBomb(Bomb):
NAME = 'Cherry Bomb'
DESCRIPTION = 'Don\'t blow off your finger.'
BLAST_RADIUS = 1
MIN_LEVEL = 1
time_remaining = 3
def __init__(self, constants):
self.SOUND = sounds.DYNAMITE_SOUND # TODO
self.constants = constants
class Dynamite(Bomb):
NAME = 'Dynamite'
DESCRIPTION = 'Fire in the hole!'
BLAST_RADIUS = 3
MIN_LEVEL = 7
time_remaining = 5
def __init__(self, constants):
self.SOUND = sounds.DYNAMITE_SOUND
self.constants = constants
class AtomBomb(Bomb):
NAME = 'Atom Bomb'
DESCRIPTION = 'I am become Death, the destroyer of worlds.'
BLAST_RADIUS = 10
MIN_LEVEL = 20
time_remaining = 20
def __init__(self, constants):
self.SOUND = sounds.ATOM_BOMB_SOUND
self.constants = constants
def list_bombs(constants):
return (CherryBomb(constants), (Dynamite(constants)), (AtomBomb(constants)))
#
# TESTS
#
def test_list_bombs(constants):
for bomb in list_bombs(constants):
assert bomb.BLAST_RADIUS > 0, 'missing BLAST_RADIUS'
assert len(bomb.NAME) > 0, 'missing NAME'
def run_tests(constants):
test_list_bombs(constants)