| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #-*- coding: UTF-8 -*-
- import tkinter
- import pygame
- import os
- import sys
- import time
- import abc
- class FlyingObject(object):
- def __init__(self,screen,x,y,image):
- self.screen = screen
- self.x = x
- self.y = y
- self.width = image.get_rect()[2]
- self.height = image.get_rect()[3]
- self.image = image
- @abc.abstractmethod
- def outOfBounds(self):
- pass
- @abc.abstractmethod
- def step(self):
- pass
- def shootBy(self,bullet):
- x1 = self.x
- x2 = self.x + self.width
- y1 = self.y
- y2 = self.y + self.height
- x = bullet.x
- y = bullet.y
- return x>x1 and x<x2 and y>y1 and y<y2
- def blitme(self):
- self.screen.blit(self.image,(self.x,self.y))
|