2023-09-27 18:03:37 +00:00
|
|
|
import pygame
|
|
|
|
|
2024-02-10 17:11:28 +00:00
|
|
|
from config.system.window import TILESIZE,\
|
2023-11-29 10:53:30 +00:00
|
|
|
HITBOX_OFFSET
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
|
2023-11-29 10:53:30 +00:00
|
|
|
class Terrain(pygame.sprite.Sprite):
|
|
|
|
|
|
|
|
def __init__(self,
|
|
|
|
position,
|
|
|
|
groups,
|
|
|
|
sprite_type,
|
|
|
|
surface=pygame.Surface((TILESIZE, TILESIZE))
|
|
|
|
):
|
2023-09-27 18:03:37 +00:00
|
|
|
|
|
|
|
super().__init__(groups)
|
|
|
|
|
|
|
|
self.sprite_type = sprite_type
|
2023-11-29 10:53:30 +00:00
|
|
|
|
|
|
|
self.position = position
|
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
self.image = surface
|
2023-11-29 10:53:30 +00:00
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
if sprite_type == 'object':
|
|
|
|
# Offset
|
|
|
|
self.rect = self.image.get_rect(
|
|
|
|
topleft=(position[0], position[1] - TILESIZE))
|
|
|
|
else:
|
|
|
|
self.rect = self.image.get_rect(topleft=position)
|
2023-12-14 17:28:45 +00:00
|
|
|
|
2023-09-27 18:03:37 +00:00
|
|
|
self.hitbox = self.rect.inflate(HITBOX_OFFSET[sprite_type])
|