Commit 2b19f7f5 by BellCodeEditor

auto save

parent 4d8b6805
Showing with 79 additions and 8 deletions
# 古代测量臂力是靠不同重量的石锁,只能测整数哦。
# 最小的石锁是30公斤最大的石锁是100公斤,注意输入的数字哦。
# 请优化刚刚的代码,并增添交互效果,和自动输出最强三人信息的功能~
import pygame
from pygame import locals
# 问询处
pygame.init()
screen = pygame.display.set_mode((600,400))
FPS = pygame.time.Clock()
# 归档处
hero=['赵一',30,'丁二',37,'孙五',52,'王猛',89,'周亮',98,'张宇',100]
for i in range(len(hero)):
background = pygame.image.load('bg.png')
hero1 = pygame.image.load('1.png')
hero2 = pygame.image.load('2.png')
hero3 = pygame.image.load('3.png')
hero4 = pygame.image.load('4.png')
hero5 = pygame.image.load('5.png')
jumpState = False
y = 300
x = 10
hero = [hero1,hero2,hero3,hero4,hero5]
index = 0
while True:
for event in pygame.event.get():
if event.tyep == locals.QUIT:
# 打印出臂力最强的三个人和他们对应的臂力值:
exit()
if event.type == locals.KEYDOWN:
if jumpState == False
if event.key == locals.K_SPACE:
jumpState = True
if jumpState == True:
if t >= -10
a = 1
if t < 0:
a = -1
y -= 0.5*a*(t**2)
t-=1
else:
jumpState = False
t = 10
wukong = hero[index]
index += 1
if index == 5:
index = 0
screen.blit(background,(0,0))
screen.blit(wukong,(200,y)
pygame.display.update()
FPS.tick(60)
\ No newline at end of file
import pygame
import random
class Block(pygame.sprite.Sprite):
def __init__(self,image):
super().__init__()
self.image = image
self.rect = self.image.get_rect()
self.rect.x = 1000
self.rect.y = 500 - self.rect.heig
stong = pygame.image.load('stone.png')
cacti = pygame.image.load('cacti.png')
bush = pygame.image.load('bush.png')
imp = random.choice([stone,cacti,bush])
\ No newline at end of file
import pygame
from pygame import locals
screen = pygame.display.set_mode((1000,600))
pygame.display.set_caption("python")
while True:
for event in pygame.event.get():
if event.type == locals.QUIT:
exit()
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment