Skip to content

Commit

Permalink
Viewport constant dimensions
Browse files Browse the repository at this point in the history
  • Loading branch information
erodozer committed Feb 20, 2011
1 parent b74536a commit b057a77
Showing 1 changed file with 23 additions and 20 deletions.
43 changes: 23 additions & 20 deletions src/Rockmeter.py
Expand Up @@ -77,6 +77,9 @@
progress = 0.0 #this gives a percentage (between 0 and 1)
# of how far the song has played

vpc = [640.0, 480.0] #viewport's constant size, these variables determine how
#things are placed on screen in relation to pixel coordinates

# A graphical rockmeter layer
# This is the base template for all rockmeter layer types
class Layer:
Expand Down Expand Up @@ -178,19 +181,19 @@ def updateLayer(self, playerNum):
scale[1] /= texture.pixelSize[1] * (rect[3] - rect[2])

scale[1] = -scale[1]
scale[0] *= w/640.0
scale[1] *= h/480.0
scale[0] *= w/vpc[0]
scale[1] *= h/vpc[1]

self.finals[1] = scale

position = self.finals[0]
if "xpos" in self.inPixels:
position[0] *= w/640.0
position[0] *= w/vpc[0]
else:
position[0] *= w

if "ypos" in self.inPixels:
position[1] *= h/480.0
position[1] *= h/vpc[1]
else:
position[1] *= h

Expand Down Expand Up @@ -252,9 +255,9 @@ def updateLayer(self, playerNum):

position = self.finals[0]
if "xpos" in self.inPixels:
position[0] /= 640.0
position[0] /= vpc[0]
if "ypos" in self.inPixels:
position[1] /= 480.0
position[1] /= vpc[1]

#the viewport code for rendering for is a little awkward
#instead of the bottom edge being at 1.0 it is at .75
Expand Down Expand Up @@ -341,20 +344,20 @@ def updateLayer(self, playerNum):
scale[1] /= texture.pixelSize[1]

scale[1] = -scale[1]
scale[0] *= w/640.0
scale[1] *= h/480.0
scale[0] *= w/vpc[0]
scale[1] *= h/vpc[1]

self.finals[1] = scale

position = self.finals[0]

if "xpos" in self.inPixels:
position[0] *= w/640.0
position[0] *= w/vpc[0]
else:
position[0] *= w

if "ypos" in self.inPixels:
position[1] *= h/480.0
position[1] *= h/vpc[1]
else:
position[1] *= h

Expand Down Expand Up @@ -416,35 +419,35 @@ def __init__(self, layer, section):

if isinstance(self.layer, FontLayer):
if "startX" in self.inPixels:
self.startCoord[0] /= 640.0
self.startCoord[0] /= vpc[0]
if "endX" in self.inPixels:
self.endCoord[0] /= 640.0
self.endCoord[0] /= vpc[0]
if "startY" in self.inPixels:
self.startCoord[1] /= 480.0
self.startCoord[1] /= vpc[1]
if "endY" in self.inPixels:
self.endCoord[1] /= 480.0
self.endCoord[1] /= vpc[1]
self.startCoord[1] *= .75
self.startCoord[1] = .75 - self.startCoord[1]
self.endCoord[1] *= .75
self.endCoord[1] = .75 - self.endCoord[1]
else:
if "startX" in self.inPixels:
self.startCoord[0] *= w/640.0
self.startCoord[0] *= w/vpc[0]
else:
self.startCoord[0] *= w

if "startY" in self.inPixels:
self.startCoord[1] *= h/480.0
self.startCoord[1] *= h/vpc[1]
else:
self.startCoord[1] *= h

if "endX" in self.inPixels:
self.endCoord[0] *= w/640.0
self.endCoord[0] *= w/vpc[0]
else:
self.endCoord[0] *= w

if "endY" in self.inPixels:
self.endCoord[1] *= h/480.0
self.endCoord[1] *= h/vpc[1]
else:
self.endCoord[1] *= h

Expand Down Expand Up @@ -540,8 +543,8 @@ def fixScale(self):
scale[1] /= self.layer.drawing.pixelSize[1]

scale[1] = -scale[1]
scale[0] *= w/640.0
scale[1] *= h/480.0
scale[0] *= w/vpc[0]
scale[1] *= h/vpc[1]

self.layer.finals[1] = scale

Expand Down

0 comments on commit b057a77

Please sign in to comment.