All i wanna do at this point is to test the (soon to be) game and see that the correct sprites are were they are supposed to be.
When i run the game the background is black instead of the green color of my field.png, no other sprites are visible and after a while i get a Runtime error and the game crashes.
Any ideas?
When i run the game the background is black instead of the green color of my field.png, no other sprites are visible and after a while i get a Runtime error and the game crashes.
Any ideas?
Code:
import pygame, math, sys
from pygame.locals import *
from livewires import games
# FPS
clock = pygame.time.Clock()
FRAMES_PER_SECOND = 30
deltat = clock.tick(FRAMES_PER_SECOND)
class Endzone(pygame.sprite.Sprite):
endzone_no_td = pygame.image.load('endzone.png')
endzone_td = pygame.image.load('endzone_td.png')
def __init__(self, position):
pygame.sprite.Sprite.__init__(self)
self.rect = pygame.Rect(self.endzone_no_td.get_rect())
self.rect.center = position
class Player(pygame.sprite.Sprite):
player_image = pygame.image.load('49er.gif')
def __init__(self,position,team,pos_in_team):
if team == 'offense':
player_image = pygame.image.load('49er.gif')
else:
player_image = pygame.image.load('defense.gif')
""" if pos_in_team... """
pygame.sprite.Sprite.__init__(self)
self.rect = pygame.Rect(self.player_image.get_rect())
self.rect.center = position
def game():
my_screen = games.Screen (width=1024, height=768)
bg = games.load_image("field.png")
my_screen.set_background(bg)
def_safety = Player((400,400),'defense','safety')
off_tight_end = Player((500,500),'offense','tigth_end')
my_screen.mainloop()
game()
Comment