def __init__(self, surface, scout): self.surface = surface self.scout = scout self.powerTime = 0 self.visible = True self.vol = elements.ConfigUtility.getConfigSetting("volume") self.image = pygame.image.load( os.path.join(os.path.dirname(__file__), '../../../resource/images/game/powerup/slow.png') ).convert_alpha() self.image = pygame.transform.smoothscale(self.image, SU.scalePos(128, 128)) self.startSound = pygame.mixer.Sound( os.path.join(os.path.dirname(__file__), '../../../resource/sound/game/powerupStart.wav')) self.endSound = pygame.mixer.Sound( os.path.join(os.path.dirname(__file__), '../../../resource/sound/game/powerupEnd.wav')) self.startSound.set_volume(self.vol) self.endSound.set_volume(self.vol) self.finished = False self.x, self.y = 0, 0 self.x, self.y = random.randint( 0, SU.scaleValue(1920) - self.getRect()[2]), -random.randint( SU.scaleValue(100), SU.scaleValue(300)) #Gravity in Feet/Second self.gravityAccel = SU.scaleFloatValue(-4) self.prevVol = 0 self.prevPos = 0
def blitLogo(self): BAR_COLOR = (53, 50, 45) PADDING = ScaleUtility.scalePos(10, 10) AREA = ScaleUtility.scaleResSurface(50, 25, 520, 300) pygame.draw.rect(self.screen, BAR_COLOR, AREA) self.screen.blit(self.logoFile, (AREA[0] + PADDING[0], AREA[1] + PADDING[1]))
def addFooter(self): COVERAGE = 8 BAR_COLOR = (53, 50, 45) pygame.draw.rect(self.screen, BAR_COLOR, (0, int(self.SCREEN_H - (self.SCREEN_H / COVERAGE)), self.SCREEN_W, int(self.SCREEN_H / COVERAGE))) font = pygame.font.Font( os.path.join(os.path.dirname(__file__), '../../resource/fonts/tf2secondary.ttf'), ScaleUtility.scaleValue(36)) text = font.render("Version " + self.version + " - made by /u/djfigs1", True, (119, 107, 95)) self.screen.blit(text, ScaleUtility.scalePos(1375, 995))
def blitFPS(self, Clock): pygame.draw.rect(self.FPS_SURFACE, (0, 0, 0), ScaleUtility.scaleResSurface(0, 0, 100, 50)) font = pygame.font.Font( os.path.join(os.path.dirname(__file__), '../../resource/fonts/tf2secondary.ttf'), ScaleUtility.scaleValue(36)) text = font.render(str(round(Clock.get_fps(), 2)), True, (255, 255, 0)) text_w = text.get_rect().width text_h = text.get_rect().height self.FPS_SURFACE.blit( text, ((0 + ScaleUtility.scaleValue(100) / 2) - text_w / 2, (0 + ScaleUtility.scaleValue(50) / 2) - text_h / 2)) self.screen.blit(self.FPS_SURFACE, ScaleUtility.scalePos(1750, 25))
def __init__(self, screen): self.screen = screen self.SCREEN_W = pygame.display.Info().current_w self.SCREEN_H = pygame.display.Info().current_h self.didQuit = False self.showFPS = elements.ConfigUtility.getConfigSetting("fps_counter") self.FPS_SURFACE = pygame.Surface(ScaleUtility.scalePos(100, 50)) self.version = "0.1.0" pygame.mouse.set_visible(True) self.logger = logging.getLogger('spf') self.logger.info("Initializing TitleScreen Class") self.FloatText = FloatText(screen, ScaleUtility.scaleValue(25)) pygame.mouse.set_visible(True) self.languageFile = json.load( open(self.getLocalFile('../../resource/language/en_US.json'), 'r')) self.randomBackground = self.returnRandomBackground() self.blitBackground(self.randomBackground) if elements.ConfigUtility.getConfigSetting("ts_music_enable"): self.playRandomMusic() self.addFooter() self.buttonSurface = self.screen #pygame.Surface((self.SCREEN_W, self.SCREEN_H)) # non-containers, actual buttons quitButtonRes = self.scaleResSurface(50, 975, 400, 75) settingsButtonRes = self.scaleResSurface(500, 975, 400, 75) # container buttons playContainerRes = ScaleUtility.scaleResSurface(50, 350, 520, 70) htpContainerRes = ScaleUtility.scaleResSurface(50, 800, 520, 70) customizeContainerRes = ScaleUtility.scaleResSurface(50, 500, 520, 100) supportContainerRes = ScaleUtility.scaleResSurface(50, 725, 520, 70) self.quitButton = TSButton( self.screen, quitButtonRes[0], quitButtonRes[1], quitButtonRes[2], quitButtonRes[3], self.getLanguageString('#SPF_Quit_Button_Title'), footerButton=True) self.settingsButton = TSButton( self.screen, settingsButtonRes[0], settingsButtonRes[1], settingsButtonRes[2], settingsButtonRes[3], self.getLanguageString('#SPF_Settings_Button_Title'), footerButton=True) self.playButton = TSButton( self.buttonSurface, 50, 300, 500, 75, self.getLanguageString('#SPF_Play_Button_Title')) self.htpButton = TSButton( self.buttonSurface, 50, 600, 500, 75, self.getLanguageString('#SPF_HowToPlay_Button_Title')) self.loadoutButton = TSButton( self.buttonSurface, 50, 400, 275, 75, self.getLanguageString('#SPF_Loadout_Button_Title')) self.codeButton = TSButton( self.buttonSurface, 350, 400, 200, 75, self.getLanguageString('#SPF_Code_Button_Title')) self.supportButton = TSButton( self.buttonSurface, 0, 0, 0, 0, self.getLanguageString('#SPF_Support_Button_Title')) self.buttons = [ self.quitButton, self.playButton, self.htpButton, self.settingsButton, self.loadoutButton, self.codeButton, self.supportButton ] self.containButtons = [self.loadoutButton, self.codeButton] padding = (ScaleUtility.scaleValue(8), ScaleUtility.scaleValue(10)) self.playContainer = TSButtonContainer( self.screen, "", self.playButton, padding, 0, playContainerRes[0], playContainerRes[1], playContainerRes[2], playContainerRes[3]) self.customizeContainer = TSButtonContainer( self.screen, "Customize", self.containButtons, (ScaleUtility.scaleValue(5), ScaleUtility.scaleValue(10)), ScaleUtility.scaleValue(10), customizeContainerRes[0], customizeContainerRes[1], customizeContainerRes[2], customizeContainerRes[3]) self.supportContainer = TSButtonContainer(self.screen, "", self.supportButton, padding, 0, supportContainerRes[0], supportContainerRes[1], supportContainerRes[2], supportContainerRes[3]) self.buttonContainer = TSButtonContainer( self.screen, "", self.htpButton, padding, 0, htpContainerRes[0], htpContainerRes[1], htpContainerRes[2], htpContainerRes[3]) self.containers = [ self.playContainer, self.customizeContainer, self.supportContainer, self.buttonContainer ] self.startGame = False self.joystickConnected = False self.buttonClick = pygame.mixer.Sound( os.path.join(os.path.dirname(__file__), '../../resource/sound/menu/buttonclick.wav')) self.buttonRelease = pygame.mixer.Sound( os.path.join(os.path.dirname(__file__), '../../resource/sound/menu/buttonclickrelease.wav')) self.buttonNotSupportedSound = pygame.mixer.Sound( os.path.join(os.path.dirname(__file__), '../../resource/sound/menu/button_fail.wav')) self.notificationSound = pygame.mixer.Sound( os.path.join(os.path.dirname(__file__), '../../resource/sound/menu/notification_alert.wav')) self.notificationImage = pygame.image.load( os.path.join( os.path.dirname(__file__), '../../resource/images/menu/button_alert.png')).convert() self.notificationImage.set_colorkey((255, 255, 255)) self.blitNotificationImage = False self.testSurface = pygame.Surface(ScaleUtility.scalePos(800, 600)) self.testWindow = TSWindow(self.testSurface) self.testWindow.setTitle("Options") logoRes = ScaleUtility.scaleResSurface(50, 25, 520, 300) self.logoFile = pygame.transform.smoothscale( pygame.image.load( os.path.join( os.path.dirname(__file__), '../../resource/images/menu/spf_title.png')).convert(), (logoRes[2] - ScaleUtility.scaleValue(10) * 2, logoRes[3] - ScaleUtility.scaleValue(10) * 2))
def __init__(self, surface): self.surface = surface self.font = pygame.font.Font(os.path.join(os.path.dirname(__file__), '../../../resource/fonts/tf2build.ttf'), SU.scaleValue(128)) self.secondaryFont = pygame.font.Font(os.path.join(os.path.dirname(__file__), '../../../resource/fonts/tf2build.ttf'), SU.scaleValue(80)) self.x, self.y = SU.scalePos(50, 25)