中途岛海战玩家子弹类测试程序

"""
   玩家的子弹类,子弹从飞机的坐标出发不断地向上移动,
   如果接到了散射道具,那么就能发散射子弹,即两边都能发子弹。
   
"""
__author__ = '李兴球'
__date__ = '2019/8/30'

import pygame
from pygame.locals import *

class Player_Bullet(pygame.sprite.Sprite):
    """
      玩家飞机的子弹类
    """
    def __init__(self,image,pos,speed,screen):
        """
          image:图形,pos:起始坐标,speed:速度向量,screen:所在屏幕
        """
        pygame.sprite.Sprite.__init__(self)
        self.image = image
        self.rect = self.image.get_rect(center=pos)
        self.dx,self.dy = speed
        self.screen_rect = screen.get_rect()
        
    def update(self):
        self.rect.move_ip(self.dx,self.dy)
        if not self.screen_rect.contains(self.rect):
            self.kill()
            
def main():

    width,height = 960,720
    
    shot_image = pygame.image.load('images/Shot 1.png')
    shot_image_rightup = pygame.transform.rotate(shot_image,45)
    shot_image_up = pygame.transform.rotate(shot_image,90)
    shot_image_leftup = pygame.transform.rotate(shot_image,135)
    scatter_bullet_amounts = 100           # 初始有1千发散射子弹
    frames = 0               # 帧计数器
    shoot_interval = 60      # 子弹发射击的帧间隔
    pos = (width//2,height-100)

    screen = pygame.display.set_mode((width,height))
    pygame.display.set_caption('中途岛海战玩家子弹类测试程序by李兴球')
   

You must log in to read the rest of this article. Please log in or register as a user.