mirror of
https://github.com/OpenBMB/ChatDev.git
synced 2024-09-20 22:59:10 +03:00
26 lines
814 B
Python
26 lines
814 B
Python
'''
|
|
This file defines the Block and Obstacle classes.
|
|
'''
|
|
import pygame
|
|
class Block(pygame.sprite.Sprite):
|
|
def __init__(self, x, y, size):
|
|
super().__init__()
|
|
self.image = pygame.Surface((size, size))
|
|
self.image.fill((0, 0, 0))
|
|
self.rect = self.image.get_rect()
|
|
self.rect.x = x
|
|
self.rect.y = y
|
|
self.speed_y = 0
|
|
def update(self, gravity):
|
|
self.speed_y += gravity
|
|
self.rect.y += self.speed_y
|
|
class Obstacle(pygame.sprite.Sprite):
|
|
def __init__(self, x, y, width, height):
|
|
super().__init__()
|
|
self.image = pygame.Surface((width, height))
|
|
self.image.fill((0, 0, 0))
|
|
self.rect = self.image.get_rect()
|
|
self.rect.x = x
|
|
self.rect.y = y
|
|
def update(self, speed):
|
|
self.rect.x -= speed |