Esempio n. 1
0
    def calc_pos(self, deltatime):
        if (self.rect.right > self.area.width or self.rect.left < 0):
            if (self.rect.right > self.area.width):
                self.velY = 500
                self.velX = 0
                self.image, self.rect = load_png('playerd.png')
            elif (self.rect.left < 0):
                self.velY = -500
                self.velX = 0
                self.image, self.rect = load_png('playert.png')
        if (self.rect.bottom > self.area.height - 200 or self.rect.top < 0):
            if (self.rect.bottom > self.area.height - 200):
                self.velX = -500
                self.velY = 0
                self.image, self.rect = load_png('playerl.png')
            elif (self.rect.top < 0):
                self.velX = 500
                self.velY = 0
                self.image, self.rect = load_png('playerr.png')

        self.velX = self.velX + self.accX * deltatime
        self.velY = self.velY + self.accY * deltatime

        self.posX = self.posX + self.velX * deltatime
        self.posY = self.posY + self.velY * deltatime

        self.update_bounds()
Esempio n. 2
0
    def __init__(self, shelfnum):
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_png('shelf.png')

        self.image = pygame.transform.scale(self.image, (100, 500))
        self.rect = self.image.get_rect()
        if shelfnum == 0:
            self.x = 180
            self.y = 128
            self.rect.x = 180
            self.rect.y = 128
        elif shelfnum == 1:
            self.x = 460
            self.y = 128
            self.rect.x = 460
            self.rect.y = 128
        elif shelfnum == 2:
            self.x = 740
            self.y = 128
            self.rect.x = 740
            self.rect.y = 128
        else:
            self.x = 1020
            self.y = 128
            self.rect.x = 1020
            self.rect.y = 128
        screen = pygame.display.get_surface()
        self.area = screen.get_rect()
Esempio n. 3
0
    def input(self, up, down, left, right):
        lastangle = 0
        previousRect = self.rect
        if (up):
            self.velY = -self.speed
            self.image, self.rect = load_png('playert.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
        elif (down):
            self.velY = self.speed
            self.image, self.rect = load_png('playerd.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
        else:
            self.velY = 0
        if (left):
            self.velX = -self.speed
            self.image, self.rect = load_png('playerl.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
        elif (right):
            self.velX = self.speed
            self.image, self.rect = load_png('playerr.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
        else:
            self.velX = 0

        if (up and right):
            self.image, self.rect = load_png('playertr.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
            self.velX = self.diagspeed
            self.velY = -self.diagspeed
        elif (up and left):
            self.image, self.rect = load_png('playertl.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
            self.velX = -self.diagspeed
            self.velY = -self.diagspeed
        elif (down and left):
            self.image, self.rect = load_png('playerdl.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
            self.velX = -self.diagspeed
            self.velY = self.diagspeed
        elif (down and right):
            self.image, self.rect = load_png('playerdr.png')
            self.rect.x = previousRect.x
            self.rect.y = previousRect.y
            self.velX = self.diagspeed
            self.velY = self.diagspeed
Esempio n. 4
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_png('../assets/Cloud.png')

        self.x = 1080
        self.y = 140

        self.v = 1  #Velocity
        self.move = True

        screen = pygame.display.get_surface()
        self.area = screen.get_rect()
Esempio n. 5
0
 def __init__(self):
     pygame.sprite.Sprite.__init__(self)
     self.image, self.rect = load_png('../assets/img/gondolaframe-1.png')
     screen = pygame.display.get_surface()
     self.originalX = 500
     self.area = screen.get_rect()
     self.state = "still"
     self.reinit()
     self.imageCounter = 0
     self.rect.y = 212
     self.rect.x = 500
     self.reversed = False
Esempio n. 6
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_png('../assets/Cactus.png')
        self.x = 1080
        self.y = 425
        self.v = 2

        screen = pygame.display.get_surface()
        self.area = screen.get_rect()
        self.state = "moving"

        self.imageCounter = 0
        self.counter = 10
Esempio n. 7
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_png('../assets/Cactus2.png')
        self.rect = self.rect.inflate(-40, -40)

        self.x = 1080
        self.y = 420
        self.rect.x = 1080
        self.rect.y = 420

        self.v = 8  #Velocity
        self.move = True

        screen = pygame.display.get_surface()
        self.area = screen.get_rect()
 def __init__(self, speed, x, y):
     pygame.sprite.Sprite.__init__(self)
     screen = pygame.display.get_surface()
     self.image, self.rect = load_png('../assets/img/boomerangframe-0.png')
     self.rect.x = x
     self.imageCounter = 0
     self.rect.y = y
     self.orignalx = x
     self.orignaly = y
     self.reversed = False
     self.speed = speed
     self.area = screen.get_rect()
     self.movepos = [self.rect.x,self.rect.y]
     if(self.speed < 1):
         self.rect.x = 1280 - self.rect.x
     else:
         self.rect.x = self.rect.x
     self.rect.y = self.rect.y - 20
Esempio n. 9
0
    def __init__(self):
        '''Initializes kangaroo sprite'''
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_png('../assets/kangaroo-frame-0.png')
        self.rect = self.rect.inflate(-64, -64)

        self.jumpup = False
        self.colliding = False

        self.x = 0
        self.y = 415
        self.rect.x = 0
        self.rect.y = 415
        self.v = -20 #Velocity
        self.g = 1 #Gravity constant

        screen = pygame.display.get_surface()
        self.area = screen.get_rect()

        self.imageCounter = 0 #For images
        self.counter = 10
Esempio n. 10
0
    def __init__(self):
        '''Initializes kangaroo sprite'''
        pygame.sprite.Sprite.__init__(self)
        self.image, self.rect = load_png('../assets/kangaroo-frame-0.png')
        self.jumpup = False
        self.x = 0
        self.y = 415
        self.v = -20
        self.g = 1

        screen = pygame.display.get_surface()
        self.area = screen.get_rect()
        self.state = "still"

        self.imageCounter = 0
        self.counter = 10

        #self.reinit()

        #def reinit(self):
        '''Moves kangaroo to position'''
Esempio n. 11
0
    def __init__(self):
        pygame.sprite.Sprite.__init__(self)
        #pygame.display.init()
        self.image, self.rect = load_png('playerr.png')

        self.isMoving = False
        self.key = pygame.K_m  #can't create an empty variable or something smh

        screen = pygame.display.get_surface()

        self.velX = 500
        self.velY = 0
        self.accX = 0
        self.accY = 0
        self.posX = random.randint(1, 11) * 100
        self.posY = 50
        self.rect.x = 700
        self.rect.y = 100
        self.speed = 500
        self.diagspeed = 354

        self.area = screen.get_rect()
Esempio n. 12
0
 def __init__(self, yesno):
     pygame.sprite.Sprite.__init__(self)
     if (yesno):
         self.image, self.rect = load_png('buttony.png')
     else:
         self.image, self.rect = load_png('buttonn.png')