我在 python 中工作,试图制作一个游戏,但我不断收到一个错误,我不明白在我的特定上下文中的解决方案。
我的错误如下:TypeError: unsupported operation types(s) for -=: 'CreateEnemy' and 'int'
错误发生在这一行:
if Player.x < Missle.x:
Missle.x -= Espeed
Run Code Online (Sandbox Code Playgroud)
如果有助于提供更多详细信息,我将粘贴以下文件的其余部分:
#!/usr/bin/env python
# Import the pygame library and initialise the game engine
import pygame
import sys
import math
pygame.init()
# Open a new window
WinSize = [1000, 900]
size = (WinSize[0], WinSize[1])
screen = pygame.display.set_mode(size)
pygame.display.set_caption("Space Adventures")
# Global Variables
FPS = 30
Speed = 30
Espeed = 5
class CreatePlayer(pygame.sprite.Sprite):
def __init__(self):
pygame.sprite.Sprite.__init__(self)
self.x = 30
self.y = …Run Code Online (Sandbox Code Playgroud)