Pygame नहीं blitting छवि,बजाय बाहर थूकना प्रकार की त्रुटि

0

सवाल

तो मैं देख रहा था इस ट्यूटोरियल के बारे में ऑनलाइन pygame के रूप में मैं बहुत नया करने के लिए pygame. तो क्या वह किया गया था एक खिलाड़ी बनाने के लिए() समारोह और फिर blit । तो मैं था ही । उसके लिए, वह यह पूरी तरह से blitted, लेकिन मेरे लिए, मैं एक प्रकार की त्रुटि. केवल एक चीज के बीच अलग अपने कोड और खान के आयाम खिड़की और खिलाड़ी वर्ग और रंग. मैं करने की कोशिश की खोज में यहाँ यह अतिप्रवाह हो चुकी है, लेकिन केवल प्रासंगिक सवाल अनुत्तरित था. नहीं यकीन है कि क्या गलत हो गया था.

पूर्ण त्रुटि:

/home/Command Blocks/Desktop/venv/bin/python "/home/CommandBlocks/Desktop/CLASS_/Studies/Computer/python/practice/space shooter/main.py"
pygame 2.0.2 (SDL 2.0.16, Python 3.9.5)
Hello from the pygame community. https://www.pygame.org/contribute.html
Traceback (most recent call last):
  File "/home/Command Blocks/Desktop/CLASS_/Studies/Computer/python/practice/space shooter/main.py", line 33, in <module>
    player()
  File "/home/Command Blocks/Desktop/CLASS_/Studies/Computer/python/practice/space shooter/main.py", line 20, in player
    screen.blit(player, (playerX, playerY))
TypeError: argument 1 must be pygame.Surface, not function

Process finished with exit code 1

पूरा कोड:

import pygame

#Initialize pygame module
pygame.init()

#Create Screen
screen = pygame.display.set_mode((1000, 600))

#Title and Icon
pygame.display.set_caption("Jungle Invader")
icon = pygame.image.load('fox-sitting.png')
pygame.display.set_icon(icon)

# Player
player = pygame.image.load('cat.png')
playerX = 300
playerY = 500

def player():
    screen.blit(player, (playerX, playerY))


#Main loop
running = True
while running:
    pygame.display.update()

    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            running = False

    screen.fill((244, 232, 255))
    player()
pygame python python-3.x
2021-11-23 13:55:58
1

सबसे अच्छा जवाब

0

आप का इस्तेमाल किया है नाम खिलाड़ी दो बार. यह सतह से लौटे pygame.image.load('cat.png') और समारोह है कि blits स्क्रीन करने के लिए. का नाम बदलें player समारोह के लिए drawPlayer

2021-12-22 18:50:39

अन्य भाषाओं में

यह पृष्ठ अन्य भाषाओं में है

Русский
..................................................................................................................
Italiano
..................................................................................................................
Polski
..................................................................................................................
Română
..................................................................................................................
한국어
..................................................................................................................
Français
..................................................................................................................
Türk
..................................................................................................................
Česk
..................................................................................................................
Português
..................................................................................................................
ไทย
..................................................................................................................
中文
..................................................................................................................
Español
..................................................................................................................
Slovenský
..................................................................................................................

इस श्रेणी में लोकप्रिय

लोकप्रिय सवाल इस श्रेणी में