Не могу создать apk игры на pygame
вот код игры если нужно:
import pygame
from time import sleep
pygame.init()
screen = pygame.display.set_mode((618, 359))
ghosts = []
bullets = []
image_path = "data/data/com.develooper.first_pygame/files/app/"
icon = pygame.image.load(image_path + "images/icon.png").convert_alpha()
bg = pygame.image.load(image_path + "images/bg.png").convert_alpha()
ghost = pygame.image.load(image_path + "images/ghost.png").convert_alpha()
bullet = pygame.image.load(image_path + "images/bullet.png").convert_alpha()
front = (pygame.image.load(image_path + "images/spritesheet/spritesheet_f1.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_f2.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_f3.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_f4.png").convert_alpha())
back = (pygame.image.load(image_path + "images/spritesheet/spritesheet_b1.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_b2.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_b3.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_b4.png").convert_alpha())
left = (pygame.image.load(image_path + "images/spritesheet/spritesheet_l1.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_l2.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_l3.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_l4.png").convert_alpha())
right = (pygame.image.load(image_path + "images/spritesheet/spritesheet_r1.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_r2.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_r3.png").convert_alpha(),
pygame.image.load(image_path + "images/spritesheet/spritesheet_r4.png").convert_alpha())
clock = pygame.time.Clock()
anim_count, bg_x = 0, 0
p_x, p_y = 150, 250
backk, is_jump = False, False
p_speed, jump_count, bullets_left = 5, 8, 5
gameplay = True
label = pygame.font.Font(image_path + "fonts/Roboto/Roboto-Black.ttf", 40)
lose = label.render("Вы проиграли", False, (193, 196, 199))
restart = label.render("Играть снова", False, (115, 132, 168))
restart_rect = restart.get_rect(topleft=(180, 200))
ghost_timer = pygame.USEREVENT + 1
pygame.time.set_timer(ghost_timer, 2500)
pygame.display.set_caption("Игра на pygame")
pygame.display.set_icon(icon)
bg_sound = pygame.mixer.Sound(image_path + "sounds/Windows Critical Stop.mp3")
running = True
while running:
screen.blit(bg, (bg_x, 0))
screen.blit(bg, (bg_x + 618, 0))
if gameplay:
p_rect = left[0].get_rect(topleft=(p_x, p_y))
if ghosts:
for ghost_cord in ghosts:
screen.blit(ghost, ghost_cord)
ghost_cord.x -= 10
if p_rect.colliderect(ghost_cord):
print("you lose")
sleep(1)
gameplay = False
bg_sound.play()
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT] and p_x > 50 or keys[pygame.K_a] and p_x > 50:
p_x -= p_speed
screen.blit(left[anim_count], (p_x, p_y))
elif keys[pygame.K_RIGHT] and p_x < 200 or keys[pygame.K_d] and p_x < 200:
p_x += p_speed
screen.blit(right[anim_count], (p_x, p_y))
elif keys[pygame.K_DOWN] or keys[pygame.K_s]:
backk = True
else:
if backk:
screen.blit(back[anim_count], (p_x, p_y))
else:
screen.blit(front[0], (p_x, p_y))
if not is_jump:
if keys[pygame.K_SPACE] or keys[pygame.K_UP] or keys[pygame.K_w]:
is_jump = True
else:
if jump_count >= -8:
if jump_count > 0:
p_y -= (jump_count ** 2) / 2
else:
p_y += (jump_count ** 2) / 2
jump_count -= 1
else:
is_jump = False
backk = False
jump_count = 8
if anim_count == 3:
anim_count = 0
else:
anim_count += 1
bg_x -= 2
if bg_x == -618:
bg_x = 0
if bullets:
for bullet_rect in bullets:
screen.blit(bullet, (bullet_rect.x, bullet_rect.y))
bullet_rect.x += 4
if bullet_rect.x > 630:
bullets.remove(bullet_rect)
if ghosts:
for ghost_rect in ghosts:
if bullet_rect.colliderect(ghost_rect):
ghosts.remove(ghost_rect)
bullets.remove(bullet_rect)
else:
screen.fill("red")
screen.blit(lose, (180, 100))
screen.blit(restart, restart_rect)
mouse = pygame.mouse.get_pos()
if restart_rect.collidepoint(mouse) and pygame.mouse.get_pressed()[0]:
gameplay = True
p_x = 150
ghosts.clear()
bullets.clear()
bullets_left = 5
pygame.display.update()
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
elif event.type == ghost_timer:
ghosts.append(ghost.get_rect(topleft=(620, 250)))
elif event.type == pygame.KEYUP:
if gameplay and event.key == pygame.K_SLASH and bullets_left != 0:
bullets.append(bullet.get_rect(topleft=(p_x + 30, p_y + 10)))
bullets_left -= 1
clock.tick(10)
файл buildozer.spec в репозитории там же и вывод buildoer в терминал (не написал здесь, потому что слишком большой): https://github.com/Daniil1235/test-game