Take the call out;
__author__ = 'User'
import pygame
class Box(pygame.sprite.Sprite):
def __init__(self,scn):
pygame.sprite.Sprite.__init__(self)
self.scn = scn
self.image =pygame.image.load('assets\cube.png').convert_alpha()
self.rect = self.image.get_rect()
self.rect.left = scn.width / 2 - self.rect.width/2
self.rect.top= scn.height /2 - self.rect.hight /2
self.speed = 4
self.scn.box_group.add(self)
def event_received(self):
if self.scn.key_pressed == 'left':
if self.rect.left >0:
self.rect.left -=self.speed
elif self.scn.key_pressed == 'right':
if self.rect.right<self.scn.width:
self.rect.left += self.speed
elif self.scn.key_pressed == 'up':
if self.rect.top> 0:
self.rect.top -= self.speed
elif self.scn.key_pressed == 'down':
if self.rect.bottom < self.scn.height:
self.rect.top +=self.speed
def update(self):
self.event_received()
On Mon, Oct 12, 2015 at 5:00 PM, Tom Easterbrook <[email protected]
> wrote:
> Hey everybody,
>
> I am currently having an error in the latest build where inheriting the
> Sprite class Causes a stack overflow error as pictured below:
>
> I have narrowed this error down to the Loop in the Sprite class Which is
> present between lines 136 to 140. I've included an image of the Loop for
> reference
>
> Finally I have included a copy of my Class In case that helps anybody
>
> Any help Would be appreciated!
>
> --
> Regards,
>
> Tom Easterbrook
>
> This email and any attachments to it may be confidential and are intended
> solely for the use of the individual to whom it is addressed. Any views or
> opinions expressed are solely those of the author and do not necessarily
> represent those of any other person or organisation
>
> If you are not the intended recipient of this email, you must neither take
> any action based upon its contents, nor copy or show it to anyone.
>
> Please contact the sender if you believe you have received this email in
> error.
>