Лаги при отрисовке объекта на изображении в pygame на андроид

Столкнулся с проблемой, что при отрисовке персонажа(пока что это жёлтый прямоугольник) сильно лагает, может быть это я что то не так сделал, или это из за того, что пишу на андроид. Вот код:

import pygame as pg
import random as rd

pg.init()

f = pg.font.SysFont("dancingscript", 40)

w, h = 720, 1600
sc = pg.display.set_mode((w, h))

clock = pg.time.Clock()
fps = 60

bgColor = "lightblue"
mountain = pg.image.load("mountain.png")
mountainRect = mountain.get_rect(center = (w / 2, h - mountain.get_height() / 2))

jump = False
canJump = True
strengthOfJump = -33 // 5
strengthOfJumpS = strengthOfJump * (-1)
damage = 1

def createMob():
    global mob, mobpy, hp, kill, mobAlpha
    hp = 30
    mob = pg.Surface((200, 400))
    mobAlpha = 255
    mob.fill("yellow")
    mobpy = h / 2 + mob.get_height() / 2
    kill = False

createMob()

while 1:
    # Update sprites
    
    mobRect = mob.get_rect(center = (w / 2, mobpy))
    showHp = f.render("Health: %s" % (hp), 1, "red")
    showHpRect = showHp.get_rect(center = (mobRect.x + mob.get_width() / 2, mobRect.y - 50))
    
    # Check clicks
    
    px, py = pg.mouse.get_pos()[0], pg.mouse.get_pos()[1]
    
    for ev in pg.event.get():
        if ev.type == pg.MOUSEBUTTONDOWN:
            if canJump and mobRect.x <= px <= mobRect.x + mob.get_width() and mobRect.y <= py <= mobRect.y + mob.get_height():
                jump = True
                hp -= damage
    
    if jump:
        mobpy += strengthOfJump
        strengthOfJump += 1
        if strengthOfJump > strengthOfJumpS:
            jump = False
            strengthOfJump = strengthOfJumpS * (-1)
    if kill:
        canJump = False
        mob.set_alpha(mobAlpha)
        showHp.set_alpha(mobAlpha)
        mobAlpha -= 10
        if mobAlpha < 0:
            strengthOfJump = strengthOfJumpS * (-1)
            canJump = True
            jump = False
            createMob()
    
    if hp <= 0: kill = True
    
    # Render
    
    sc.fill(bgColor)
    sc.blit(mountain, mountainRect)
    pg.draw.rect(sc, "green", (0, h - 400, w, 400))
    sc.blit(mob, mobRect)
    sc.blit(showHp, showHpRect)
    
    # Update
    
    pg.display.update()
    
    clock.tick(fps)

Ответы (0 шт):