import pgzrun, random, time
WIDTH=800
HEIGHT=600
TITLE='Крутая игра'
plr_w=plr_h=50
plr_x=WIDTH//2
plr_y=HEIGHT//2
player=Rect(plr_x,plr_y,plr_w,plr_h)
jump_counter=0
jump_speed=10
jump_height=100//jump_speed
game_active=True
enemy_w=enemy_h=50
enemy_speed=7
enemies=[]
pause=2.0
begin=time.time()
platform=Rect(0,plr_y+player.height//2,WIDTH,5)
def create_enemy():
x=WIDTH
y=platform.y-enemy_h//2
enemy=Actor('spike-up.png',(x,y))
enemies.append(enemy)
def draw():
screen.fill('green')
screen.draw.filled_rect(player,'white')
def update():
global jump_speed,jump_height,jump_counter
if not game_active:
return
if 0<jump_counter<jump_height or (keyboard.space and player.y==plr_y):
player.y -= jump_speed
jump_counter+=1
elif jump_counter>jump_height:
jump_counter=0
elif player.y<plr_y:
player.y+=jump_speed
pgzrun.go()