import pygame
pygame.init()
#Окно и название окна
win = pygame.display.set_mode((1000, 700))
pygame.display.set_caption('"Pug Racing" by Said')
#Изображения
Jumping = pygame.image.load('Pug_2.png')
Standing = pygame.image.load('Pug_1.png')
bg = pygame.image.load('фон.jpg')
#Кадры
clock = pygame.time.Clock()
#Расположение мопса
x = 300
y = 315
#Характеристики мопса
widht = 128
heidht = 128
speed = 10
#Характеристики прыжка
Jump = False
JumpCount = 10
#Покраска окна
def draw_window():
win.blit(bg, (0,0))
pygame.display.update()
if Jump:
win.blit(Jumping, (x,y))
else:
win.blit(Standing, (x,y))
#Процесс игры
run_game = True
while run_game:
#Обновление событий
clock.tick(60)
#Перебираем события
for event in pygame.event.get():
if event.type == pygame.QUIT:
run_game = False
#Управление
keys = pygame.key.get_pressed()
if not Jump:
Stand = True
if keys[pygame.K_SPACE]:
Stand = False
Jump = True
else:
if JumpCount >= -10:
if JumpCount < 0:
y += (JumpCount **2) / 3
else:
y -= (JumpCount **2) / 3
JumpCount -= 1
else:
Jump = False
JumpCount = 10
draw_window()
pygame.quit()
Добавить комментарий
|
1 ответ
Попробуйте так:
import pygame
pygame.init()
#Окно и название окна
win = pygame.display.set_mode((1000, 600))
pygame.display.set_caption('"Pug Racing" by Said')
#Изображения
Jumping = pygame.image.load('Ok.png')
Standing = pygame.image.load('on.png')
bg = pygame.image.load('lena.jpg')
#Кадры
clock = pygame.time.Clock()
#Расположение мопса
x = 300
y = 315
#Характеристики мопса
widht = 128
heidht = 128
speed = 10
#Характеристики прыжка
Jump = False # True
JumpCount = 10
#Покраска окна
def draw_window():
win.blit(bg, (0, 0))
# pygame.display.update() # ---
if Jump:
win.blit(Jumping, (x, y))
else:
win.blit(Standing, (x, y))
pygame.display.update() # +++
#Процесс игры
run_game = True
while run_game:
#Обновление событий
clock.tick(60)
#Перебираем события
for event in pygame.event.get():
if event.type == pygame.QUIT:
run_game = False
#Управление
keys = pygame.key.get_pressed()
if not Jump:
Stand = True
if keys[pygame.K_SPACE]:
Stand = False
Jump = True
else:
if JumpCount >= -10:
if JumpCount < 0:
y += (JumpCount **2) / 3
else:
y -= (JumpCount **2) / 3
JumpCount -= 1
else:
Jump = False
JumpCount = 10
draw_window()
pygame.quit()