@eupshoria

Как отобразить платформы в Pygame?

Не могу понять в чем проблема,не отображаются платформы

код:
import pygame ,sys 
from tkinter import *

pygame.init()
screen_size=1366,768
win=pygame.display.set_mode((screen_size),pygame.FULLSCREEN)
pygame.display.set_caption("Платформер")

def make_level(level1, platform):
    x=0
    y=0
    for row in level_01:
        for col in row:
            if col=="-":
                win.blit(platform,(x,y))
            x+=40
        y+=40
        x=0
def drowWindow():
    global animCount
    x=0

    if animCount + 1 >= 72:
        animCount = 0

    if left:
        win.blit(walkLeft[animCount // 3], (positionX,positionY))
        animCount += 1
    elif right:
        win.blit(walkRight[animCount // 3], (positionX,positionY))
        animCount += 1
    elif isJump:
        win.blit(jumping[animCount //12], (positionX,positionY))
        animCount += 1
    elif  stand:
        win.blit(playerStand[animCount //4], (positionX,positionY))
        animCount += 1
    else:
        x=x+1

    pygame.display.update()

walkRight = [pygame.image.load('Sprite\Right\R1.png'),
            pygame.image.load('Sprite\Right\R2.png'),
            pygame.image.load('Sprite\Right\R3.png'),
            pygame.image.load('Sprite\Right\R4.png'),
            pygame.image.load('Sprite\Right\R5.png'),
            pygame.image.load('Sprite\Right\R6.png'),
            pygame.image.load('Sprite\Right\R7.png'),
            pygame.image.load('Sprite\Right\R8.png'),
            pygame.image.load('Sprite\Right\R9.png'),
            pygame.image.load('Sprite\Right\R10.png'),
            pygame.image.load('Sprite\Right\R11.png'),
            pygame.image.load('Sprite\Right\R12.png'),
            pygame.image.load('Sprite\Right\R13.png'),
            pygame.image.load('Sprite\Right\R14.png'),
            pygame.image.load('Sprite\Right\R15.png'),
            pygame.image.load('Sprite\Right\R16.png'),
            pygame.image.load('Sprite\Right\R17.png'),
            pygame.image.load('Sprite\Right\R18.png'),
            pygame.image.load('Sprite\Right\R19.png'),
            pygame.image.load('Sprite\Right\R20.png'),
            pygame.image.load('Sprite\Right\R21.png'),
            pygame.image.load('Sprite\Right\R22.png'),
            pygame.image.load('Sprite\Right\R23.png'),
            pygame.image.load('Sprite\Right\R24.png'),]
walkLeft = [pygame.image.load('Sprite\Left\L1.png'),
            pygame.image.load('Sprite\Left\L2.png'),
            pygame.image.load('Sprite\Left\L3.png'),
            pygame.image.load('Sprite\Left\L4.png'),
            pygame.image.load('Sprite\Left\L5.png'),
            pygame.image.load('Sprite\Left\L6.png'),
            pygame.image.load('Sprite\Left\L7.png'),
            pygame.image.load('Sprite\Left\L8.png'),
            pygame.image.load('Sprite\Left\L9.png'),
            pygame.image.load('Sprite\Left\L10.png'),
            pygame.image.load('Sprite\Left\L11.png'),
            pygame.image.load('Sprite\Left\L12.png'),
            pygame.image.load('Sprite\Left\L13.png'),
            pygame.image.load('Sprite\Left\L14.png'),
            pygame.image.load('Sprite\Left\L15.png'),
            pygame.image.load('Sprite\Left\L16.png'),
            pygame.image.load('Sprite\Left\L17.png'),
            pygame.image.load('Sprite\Left\L18.png'),
            pygame.image.load('Sprite\Left\L19.png'),
            pygame.image.load('Sprite\Left\L20.png'),
            pygame.image.load('Sprite\Left\L21.png'),
            pygame.image.load('Sprite\Left\L22.png'),
            pygame.image.load('Sprite\Left\L23.png'),
            pygame.image.load('Sprite\Left\L24.png'),]
jumping= [pygame.image.load('Sprite\Jump\J1.png'),
         pygame.image.load('Sprite\Jump\J2.png'),
         pygame.image.load('Sprite\Jump\J3.png'),
         pygame.image.load('Sprite\Jump\J4.png'),
         pygame.image.load('Sprite\Jump\J5.png'),
         pygame.image.load('Sprite\Jump\J6.png')]
playerStand = [pygame.image.load('Sprite\Stay\S1.png'),
         pygame.image.load('Sprite\Stay\S2.png'),
         pygame.image.load('Sprite\Stay\S3.png'),
         pygame.image.load('Sprite\Stay\S4.png'),
         pygame.image.load('Sprite\Stay\S5.png'),
         pygame.image.load('Sprite\Stay\S6.png'),
         pygame.image.load('Sprite\Stay\S7.png'),
         pygame.image.load('Sprite\Stay\S8.png'),
         pygame.image.load('Sprite\Stay\S9.png'),
         pygame.image.load('Sprite\Stay\S10.png'),
         pygame.image.load('Sprite\Stay\S11.png'),
         pygame.image.load('Sprite\Stay\S12.png'),
         pygame.image.load('Sprite\Stay\S13.png'),
         pygame.image.load('Sprite\Stay\S14.png'),
         pygame.image.load('Sprite\Stay\S15.png'),
         pygame.image.load('Sprite\Stay\S16.png'),
         pygame.image.load('Sprite\Stay\S17.png'),
         pygame.image.load('Sprite\Stay\S18.png')]
level_01=["                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "                   "
        "-------------------"]
pl=pygame.Surface((40,40))
pl.fill((210,120,60))
bg = pygame.image.load('Sprite\BG\BG1-1.png')

positionX=10
positionY=640
widht=30
height=30 
speed=5
jumpCount=10
animCount=0
animCountJaS=0

isJump=False
right=False
left=False
stand=True


clock= pygame.time.Clock()

exit=True

while exit:

    clock.tick(30)

    for event in pygame.event.get():   #Выход при нажатии Quit
        if event.type == pygame.QUIT:
            exit=False

    win.blit(bg,(0,0))

    keys=pygame.key.get_pressed()  #Создание списка кнопок для отслеживание нажатий
    if keys[pygame.K_LEFT] and positionX > -30:
        positionX-=speed
        left=True
        right=False
        stand=False
    elif keys[pygame.K_RIGHT] and positionX < 1366 - widht - 60:
        positionX+=speed
        left=False
        right=True
        stand=False
    elif  not(keys[pygame.K_RIGHT] and keys[pygame.K_LEFT] and keys[pygame.K_UP]):
        left=False
        right=False
        stand=True
        positionX = positionX
        positionY = positionY
    if not(isJump):
        if keys[pygame.K_UP] and positionY > 5:
            isJump=True
            stand=False
    else:
        if jumpCount >= -10:
            if jumpCount<0:
                positionY += (jumpCount ** 2)/2
            else:
                positionY -= (jumpCount ** 2)/2
            jumpCount -=1
            
        else:
           isJump=False
           jumpCount=10
           stand=False
    drowWindow()
    make_level(level_01,pl)
  • Вопрос задан
  • 33 просмотра
Пригласить эксперта
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы