[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Receiving stack overflow when inheriting Sprite class



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 <tomeasterbrook98@xxxxxxxxx> 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.