Changed tiled background to work based on repetitions.

This commit is contained in:
2013-01-16 23:53:32 -04:30
parent 493e46233d
commit b5e8c04754
2 changed files with 11 additions and 15 deletions

View File

@@ -6,17 +6,16 @@ import pygame
import imloader
from constants import DEBUG
class TiledBackground():
def __init__(self, width, height, texture_filename, position_x = 0, position_y = 0):
self.w = width
self.h = height
def __init__(self, rep_x, rep_y, texture_filename, position_x = 0, position_y = 0):
self.position = (position_x, position_y)
texture = imloader.cached_image_loader.get_image_to_screen_percent(texture_filename)
img_w = texture.get_width()
img_h = texture.get_height()
rep_x = (self.w // img_w) + 1
rep_y = (self.h // img_h) + 1
self.w = img_w * rep_x
self.h = img_h * rep_y
if DEBUG:
print '(' + str(rep_x) + ', ' + str(rep_y) + ')'