# -*- coding: utf8 -*-
background_image_filename = 'background.png'
mouse_image_filename = 'hero.png'
#指定图像文件名称
import pygame #导入pygame库
from sys import exit #向sys模块借一个exit函数用来退出程序
pygame.init() #初始化pygame,为使用硬件做准备
screen = pygame.display.set_mode((480, 650), 0, 32)
#创建了一个窗口
pygame.display.set_caption("PlaneFight!")
#设置窗口标题
background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).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-= mouse_cursor.get_width() / 2
y-= mouse_cursor.get_height() / 2
#计算光标的左上角位置
screen.blit(mouse_cursor, (x, y))
#把光标画上去
pygame.display.update()
#刷新一下画面
# -*- coding: utf8 -*-
background_image_filename = 'background.png'
mouse_image_filename = 'hero.png'
bullet_image_filename = 'bullet.png'
#指定图像文件名称
import pygame #导入pygame库
from sys import exit #向sys模块借一个exit函数用来退出程序
pygame.init() #初始化pygame,为使用硬件做准备
screen = pygame.display.set_mode((480, 650), 0, 32)
#创建了一个窗口
pygame.display.set_caption("PlaneFight!")
#设置窗口标题
pygame.mouse.set_visible(False)
background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()
bullet = pygame.image.load(bullet_image_filename).convert_alpha()
#加载并转换图像
bullet_x, bullet_y = 0, -100 #初始化子弹坐标
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 < -1 : #移动子弹
bullet_x, bullet_y = x, y
else:
bullet_y -= 1
x-= mouse_cursor.get_width() / 2
y-= mouse_cursor.get_height() / 2
#计算光标的左上角位置
screen.blit(bullet, (bullet_x, bullet_y))
screen.blit(mouse_cursor, (x, y))
#把光标画上去
pygame.display.update()
#刷新一下画面
# -*- coding: utf8 -*-
background_image_filename = 'background.png'
mouse_image_filename = 'hero.png'
bullet_image_filename = 'bullet.png'
#指定图像文件名称
import pygame #导入pygame库
from sys import exit #向sys模块借一个exit函数用来退出程序
pygame.init() #初始化pygame,为使用硬件做准备
screen = pygame.display.set_mode((480, 650), 0, 32)
#创建了一个窗口
pygame.display.set_caption("PlaneFight!")
#设置窗口标题
pygame.mouse.set_visible(False)
background = pygame.image.load(background_image_filename).convert()
mouse_cursor = pygame.image.load(mouse_image_filename).convert_alpha()
bullet = pygame.image.load(bullet_image_filename).convert_alpha()
#加载并转换图像
bullet_x, bullet_y = 0, -100 #初始化子弹坐标
bullet_speed = 600 #初始化子弹速度
clock = pygame.time.Clock()
while True:
#游戏主循环
for event in pygame.event.get():
if event.type == pygame.QUIT:
#接收到退出事件后退出程序
pygame.quit()
exit()
time_passed = clock.tick(100)
time_passed_second = time_passed/1000.0
screen.blit(background, (0,0))
#将背景图画上去
x, y = pygame.mouse.get_pos()
#获得鼠标位置
if bullet_y < -1 : #移动子弹
bullet_x, bullet_y = x, y
else:
bullet_y -= time_passed_second * bullet_speed
x-= mouse_cursor.get_width() / 2
y-= mouse_cursor.get_height() / 2
#计算光标的左上角位置
screen.blit(bullet, (bullet_x, bullet_y))
screen.blit(mouse_cursor, (x, y))
#把光标画上去
pygame.display.update()
#刷新一下画面
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有