Witam! Rozpoczynam przygodę z Pythonem więc jeszcze się uczę. Jak już napisałem w tytule (temacie) chcę w mojej grze zrobić automatyczny fullscreen i rozdzielczość.
import pgzrun
import pygame
WIDTH = 1920
HEIGHT = 1080
player = Actor('p1_front', (100, 964))
game = 0
frame = 0
jump = 0
jump_lock = 0
def draw():
global game
screen.clear()
screen.fill('#7dffeb')
for i in range((screen.width // 70) + 1):
screen.blit('grass', (i * 70, screen.height - 70))
player.draw()
if game == 0:
screen.draw.text(
"Press Space",
center=(screen.width / 2, screen.height / 2),
color='#b58c05',
fontsize = 60
)
def on_key_down(key):
if key == keys.F:
screen.surface = pygame.display.set_mode((WIDTH, HEIGHT), pygame.FULLSCREEN)
elif key == keys.O:
screen.surface = pygame.display.set_mode((WIDTH, HEIGHT))
def update():
global game
global jump
global jump_lock
if keyboard.SPACE:
if game == 0:
jump_lock = 1
clock.schedule_unique(lock_release, 0.3)
game = 1
if jump_lock ==0:
jump = -18
jump_lock = 1
player_animation()
jump_functionality()
def lock_release():
global jump_lock
jump_lock = 0
def jump_functionality():
global jump
global frame
if jump != 0:
frame = 0
player.y += jump
if player.y >= 964:
lock_release()
jump = 0
if player.y <= 730:
jump*=(-1)
def player_animation():
global frame
if game == 1:
if frame == 0:
player.image = 'p1_walk01'
elif frame == 1:
player.image = 'p1_walk02'
elif frame == 2:
player.image = 'p1_walk03'
elif frame == 3:
player.image = 'p1_walk04'
elif frame == 4:
player.image = 'p1_walk05'
elif frame == 5:
player.image = 'p1_walk06'
elif frame == 6:
player.image = 'p1_walk07'
elif frame == 7:
player.image = 'p1_walk08'
elif frame == 8:
player.image = 'p1_walk09'
elif frame == 9:
player.image = 'p1_walk10'
elif frame == 10:
player.image = 'p1_walk11'
frame += 1
frame %= 11
pgzrun.go()
Z góry dziękuje za pomoc.
P.S. Piszę w Pycharm.