def addRacers(self, racers): if type(racers) == dict: for racer in racers.itervalues(): self.racers[id(racer)] = racer elif type(racers) == list or type(racers) == tuple: for racer in racers: racerPath0 = pathJoin(('images','beta.png')) racerPath1 = pathJoin(('images','alpha.png')) if not racerPath0 in self.racers: self.racers[racerPath0] = racer else: self.racers[racerPath1] = racer
def __init__(self, size, ui): Ship.imageCache = Screen.imageCache Boulder.imageCache = Screen.imageCache BoulderFragment.imageCache = Screen.imageCache ScrollingCodeBackground.textCache = Screen.textCache ScrollingCodeBackground.resolution = Screen.resolution Counter.textCache = Screen.textCache Counter.resolution = Screen.resolution background = ScrollingCodeBackground() Screen.__init__(self, background, size, ui) self.ships = pygame.sprite.Group() ship = Ship(self, pos=(size[0]/2,size[1]), screenBoundaries=(0,0)+size) self.ships.add(ship) #May change if we add more ships (multiplayer?) for ship in self.ships: ship.move((0,-ship.rect.height/2)) ship.targetPosition = ship.position self.boulders = pygame.sprite.Group() self.nextBoulderTime = 0 self.boulderFragments = pygame.sprite.Group() self.healthBar = Bar(100,int(size[0]*0.72),int(size[1]*0.05),fullColor=(255,0,0),emptyColor=(0,0,0), borderSize=int(size[1]*0.005), borderColor=(255,255,255)) self.scoreDisplay = Counter(0,(self.healthBar.surface.get_rect().width,0)) musicPath = pathJoin(('music','Music.ogg')) pygame.mixer.music.load(musicPath) pygame.mixer.music.play(-1)
def __init__(self, parent, pos=(0, 0), vel=(0, 0), screenBoundaries=None): boulderPath = pathJoin(('images', 'boulder.png')) boulderImage = self.imageCache.getImage(boulderPath, colorkey='alpha', mask=True) GameObject.__init__(self, boulderImage, parent, pos, vel) self.minXPos = screenBoundaries[0] + self.rect.width / 2 self.maxXPos = screenBoundaries[2] - self.rect.width / 2 if self.position[0] < self.minXPos: self.moveTo((self.minXPos, self.position[1])) elif self.position[0] > self.maxXPos: self.moveTo((self.maxXPos, self.position[1])) self.moveTo( (self.position[0], self.position[1] - self.rect.height / 2)) self.mask = self.imageCache.getMask(boulderPath) if screenBoundaries == None: raise Exception('Boulders must have screen boundaries') self.boundaries = screenBoundaries self.acceleration = (0, .001) self.damage = 5 #Damage done to ship when it hits self.value = 5 #How many points the boulder is worth
def __init__(self, screenBoundaries, pos=(200, 0), vel=(0, 0), scaleSize=0.3): pygame.sprite.Sprite.__init__(self) self.boundaries = screenBoundaries if CodeObject.count + 1 >= CodeObject.maxCount: CodeObject.count = 0 self.text = CodeObject.specialText[CodeObject.count].strip() CodeObject.count += 1 self.fontname = pathJoin(('fonts', 'orbitron', 'orbitron-black.ttf')) self.size = int(self.resolution[1] * (1 / 15.0)) if scaleSize != None: self.size *= scaleSize self.size = int(self.size) self.color = (255, 140, 0) self.antialias = True self.image = self.textCache.getText(self.text, self.fontname, self.size, self.color, antialias=self.antialias) self.rect = self.image.get_rect() self.rect.center = int(pos[0]), int(pos[1]) self.position = pos self.velocity = vel
def __init__(self, screenBoundaries, pos=(200,0), vel=(0,0), scaleSize=0.3): pygame.sprite.Sprite.__init__(self) self.boundaries = screenBoundaries if CodeObject.count+1 >= CodeObject.maxCount: CodeObject.count = 0 self.text = CodeObject.specialText[CodeObject.count].strip() CodeObject.count += 1 self.fontname = pathJoin(('fonts','orbitron', 'orbitron-black.ttf')) self.size = int(self.resolution[1]*(1/15.0)) if scaleSize != None: self.size *= scaleSize self.size = int(self.size) self.color = (255,140,0) self.antialias = True self.image = self.textCache.getText(self.text, self.fontname, self.size, self.color, antialias=self.antialias) self.rect = self.image.get_rect() self.rect.center = int(pos[0]), int(pos[1]) self.position = pos self.velocity = vel
def __init__(self, value, pos, digits=8, scaleSize=None): self.digits = digits self.value = value self.pos = pos self.fontname = pathJoin(('fonts', 'orbitron', 'orbitron-black.ttf')) self.size = int(self.resolution[1] * (1 / 15.0)) if scaleSize != None: self.size *= scaleSize self.size = int(self.size) self.color = (255, 255, 255) self.antialias = True self.updateValue(self.value)
def __init__(self, value, pos, digits=8, scaleSize=None): self.digits = digits self.value = value self.pos = pos self.fontname = pathJoin(('fonts','orbitron', 'orbitron-black.ttf')) self.size = int(self.resolution[1]*(1/15.0)) if scaleSize != None: self.size *= scaleSize self.size = int(self.size) self.color = (255,255,255) self.antialias = True self.updateValue(self.value)
def __init__(self, text, pos, scaleSize=None): self.text = text self.fontname = pathJoin(('fonts','orbitron', 'orbitron-black.ttf')) self.size = int(self.resolution[1]*(1/15.0)) if scaleSize != None: self.size *= scaleSize self.size = int(self.size) self.color = (255,255,255) self.antialias = True self.textSurface = self.textCache.getText(text, self.fontname, self.size, self.color, antialias=self.antialias) self.rect = self.textSurface.get_rect() self.rect.center = int(pos[0]), int(pos[1])
def __init__(self, parent, pos=(0,0), vel=(0,0), screenBoundaries=None): shipPath = pathJoin(('images','ship.png')) shipImage = self.imageCache.getImage(shipPath, colorkey='alpha', mask=True) GameObject.__init__(self, shipImage, parent, pos, vel) self.targetPosition = pos self.mask = self.imageCache.getMask(shipPath) self.screenBoundaries = screenBoundaries self.health = 100 self.score = 0 if screenBoundaries != None: self.minXPos = screenBoundaries[0] + self.rect.width/2 self.maxXPos = screenBoundaries[2] - self.rect.width/2
def __init__(self, text, pos, scaleSize=None): self.text = text self.fontname = pathJoin(('fonts', 'orbitron', 'orbitron-black.ttf')) self.size = int(self.resolution[1] * (1 / 15.0)) if scaleSize != None: self.size *= scaleSize self.size = int(self.size) self.color = (255, 255, 255) self.antialias = True self.textSurface = self.textCache.getText(text, self.fontname, self.size, self.color, antialias=self.antialias) self.rect = self.textSurface.get_rect() self.rect.center = int(pos[0]), int(pos[1])
def __init__(self, parent, pos=(0,0), vel=(0,0), id=0, screenBoundaries = None): fragmentPath = pathJoin(('images','fragments','fragment'+str(id)+'.png')) fragmentImage = self.imageCache.getImage(fragmentPath, colorkey='alpha', mask=False) rect = self.imageCache.getRect(fragmentPath) GameObject.__init__(self, fragmentImage, parent, pos, vel) if screenBoundaries == None: raise Exception('Boulders must have screen boundaries') self.boundaries = (screenBoundaries[0]-rect.width, screenBoundaries[1]-rect.height, screenBoundaries[2]+rect.width, screenBoundaries[3]+rect.height) self.acceleration = (0,0.001)
def __init__(self, parent, pos=(0, 0), vel=(0, 0), screenBoundaries=None): shipPath = pathJoin(('images', 'ship.png')) shipImage = self.imageCache.getImage(shipPath, colorkey='alpha', mask=True) GameObject.__init__(self, shipImage, parent, pos, vel) self.targetPosition = pos self.mask = self.imageCache.getMask(shipPath) self.screenBoundaries = screenBoundaries self.health = 100 self.score = 0 if screenBoundaries != None: self.minXPos = screenBoundaries[0] + self.rect.width / 2 self.maxXPos = screenBoundaries[2] - self.rect.width / 2
def __init__(self, size, ui): Ship.imageCache = Screen.imageCache Boulder.imageCache = Screen.imageCache BoulderFragment.imageCache = Screen.imageCache ScrollingCodeBackground.textCache = Screen.textCache ScrollingCodeBackground.resolution = Screen.resolution Counter.textCache = Screen.textCache Counter.resolution = Screen.resolution background = ScrollingCodeBackground() Screen.__init__(self, background, size, ui) self.ships = pygame.sprite.Group() ship = Ship(self, pos=(size[0] / 2, size[1]), screenBoundaries=(0, 0) + size) self.ships.add(ship) #May change if we add more ships (multiplayer?) for ship in self.ships: ship.move((0, -ship.rect.height / 2)) ship.targetPosition = ship.position self.boulders = pygame.sprite.Group() self.nextBoulderTime = 0 self.boulderFragments = pygame.sprite.Group() self.healthBar = Bar(100, int(size[0] * 0.72), int(size[1] * 0.05), fullColor=(255, 0, 0), emptyColor=(0, 0, 0), borderSize=int(size[1] * 0.005), borderColor=(255, 255, 255)) self.scoreDisplay = Counter( 0, (self.healthBar.surface.get_rect().width, 0)) musicPath = pathJoin(('music', 'Music.ogg')) pygame.mixer.music.load(musicPath) pygame.mixer.music.play(-1)
def __init__(self, parent, pos=(0,0), vel=(0,0), screenBoundaries = None): boulderPath = pathJoin(('images','boulder.png')) boulderImage = self.imageCache.getImage(boulderPath, colorkey='alpha', mask=True) GameObject.__init__(self, boulderImage, parent, pos, vel) self.minXPos = screenBoundaries[0] + self.rect.width/2 self.maxXPos = screenBoundaries[2] - self.rect.width/2 if self.position[0] < self.minXPos: self.moveTo((self.minXPos, self.position[1])) elif self.position[0] > self.maxXPos: self.moveTo((self.maxXPos, self.position[1])) self.moveTo((self.position[0],self.position[1]-self.rect.height/2)) self.mask = self.imageCache.getMask(boulderPath) if screenBoundaries == None: raise Exception('Boulders must have screen boundaries') self.boundaries = screenBoundaries self.acceleration = (0,.001) self.damage = 5 #Damage done to ship when it hits self.value = 5 #How many points the boulder is worth
def __init__(self, parent, pos=(0, 0), vel=(0, 0), id=0, screenBoundaries=None): fragmentPath = pathJoin( ('images', 'fragments', 'fragment' + str(id) + '.png')) fragmentImage = self.imageCache.getImage(fragmentPath, colorkey='alpha', mask=False) rect = self.imageCache.getRect(fragmentPath) GameObject.__init__(self, fragmentImage, parent, pos, vel) if screenBoundaries == None: raise Exception('Boulders must have screen boundaries') self.boundaries = (screenBoundaries[0] - rect.width, screenBoundaries[1] - rect.height, screenBoundaries[2] + rect.width, screenBoundaries[3] + rect.height) self.acceleration = (0, 0.001)
def __init__(self): CodeObject.textCache = self.textCache CodeObject.resolution = self.resolution bg = pygame.sprite.Group() CodeObject.specialText = [] CodeObject.count = 0 for fn in [pathJoin(['engine','__init__.py']), pathJoin(['engine','altInput.py']), pathJoin(['engine','background.py']), pathJoin(['engine','bar.py']), pathJoin(['engine','classMethod.py']), pathJoin(['engine','continuousEvent.py']), pathJoin(['engine','drawableObject.py']), pathJoin(['engine','imageCache.py']), pathJoin(['engine','listener.py']), pathJoin(['engine','manager.py']), pathJoin(['engine','potentialObject.py']), pathJoin(['engine','screen.py']), pathJoin(['engine','textCache.py']), pathJoin(['engine','trueProcess.py']), pathJoin(['engine','ui.py']), pathJoin(['engine','functions','__init__.py']), pathJoin(['backgrounds.py']), pathJoin(['biofeedback.py']), pathJoin(['inputDevice.py']), pathJoin(['mindRush.py']), pathJoin(['screens.py']), pathJoin(['engine','functions','pathJoin.py']), pathJoin(['gameObjects','__init__.py']), pathJoin(['gameObjects','boulder.py']), pathJoin(['gameObjects','boulderFragment.py']), pathJoin(['gameObjects','ship.py']), pathJoin(['gameObjects','gameObject.py']), pathJoin(['hardware','arduinoEyeAndBrain', 'arduinoEyeAndBrain.pde'])]: try: f = open(fn) CodeObject.specialText += f.readlines() f.close() except: pass CodeObject.maxCount = len(CodeObject.specialText) self.nextCodeTime = 0 Background.__init__(self, bg)
def __init__(self): CodeObject.textCache = self.textCache CodeObject.resolution = self.resolution bg = pygame.sprite.Group() CodeObject.specialText = [] CodeObject.count = 0 for fn in [ pathJoin(['engine', '__init__.py']), pathJoin(['engine', 'altInput.py']), pathJoin(['engine', 'background.py']), pathJoin(['engine', 'bar.py']), pathJoin(['engine', 'classMethod.py']), pathJoin(['engine', 'continuousEvent.py']), pathJoin(['engine', 'drawableObject.py']), pathJoin(['engine', 'imageCache.py']), pathJoin(['engine', 'listener.py']), pathJoin(['engine', 'manager.py']), pathJoin(['engine', 'potentialObject.py']), pathJoin(['engine', 'screen.py']), pathJoin(['engine', 'textCache.py']), pathJoin(['engine', 'trueProcess.py']), pathJoin(['engine', 'ui.py']), pathJoin(['engine', 'functions', '__init__.py']), pathJoin(['backgrounds.py']), pathJoin(['biofeedback.py']), pathJoin(['inputDevice.py']), pathJoin(['mindRush.py']), pathJoin(['screens.py']), pathJoin(['engine', 'functions', 'pathJoin.py']), pathJoin(['gameObjects', '__init__.py']), pathJoin(['gameObjects', 'boulder.py']), pathJoin(['gameObjects', 'boulderFragment.py']), pathJoin(['gameObjects', 'ship.py']), pathJoin(['gameObjects', 'gameObject.py']), pathJoin([ 'hardware', 'arduinoEyeAndBrain', 'arduinoEyeAndBrain.pde' ]) ]: try: f = open(fn) CodeObject.specialText += f.readlines() f.close() except: pass CodeObject.maxCount = len(CodeObject.specialText) self.nextCodeTime = 0 Background.__init__(self, bg)