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.
__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()
Attachment:
error.PNG
Description: PNG image
Attachment:
loop.PNG
Description: PNG image