- 帖子
- 15
- 精华
- 0
- 积分
- 114
- 阅读权限
- 20
- 注册时间
- 2016-8-8
- 最后登录
- 2016-10-22
|
改了下子弹的X坐标,变成散弹了- # -*- coding: utf-8 -*-
- import pygame
- from sys import exit
- pygame.init()
- screen = pygame.display.set_mode((450, 800), 0, 32)
- pygame.display.set_caption("Hello, World!")
- background = pygame.image.load('back.jpg').convert()
- plane = pygame.image.load('plane.png').convert_alpha()
- bullet=pygame.image.load('bullet.png').convert_alpha()
- bullet1=bullet
- bullet2=bullet
- bullet_x=0
- bullet_y=-1
- bullet1_x=0
- bullet1_y=0
- bullet2_x=0
- bullet2_y=0
- while True:
- for event in pygame.event.get():
- if event.type == pygame.QUIT:
- pygame.quit()
- exit()
- screen.blit(background, (0,0))
- x, y = pygame.mouse.get_pos()
- if bullet_y<0:
- bullet_x=x-bullet.get_width()/2
- bullet_y=y-bullet.get_height()/2
- bullet1_x=x-bullet.get_width()/2-23
- bullet1_y=y-bullet.get_height()/2
- bullet2_x=x-bullet.get_width()/2+23
- bullet2_y=y-bullet.get_height()/2
- else:
- bullet_y-=2
- bullet1_y-=2
- bullet1_x-=0.5
- bullet2_y-=2
- bullet2_x+=0.5
- screen.blit(bullet,(bullet_x,bullet_y))
- screen.blit(bullet1,(bullet1_x,bullet1_y))
- screen.blit(bullet2,(bullet2_x,bullet2_y))
- x-= plane.get_width() / 2
- y-= plane.get_height() / 2
- #print (x,y,bullet_x,bullet_y)
- screen.blit(plane, (x,y))
- pygame.display.update()
复制代码 |
|