Zuerst, ich hab das forum durchsucht und nichts gefunden
hier Fehlermeldung:
Code: Alles auswählen
C:\Python25\Pong>main.py
Traceback (most recent call last):
File "C:\Python25\Pong\Main.py", line 54, in <module>
main()
File "C:\Python25\Pong\Main.py", line 21, in main
ball = Ball(screen)
TypeError: 'module' object is not callable
Code: Alles auswählen
# -*- coding: UTF-8 -*-
import os, sys
import pygame
import Ball
import Leftplayer
import Rightplayer
from pygame.locals import *
from pygame.rect import *
def main():
#initalize
pygame.init()
screen = pygame.display.set_mode((800,600))
pygame.display.set_caption("Pong")
pygame.mouse.set_visible(1)
pygame.key.set_repeat(1, 30)
white = (255,255,255)
width = 5
#Create ball/players
ball = Ball(screen)
rightplayer = Rightplayer(screen)
leftplayer = Leftplayer(screen)
#show longer than one frame
clock = pygame.time.Clock()
running = 1
while running:
clock.tick(30)
screen.fill((0, 0, 0))
#Draw the playarea
playarea = pygame.draw.polygon(screen, white, [(10, 10), (790, 10), (790, 590), (10, 590)], 5 )
middlline = pygame.draw.line(screen, white, (400,10), (400,590), width)
middlline.inflate_ip(width,20)
ball.draw()
for event in pygame.event.get():
if event.type == QUIT:
running = 0
if event.type == KEYDOWN:
if event.key == K_ESCAPE:
pygame.event.post(pygame.event.Event(QUIT))
pygame.display.flip()
if __name__ == '__main__':
main()
Ball.py
#Ball
import os, sys
import Main
import pygame
class Ball:
def __init__(self,surface):
self.surface = surface
self.white = (255,255,255)
self.bwidth = 3
self.radius = 7
def draw(self):
pygame.draw.circle(surface, self.white, (400,250), self.radius, self.bwidth)
#def moveball(self):
#kommt noch
Leftplayer.py
#player left
import os, sys
import pygame
class Leftplayer:
def __init__(self,surface):
self.surface = surface
self.width = 6
def draw(self):
leftplayer = pygame.draw.line(screen, white, (150,25), (250,25), width)
leftplayer.inflate_ip(width,20)
Rightplayer.py
#player right
import os, sys
import pygame
class Rightplayer:
def __init__(self,surface):
self.surface = surface
self.width = 6
def draw(self):
rightplayer = pygame.draw.line(screen, white, (150,775), (250,775), width)
rightplayer.inflate_ip(width,20)