- 帖子
- 3
- 精华
- 0
- 积分
- 26
- 阅读权限
- 10
- 注册时间
- 2016-11-29
- 最后登录
- 2016-12-26
|
鼠标操控模式,但是这跟线太难看了……不知道有没方法弄得好看点
#-*-coding:utf-8-*-
import pygame
from sys import exit
pygame.init()
screen=pygame.display.set_mode((450,800),0,32)
pygame.display.set_caption("Plane")
background=pygame.image.load(r"C:\pythonexam\game\image\background.jpg").convert()
plane=pygame.image.load(r"C:\pythonexam\game\image\plane.png").convert_alpha()
bullet=pygame.image.load(r"C:\pythonexam\game\image\bullet.png").convert_alpha()
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()
x_plane=x-plane.get_width()/2
y_plane=y-plane.get_height()/2
y_value=y
x_bullet=x-bullet.get_width()/2
y_bullet=y-plane.get_height()/2
screen.blit(plane,(x_plane,y_plane))
if event.type==pygame.MOUSEBUTTONDOWN:
for i in range(y_value):
if y_bullet<0:
y_bullet=y-bullet.get_width()/2
if y_bullet>0:
y_bullet-=1
screen.blit(bullet,(x_bullet,y_bullet))
pygame.display.update()
pygame.display.update()
|
|