forked from joshuakcockrell/color-tower-defense
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tower_range.py
executable file
·20 lines (16 loc) · 878 Bytes
/
tower_range.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import pygame
from snap_to_grid import *
##### Range circle #####
class Tower_Range(pygame.sprite.Sprite):
def __init__(self, location, tower_range):
pygame.sprite.Sprite.__init__(self, self.groups)
self.range = tower_range
self.image = pygame.Surface((self.range*2, self.range*2)) # create a box surface
self.image.fill((255, 255, 255)) # fill the image with RGB
self.image.set_colorkey(self.image.get_at((0, 0))) # make the white transparent
self.rect = self.image.get_rect()
self.rect.center = location # draw it at the location
pygame.draw.circle(self.image, (0, 200, 0), ((int(self.range),int(self.range))), int(self.range), 2) # draw the circle inside the box
def move(self, position):
grid_position = snap_to_grid(position)
self.rect.center = grid_position