48 lines
1.6 KiB
Python
48 lines
1.6 KiB
Python
import pygame
|
|
from pygame import Rect
|
|
from pygame.locals import *
|
|
|
|
from lib.pgfw.pgfw.GameChild import GameChild
|
|
from lib.pgfw.pgfw.Vector import Vector
|
|
from .Mask import Mask
|
|
from .Plate import Plate
|
|
|
|
class Land(GameChild, Rect):
|
|
|
|
def __init__(self, parent):
|
|
GameChild.__init__(self, parent)
|
|
self.display_surface = self.get_game().background
|
|
self.load_configuration()
|
|
if not self.get_game().rotated:
|
|
self.intermediate = pygame.Surface(self.get_display_surface().get_size())
|
|
else:
|
|
self.intermediate = pygame.Surface((self.get_display_surface().get_height(), self.get_display_surface().get_width()))
|
|
self.intermediate.set_colorkey((0, 0, 0))
|
|
self.mask = Mask(self)
|
|
self.plate = Plate(self)
|
|
self.init_rect()
|
|
self.reset()
|
|
|
|
def load_configuration(self):
|
|
config = self.get_configuration("land")
|
|
self.height = config["height"]
|
|
self.altitude_ratio = config["altitude-ratio"]
|
|
|
|
def init_rect(self):
|
|
Rect.__init__(self, (0, self.get_initial_top()), self.mask.get_size())
|
|
|
|
def get_initial_top(self):
|
|
return self.intermediate.get_height() - self.h
|
|
|
|
def reset(self):
|
|
self.top = self.get_initial_top()
|
|
self.mask.reset()
|
|
self.plate.reset()
|
|
|
|
def update(self):
|
|
self.mask.update()
|
|
self.plate.update()
|
|
self.intermediate.blit(self.plate, self)
|
|
self.intermediate.blit(self.mask, self, None, BLEND_RGB_MIN)
|
|
self.get_display_surface().blit(self.get_game().orient(self.intermediate), (0, 0))
|