-
Notifications
You must be signed in to change notification settings - Fork 0
/
supply.py
43 lines (39 loc) · 1.55 KB
/
supply.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
#-*- coding:utf-8 -*-
import pygame
from random import *
class Bullet_Supply(pygame.sprite.Sprite):
def __init__(self,bg_size):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("images/bullet_supply.png")
self.rect = self.image.get_rect()
self.width, self.height = bg_size[0],bg_size[1]
self.rect.left, self.rect.bottom = randint(0,self.width - self.rect.width), -100
self.speed = 5
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
if self.rect.top < self.height:
self.rect.top += self.speed
else:
self.active = False
def reset(self):
self.active = True
self.rect.left, self.rect.bottom = randint(0,self.width - self.rect.width), -100
class Bomb_Supply(pygame.sprite.Sprite):
def __init__(self,bg_size):
pygame.sprite.Sprite.__init__(self)
self.image = pygame.image.load("images/bomb_supply.png")
self.rect = self.image.get_rect()
self.width, self.height = bg_size[0],bg_size[1]
self.rect.left, self.rect.bottom = randint(0,self.width - self.rect.width), -100
self.speed = 5
self.active = False
self.mask = pygame.mask.from_surface(self.image)
def move(self):
if self.rect.top < self.height:
self.rect.top += self.speed
else:
self.active = False
def reset(self):
self.active = True
self.rect.left, self.rect.bottom = randint(0,self.width - self.rect.width), -100