Added stage bounding box camera constraints (to be moved into a Camera object later)
from Sprite import Sprite
from OpenGL.GL import *
from Numeric import array
+import pygame
import TexMan
class Collage:
tiles = None
displaylist = None
+ bbox = None
def __init__(self, file):
self.parse(file)
args = args[1:]
if cmd == 'tilesize':
mf = (int(args[0]),int(args[1]))
+ elif cmd == 'bbox':
+ self.bbox = pygame.Rect(0, 0, mf[0] * int(args[0]), mf[1] * int(args[1]))
elif cmd == 'texture':
if nvertices > 0: # dump vertex array
glVertexPointer(3, GL_FLOAT, 0, array(vertexarray,'f'))
def __init__(self, collage, scale=1.0, parallax=1.0):
if collage:
self.collage = Collage(collage)
+ self.bbox = self.collage.bbox
self.scale = scale
self.parallax = parallax
self.position = (0, 0)
tilesize 64 64
+bbox 19 7
texture img/block.png
tile 0 0
tile 1 0
richter.update()
if richter.position[1] < 0:
richter.position = [richter.position[0],480]
- stage.moveTo(richter.position[0] - resolution[0]/2, richter.position[1] - resolution[1]/4)
+ stagepos = [richter.position[0] - resolution[0]/2, richter.position[1] - resolution[1]/4]
+
+ ### Stage bounding box stuff should be moved upstream
+ # This is a wee bit confusing since Rects assume (0,0) in the upper
+ # left, but we want it in the lower left. Flip tops and bottoms.
+ if main.bbox.height < resolution[1] or stagepos[1] < main.bbox.top:
+ stagepos[1] = main.bbox.top
+ elif stagepos[1] + resolution[1] > main.bbox.bottom:
+ stagepos[1] = main.bbox.bottom - resolution[1]
+
+ if main.bbox.width < resolution[0] or stagepos[0] < main.bbox.left:
+ stagepos[0] = main.bbox.left
+ elif stagepos[0] + resolution[0] > main.bbox.right:
+ stagepos[0] = main.bbox.right- resolution[0]
+
+ stage.moveTo(stagepos[0], stagepos[1])
n = 0