Changeset 428:6a8f98335a53


Ignore:
Timestamp:
04/09/11 16:23:59 (12 years ago)
Author:
Jeremy Thurgood <firxen@…>
Branch:
default
Phase:
public
Message:

Crop background image if necessary.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • skaapsteker/level.py

    r344 r428  
    55
    66from . import data
    7 from .constants import Layers
     7from .constants import SCREEN, Layers
    88from .sprites.base import TILE_SIZE, find_sprite, Geography
    99from .widgets.text import Text
     
    6464        self.sprites = LayeredUpdates()
    6565        self._soundsystem = soundsystem
     66        self.build_tiles()
    6667        self.build_backgrounds()
    67         self.build_tiles()
    6868        self.setup_enemies()
    6969        self.setup_doorways()
     
    7575    def build_backgrounds(self):
    7676        self.backgrounds = []
    77         for background in self.level_data['backgrounds']:
    78             self.backgrounds.append(data.load_image('backgrounds/' + background))
     77        for i, background in enumerate(self.level_data['backgrounds']):
     78            image = data.load_image('backgrounds/' + background)
     79            if i == 0:
     80                print "background:", background, image.get_rect()
     81                print "pixel_size:", self.pixel_size
     82                clip_rect = Rect((0, 0), (int(self.pixel_size[0] * 0.75), int(self.pixel_size[1] * 0.75)))
     83                print "initial:", clip_rect
     84                clip_rect = clip_rect.clip(image.get_rect())
     85                print "clipped to image:", clip_rect
     86                clip_rect = clip_rect.union(Rect((0, 0), SCREEN))
     87                print "unioned to screen:", clip_rect
     88                clip_rect.midbottom = image.get_rect().midbottom
     89                print "offset:", clip_rect
     90                image = image.subsurface(clip_rect)
     91            self.backgrounds.append(image)
    7992
    8093    def enter(self):
Note: See TracChangeset for help on using the changeset viewer.