def __init__(self,text, duration, type=NotificationType.Info): self.length = duration background = pSprite(glob.PixelWhite, vector2(0,0), SkinSource.local, Positions.topLeft, Positions.topLeft,Color(0,0,0)) background.Fade(0.8) background.VectorScale(vector2(1920,100)) if type == NotificationType.Info: Fgcolor = Color(0, 142, 250) textcolor = Color(255,255,255) elif type == NotificationType.Warning: Fgcolor = Color(255, 136, 0) textcolor = Color(255, 136, 0) else: Fgcolor = Color(255, 0, 0) textcolor = Color(255, 0, 0) foreGround = pSprite(glob.PixelWhite, vector2(0,100),SkinSource.local, Positions.topCentre, Positions.bottomCentre, Fgcolor) foreGround.VectorScale(vector2( 1900, 10)) text = pText(text, 30, FontStyle.regular,vector2(0, 25), Positions.topCentre, Positions.centre, textcolor) foreGround.tag = "Notification" background.tag = "Notification" text.tag = "Notification" self.text = text self.bg = background self.fg = foreGround
def GameQuit(): global isQuitting if isQuitting: InstantQuit() return isQuitting = True try: glob.WindowLeft.dispose() glob.WindowCenter.dispose() glob.WindowRight.dispose() except: pass glob.AudioManager.play( glob.AudioManager.loadSound("goodbye.mp3", SkinSource.user)) glob.AudioManager.Stop() glob.MenuManager.activeMenu.Transition = True for sprite in glob.foregroundSprites.sprites: sprite.FadeTo(0, 1000, EaseTypes.easeInOut) for sprite in glob.backgroundSprites.sprites: sprite.FadeTo(0, 5000, EaseTypes.easeInOut) for sprite in glob.overlaySprites.sprites: sprite.FadeTo(0, 200, EaseTypes.easeInOut) goodbye = pText("Goodbye", 70, FontStyle.regular, vector2(0, 0), Positions.centre, Positions.centre) glob.overlaySprites.add(goodbye) goodbye.FadeTo(0, 6000, EaseTypes.easeIn) glob.Scheduler.AddDelayed(6000, InstantQuit)
def __init__(self): self.active = False self.lastActive = 0 self.background = pSprite(glob.PixelWhite, vector2(0,0), SkinSource.local, Positions.centreRight, Positions.centreRight, Color(0,0,0)) self.background.VectorScale(vector2(30,600)) self.foreground = pSprite(glob.PixelWhite, vector2(-13,290), SkinSource.local, Positions.centreRight, Positions.bottomCentre, Color(255, 204, 212)) self.text = pText("100%", 20, FontStyle.regular, vector2(10,180), Positions.centreRight, Positions.centreRight) self.foreground.VectorScale(vector2(10,glob.volume*580))
def __init__(self, text, size, style=FontStyle.regular, position=vector2(0, 0), color=Color(255, 255, 255, 255)): self.originPosition = position self.position = vector2(0, 0) self.color = color self.size = size self.centreButton = pSprite(glob.PixelWhite, position=position, skinSource=SkinSource.local, field=Positions.topLeft, origin=Positions.centre, color=color) self.centreButton.VectorScale(size) offset = 0.57 self.text = pText(text, (0.8 * size.y), style, position=vector2(position.x * offset, position.y * offset - 15), field=Positions.topLeft, origin=Positions.centre) #575 self.rightButton = pSprite( "button-right.png", vector2(position.x + (size.x / 2) - 1, position.y), SkinSource.local, Positions.topLeft, Positions.centreLeft, color) self.rightButton.Scale((1 / 500) * size.y) self.leftButton = pSprite( "button-left.png", vector2(position.x - (size.x / 2) + 1, position.y), SkinSource.local, Positions.topLeft, Positions.centreRight, color) self.leftButton.Scale((1 / 500) * size.y) self.tag = "" self.onhover = [] self.onhoverlost = [] self.onclick = [] self.isonHover = False self.enabled = True
def __init__(self,text, duration, color=Color(255,0,0)): self.length = duration text = pText(text, 15, FontStyle.regular, vector2(0, 0), Positions.bottomRight, Positions.bottomRight) textHeight, textWidth = max(text.text.get_height(), 10), max(text.text.get_width(),100) background = pSprite(glob.PixelWhite, vector2(0,0), SkinSource.local, Positions.bottomRight, Positions.bottomRight,Color(0,0,0)) background.Fade(0.8) background.VectorScale(vector2(textWidth*1.5+20,textHeight+10)) text.position = vector2(0, 2) foreGround = pSprite(glob.PixelWhite, vector2(0,0),SkinSource.local, Positions.bottomRight, Positions.bottomCentre, color) foreGround.VectorScale(vector2( background.image.get_width(), 5)) foreGround.tag = "SNotification" background.tag = "SNotification" text.tag = "SNotification" self.text = text self.bg = background self.fg = foreGround
def init(self): glob.Framerate = 30 #Get data from cache and empty it to get it ready to free some space self.data = glob.cache #To avoiding python to act as reference and not copy when emptying cache glob.cache = None self.panel = pSprite("ranking-panel.png", vector2(0, 0), SkinSource.user, Positions.topLeft, Positions.topLeft) glob.foregroundSprites.add(self.panel) self.panel.Scale(glob.windowManager.height / self.panel.image.get_height()) self.rank = pSprite(f"ranks/{(self.data['rank'])}.png", vector2(-50, 100), SkinSource.local, Positions.topRight, Positions.topRight) glob.foregroundSprites.add(self.rank) bottomBar = pSprite(glob.PixelWhite, vector2(0, 0), SkinSource.local, Positions.bottomCentre, Positions.bottomCentre, Color(50, 50, 50)) bottomBar.VectorScale(vector2(1920, 100)) glob.foregroundSprites.add(bottomBar) button = pButton("Back", vector2(200, 100), FontStyle.regular, vector2(100, glob.windowManager.heightScaled - 50), Color(255, 120, 174)) button.text.position = vector2(0, 20) button.onClick(glob.AudioManager.play, sound=self.SoundBack) button.onClick(glob.MenuManager.ChangeMenu, type=Menus.SongSelection) glob.foregroundSprites.add(button) play_button = pButton( "Retry", vector2(200, 100), FontStyle.regular, vector2(glob.windowManager.widthScaled - 100, glob.windowManager.heightScaled - 50), Color(52, 237, 132)) play_button.text.position = vector2(-10, 20) play_button.onClick(glob.AudioManager.play, sound=self.SoundClick) play_button.onClick(glob.MenuManager.ChangeMenu, type=Menus.Playing) glob.foregroundSprites.add(play_button) stat = pText( glob.AudioManager.currentSong["name"] + " [" + ["normal", "hard", "insane"][glob.Difficulty] + "]", 60, FontStyle.thin, vector2(0, 0), Positions.topRight, Positions.topRight) glob.foregroundSprites.add(stat) #Since those are not changing and will never change, just reassign variable to take less ram, even if talking about ram with python is kinda ironic stat = pText(str(self.data["score"]), 80, FontStyle.regular, vector2(350, 17), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText(str(self.data["xmgpRatio"][3]), 60, FontStyle.regular, vector2(200, 130), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText(str(self.data["xmgpRatio"][2]), 60, FontStyle.regular, vector2(200, 220), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText(str(self.data["xmgpRatio"][1]), 60, FontStyle.regular, vector2(200, 310), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText(str(self.data["xmgpRatio"][0]), 60, FontStyle.regular, vector2(500, 310), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText( str(self.data["combo"]) + "x", 60, FontStyle.regular, vector2(100, 405), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText( str(self.data["accuracy"]) + "%", 60, FontStyle.regular, vector2(380, 405), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) stat = pText( f"UR : {(self.data['unstableRate'][0][0])}ms /{(self.data['unstableRate'][0][1])}ms /{(self.data['unstableRate'][0][2])}ms", 40, FontStyle.regular, vector2(500, 135), Positions.topLeft, Positions.topCentre) glob.foregroundSprites.add(stat) bg = pSprite(glob.PixelWhite, vector2(-100, 395), SkinSource.local, Positions.topCentre, Positions.topCentre, Color(0, 0, 0)) bg.VectorScale(vector2(300, 55)) bg.Fade(0.7) glob.foregroundSprites.add(bg) perfectLine = pSprite(glob.PixelWhite, vector2(-100, 420), SkinSource.local, Positions.topCentre, Positions.topCentre, Color(56, 185, 255)) perfectLine.VectorScale(vector2(100, 5)) glob.foregroundSprites.add(perfectLine) goodLine = pSprite(glob.PixelWhite, vector2(-150, 420), SkinSource.local, Positions.topCentre, Positions.topRight, Color(56, 255, 86)) goodLine.VectorScale(vector2(50, 5)) glob.foregroundSprites.add(goodLine) goodLine = pSprite(glob.PixelWhite, vector2(-50, 420), SkinSource.local, Positions.topCentre, Positions.topLeft, Color(56, 255, 86)) goodLine.VectorScale(vector2(50, 5)) glob.foregroundSprites.add(goodLine) MehLine = pSprite(glob.PixelWhite, vector2(-199, 420), SkinSource.local, Positions.topCentre, Positions.topRight, Color(255, 142, 77)) MehLine.VectorScale(vector2(50, 5)) glob.foregroundSprites.add(MehLine) MehLine = pSprite(glob.PixelWhite, vector2(-1, 420), SkinSource.local, Positions.topCentre, Positions.topLeft, Color(255, 142, 77)) MehLine.VectorScale(vector2(50, 5)) glob.foregroundSprites.add(MehLine) lines = self.data["unstableRate"][1] glob.Logger.debug(lines) offset = (self.data["mapOD"]) / 290 for line in lines: positionX = -100 + (line * offset) lSprite = pSprite(glob.PixelWhite, vector2(positionX, 422.5), SkinSource.local, Positions.topCentre, Positions.centre) lSprite.VectorScale(vector2(2, 55)) lSprite.Fade(0.7) glob.foregroundSprites.add(lSprite)
def init(self): if not glob.AudioManager.isPlaying: glob.AudioManager.Unpause(False) glob.Framerate = 30 background = pSprite(glob.PixelWhite, vector2(0, 0), SkinSource.local, Positions.topCentre, Positions.topCentre, Color(20, 20, 20)) background.VectorScale( vector2(glob.windowManager.widthScaled, glob.windowManager.heightScaled)) background.AlphaMask("songSelectBg.png") glob.foregroundSprites.add(background) bottomBar = pSprite(glob.PixelWhite, vector2(0, 0), SkinSource.local, Positions.bottomCentre, Positions.bottomCentre, Color(50, 50, 50)) bottomBar.VectorScale(vector2(1920, 100)) glob.foregroundSprites.add(bottomBar) button = pButton("Back", vector2(200, 100), FontStyle.regular, vector2(100, glob.windowManager.heightScaled - 50), Color(255, 120, 174)) button.text.position = vector2(0, 20) button.onClick(glob.AudioManager.play, sound=self.SoundBack) button.onClick(glob.MenuManager.ChangeMenu, type=Menus.MainMenu) glob.foregroundSprites.add(button) play_button = pButton( "Start", vector2(200, 100), FontStyle.regular, vector2(glob.windowManager.widthScaled - 100, glob.windowManager.heightScaled - 50), Color(52, 237, 132)) play_button.text.position = vector2(-10, 20) play_button.onClick(glob.AudioManager.play, sound=self.SoundClick) play_button.onClick(glob.MenuManager.ChangeMenu, type=Menus.Playing) glob.foregroundSprites.add(play_button) self.PlayButton = play_button if "/data/files/intro" in glob.AudioManager.currentSong["folder"]: glob.AudioManager.Skip() glob.AudioManager.ChangeBackground( glob.AudioManager.currentSong["folder"] + "/background.png", 400) tab = pSprite( glob.AudioManager.currentSong["folder"] + "/background.png", vector2(45, 0), SkinSource.absolute, Positions.centreLeft, Positions.centreLeft) tab.BottomGradiant(Color(50, 50, 50), "half") tab.crop(600, 800) tab.borderBounds(10) glob.foregroundSprites.add(tab) self.tabBg = tab tab.Fade(0) tab.FadeTo(1, 400) songSelectionHeader = pSprite("SongSelectionHeader.png", vector2(0, 0), SkinSource.local, Positions.topCentre, Positions.topCentre, Color(50, 50, 50)) tabPicBg = pSprite(glob.PixelWhite, vector2(95, 390), SkinSource.local, Positions.centreLeft, Positions.bottomLeft) tabPicBg.VectorScale(vector2(500, 500)) tabPicBg.borderBounds(10) self.tabPicBg = tabPicBg glob.foregroundSprites.add(tabPicBg) tabPic = pSprite( glob.AudioManager.currentSong["folder"] + "/thumb.png", vector2(105, 380), SkinSource.absolute, Positions.centreLeft, Positions.bottomLeft) tabPic.Scale(480 / tabPic.image.get_width() * glob.windowManager.getPixelSize()) tabPic.borderBounds(10) glob.foregroundSprites.add(tabPic) self.tabPic = tabPic SongTitle = pText(glob.AudioManager.currentSong["name"], 45, FontStyle.bold, vector2(20, 0), Positions.centreRight, Positions.centreRight) glob.foregroundSprites.add(SongTitle) self.songTitle = SongTitle SongArtist = pText(glob.AudioManager.currentSong["artist"], 45, FontStyle.regular, vector2(20, 30), Positions.centreRight, Positions.centreRight) glob.foregroundSprites.add(SongArtist) self.songArtist = SongArtist SongBpm = pText( str(glob.AudioManager.currentSong["bpm"]) + "bpm", 45, FontStyle.thin, vector2(20, 60), Positions.centreRight, Positions.centreRight) glob.foregroundSprites.add(SongBpm) self.songBPM = SongBpm SongMapper = pText( str("Map created by " + glob.AudioManager.currentSong["mapper"]), 45, FontStyle.thin, vector2(20, 90), Positions.centreRight, Positions.centreRight) glob.foregroundSprites.add(SongMapper) self.songMapper = SongMapper diffEasy = pSprite(glob.PixelWhite, vector2(300, 250), SkinSource.local, Positions.centre, Positions.topLeft, Color(62, 194, 194)) diffEasy.VectorScale(vector2(200, 150)) diffEasy.onHover(glob.AudioManager.play, sound=self.SoundHover) diffEasy.onHover(diffEasy.FadeTo, value=1, duration=100) diffEasy.onClick(self.loadDiff, difficulty=Difficulty.Normal) diffEasy.onHoverLost(diffEasy.FadeTo, value=0.8, duration=100) diffEasy.tag = "EasyDifficulty" diffEasy.borderBounds(20) diffEasy.Fade(0.8) glob.foregroundSprites.add(diffEasy) diffHard = pSprite(glob.PixelWhite, vector2(510, 250), SkinSource.local, Positions.centre, Positions.topLeft, Color(189, 163, 60)) diffHard.VectorScale(vector2(200, 150)) diffHard.onHover(glob.AudioManager.play, sound=self.SoundHover) diffHard.onHover(diffHard.FadeTo, value=1, duration=100) diffHard.onClick(self.loadDiff, difficulty=Difficulty.Hard) diffHard.onHoverLost(diffHard.FadeTo, value=0.8, duration=100) diffHard.tag = "HardDifficulty" diffHard.Fade(0.8) glob.foregroundSprites.add(diffHard) diffInsane = pSprite(glob.PixelWhite, vector2(720, 250), SkinSource.local, Positions.centre, Positions.topLeft, Color(147, 60, 194)) diffInsane.VectorScale(vector2(200, 150)) diffInsane.onHover(glob.AudioManager.play, sound=self.SoundHover) diffInsane.onHover(diffInsane.FadeTo, value=1, duration=100) diffInsane.onClick(self.loadDiff, difficulty=Difficulty.Insane) diffInsane.onHoverLost(diffInsane.FadeTo, value=0.8, duration=100) diffInsane.tag = "InsaneDifficulty" diffInsane.Fade(0.8) glob.foregroundSprites.add(diffInsane) EasyText = pText("Normal", 40, FontStyle.regular, vector2(227, 220), Positions.centre, Positions.bottomCentre) glob.foregroundSprites.add(EasyText) EasyText.tag = "EasyDifficulty" EasyDiff = pText("-", 50, FontStyle.heavy, vector2(227, 190), Positions.centre, Positions.bottomCentre) glob.foregroundSprites.add(EasyDiff) EasyDiff.tag = "EasyDifficulty" self.ezDefRating = EasyDiff HardText = pText("Hard", 40, FontStyle.regular, vector2(347, 220), Positions.centre, Positions.bottomCentre) glob.foregroundSprites.add(HardText) HardText.tag = "HardDifficulty" HardDiff = pText("-", 50, FontStyle.heavy, vector2(347, 190), Positions.centre, Positions.bottomCentre) glob.foregroundSprites.add(HardDiff) HardDiff.tag = "HardDifficulty" self.hrDefRating = HardDiff InsaneText = pText("Insane", 40, FontStyle.regular, vector2(467, 220), Positions.centre, Positions.bottomCentre) glob.foregroundSprites.add(InsaneText) InsaneText.tag = "InsaneDifficulty" InsaneDiff = pText("-", 50, FontStyle.heavy, vector2(467, 190), Positions.centre, Positions.bottomCentre) glob.foregroundSprites.add(InsaneDiff) InsaneDiff.tag = "InsaneDifficulty" self.inDefRating = InsaneDiff RankLetter = pSprite("/ranks/x.png", vector2(-50, -230), SkinSource.local, Positions.centre, Positions.centre) RankLetter.Scale(0.8) self.scoreRank = RankLetter glob.foregroundSprites.add(RankLetter) value = pText("Score: -", 35, FontStyle.regular, vector2(-170, 0), Positions.centre, Positions.centreLeft) self.scoreScore = value glob.foregroundSprites.add(self.scoreScore) value = pText("Accuracy: -", 35, FontStyle.regular, vector2(-170, 30), Positions.centre, Positions.centreLeft) self.scoreAcc = value glob.foregroundSprites.add(self.scoreAcc) value = pText("Unstable Rate: -", 35, FontStyle.regular, vector2(-170, 60), Positions.centre, Positions.centreLeft) self.scoreConsistency = value glob.foregroundSprites.add(self.scoreConsistency) value = pText("Combo: -", 35, FontStyle.regular, vector2(-170, 90), Positions.centre, Positions.centreLeft) self.scoreCombo = value glob.foregroundSprites.add(self.scoreCombo) value = pText("Perfect Hits: -", 35, FontStyle.regular, vector2(-170, 120), Positions.centre, Positions.centreLeft) self.scorePerf = value glob.foregroundSprites.add(self.scorePerf) value = pText("Good Hits: -", 35, FontStyle.regular, vector2(-170, 150), Positions.centre, Positions.centreLeft) self.scoreGood = value glob.foregroundSprites.add(self.scoreGood) value = pText("Meh Hits: -", 35, FontStyle.regular, vector2(-170, 180), Positions.centre, Positions.centreLeft) self.scoreMeh = value glob.foregroundSprites.add(self.scoreMeh) value = pText("Misses: -", 35, FontStyle.regular, vector2(-170, 210), Positions.centre, Positions.centreLeft) self.scoreMiss = value glob.foregroundSprites.add(self.scoreMiss) background.Fade(0) button.Fade(0) self.DifficultyRating = pText("Difficulty Rating | -", 45, FontStyle.thin, vector2(20, -50), Positions.centreRight, Positions.centreRight) self.NoteSpeed = pText("Note Speed | -", 45, FontStyle.thin, vector2(20, -80), Positions.centreRight, Positions.centreRight) self.health = pText("Health Drain | -", 45, FontStyle.thin, vector2(20, -110), Positions.centreRight, Positions.centreRight) self.Accuracy = pText("Accuracy needed | -", 45, FontStyle.thin, vector2(20, -140), Positions.centreRight, Positions.centreRight) self.objCount = pText("Object count | -", 45, FontStyle.thin, vector2(20, -170), Positions.centreRight, Positions.centreRight) self.Length = pText("Length | -", 45, FontStyle.thin, vector2(20, -200), Positions.centreRight, Positions.centreRight) self.diffName = pText("-", 120, FontStyle.heavy, vector2(20, -250), Positions.centreRight, Positions.centreRight) self.diffNameOverlay = pText("-", 120, FontStyle.heavy, vector2(20, -250), Positions.centreRight, Positions.centreRight) self.diffName.Fade(0.5) self.diffNameOverlay.Fade(0.5) glob.foregroundSprites.add(self.diffName) glob.foregroundSprites.add(self.diffNameOverlay) glob.foregroundSprites.add(self.DifficultyRating) glob.foregroundSprites.add(self.NoteSpeed) glob.foregroundSprites.add(self.health) glob.foregroundSprites.add(self.Accuracy) glob.foregroundSprites.add(self.objCount) glob.foregroundSprites.add(self.Length) background.FadeTo(1, 400) button.FadeTo(1, 400) glob.foregroundSprites.add(songSelectionHeader) songs = os.listdir(glob.currentDirectory + "/.user/maps") indexMin = 0 - 0.5 * len(songs) index = 0 for song in songs: songSprite = pSprite( glob.currentDirectory + "/.user/maps/" + song + "/thumb.png", vector2(0, 0), SkinSource.absolute, Positions.topCentre, Positions.topCentre) songSprite.Scale(150 / songSprite.image.get_width() * glob.windowManager.getPixelSize()) songSprite.position = vector2((indexMin + index) * 160, -20 - abs( (indexMin + index) * 10)) songSprite.tag = "SongSelectSprite" if glob.currentDirectory + "/.user/maps/" + song == glob.AudioManager.currentSong[ "folder"]: self.offset = (indexMin + index) * 160 glob.foregroundSprites.add(songSprite) self.songList.append(songSprite) songSprite.onHover(songSprite.VectorScaleTo, scale=vector2(1.1, 1.1), duration=200, easing=EaseTypes.BounceOut) songSprite.onHover(glob.AudioManager.play, sound=self.SoundHover) songSprite.onHoverLost(songSprite.VectorScaleTo, scale=vector2(1, 1), duration=100, easing=EaseTypes.easeInOut) songSprite.onClick(glob.AudioManager.play, sound=self.SoundChange) songSprite.onClick(self.GetNewSong, songPath=song, difficulty=Difficulty.Normal, sender=songSprite) songSprite.data.append((indexMin + index) * 160) songSprite.data.append(glob.currentDirectory + "/.user/maps/" + song) index += 1 self.loadDiffs()
def init(self): glob.AudioManager.Restart() glob.AudioManager.Pause() difficulties = { Difficulty.Normal: "normal.dd", Difficulty.Hard: "hard.dd", Difficulty.Insane: "insane.dd" } difficulty = difficulties[glob.Difficulty] with open(glob.AudioManager.currentSong["folder"] + "/" + difficulty) as f: file = f.read() data = data = file.split("\n")[0].split("|") self.fileBody = file.split("\n")[1:] if len(self.fileBody ) == 0: #Empty map will generate bugs within the menu glob.MenuManager.ChangeMenu(type=Menus.SongSelection) NotificationMassive(text="Beatmap is empty", duration=5000, type=NotificationType.Error).show() return self.hp = (float(data[1]) + 1) * 10 self.ar = 1 / (1 + float(data[2])) * 3000 self.od = 1 / (1 + float(data[3]) / 3) * 200 glob.Framerate = 30 glob.backgroundSprites.sprites[0].FadeTo(0.1, 400) accBar = pSprite(glob.PixelWhite, vector2(0, 0), SkinSource.local, Positions.centre, Positions.centre, Color(0, 246, 226)) accBar.Fade(0.5) accBar.VectorScale(vector2(5, glob.windowManager.heightScaled)) self.accBar = accBar glob.foregroundSprites.add(accBar) lowerStruct = pSprite("gameplay-struct.png", vector2(0, 0), SkinSource.user, Positions.bottomCentre, Positions.bottomCentre) lowerStruct.Scale(0.8) glob.foregroundSprites.add(lowerStruct) upperStruct = pSprite("gameplay-struct.png", vector2(0, 0), SkinSource.user, Positions.topCentre, Positions.topCentre) upperStruct.Scale(0.8) upperStruct.Rotate(180) upperStruct.Color(Color(176, 156, 255)) lowerStruct.Color(Color(255, 153, 153)) self.Loading = pText("Beatmap is Loading", 60, FontStyle.bold, vector2(0, 0), Positions.topCentre, Positions.topCentre) self.Loading.FadeTo(0.5, 2000, EaseTypes.easeInOut, True) self.lowerOv = pSprite("gameplay-struct-ov.png", vector2(0, 0), SkinSource.user, Positions.bottomCentre, Positions.bottomCentre) self.lowerOv.Scale(0.8) self.lowerOv.Fade(0) self.upperOv = pSprite("gameplay-struct-ov.png", vector2(0, 0), SkinSource.user, Positions.topCentre, Positions.topCentre) self.upperOv.Scale(0.8) self.upperOv.Fade(0) glob.foregroundSprites.add(upperStruct) self.progressBar = pSprite(glob.PixelWhite, vector2(0, 0), SkinSource.local, Positions.bottomLeft, Positions.bottomLeft) glob.foregroundSprites.add(self.progressBar) self.progressBar.VectorScale(vector2(0, 5)) self.LengthTime = pText("00:00", 40, FontStyle.regular, vector2(0, 10), Positions.bottomLeft, Positions.bottomLeft) glob.foregroundSprites.add(self.LengthTime) seconds = str( int((glob.AudioManager.currentSong["length"] / 1000) % 60)) if len(seconds) == 1: seconds = "0" + seconds minutes = str( int((glob.AudioManager.currentSong["length"] / 1000 / 60) % 60)) totalLength = pText("{}:{}".format(minutes, seconds), 40, FontStyle.regular, vector2(0, 10), Positions.bottomRight, Positions.bottomRight) glob.foregroundSprites.add(totalLength) self.upperSprites.sort( key=lambda x: x.time ) # Rearrange sprites to be sure it will be handled in the right order self.comboIndicator = pText("0x", 100, FontStyle.regular, vector2(0, 0), Positions.centre, Positions.centre) self.comboIndicatorOv = pText("0x", 100, FontStyle.regular, vector2(0, 0), Positions.centre, Positions.centre) self.ScoreIndicator = pText("0", 50, FontStyle.regular, vector2(10, 0), Positions.topRight, Positions.topRight) self.lifeBar = pSprite(glob.PixelWhite, vector2(0, 0), SkinSource.local, Positions.topLeft, Positions.topLeft) self.lifeBar.VectorScale(vector2(1920, 5)) glob.foregroundSprites.add(self.comboIndicator) glob.foregroundSprites.add(self.comboIndicatorOv) glob.foregroundSprites.add(self.ScoreIndicator) glob.foregroundSprites.add(self.lifeBar) glob.foregroundSprites.add(self.upperOv) glob.foregroundSprites.add(self.lowerOv) self.failOverlay = pSprite("fail-background.png", vector2(0, 0), SkinSource.user, Positions.centre, Positions.centre) self.failOverlay.Scale(glob.windowManager.width / self.failOverlay.image.get_width()) self.failOverlay.Fade(0) glob.foregroundSprites.add(self.failOverlay) self.failRetry = pSprite("fail-retry.png", vector2(0, 30), SkinSource.user, Positions.centre, Positions.centre) self.failRetry.Scale(0.7) self.failRetry.Fade(0) self.failRetry.onHover(self.failRetry.ScaleTo, scale=0.75, duration=200) self.failRetry.onHover(glob.AudioManager.play, sound=self.SoundHover) self.failRetry.onClick(glob.AudioManager.play, sound=self.SoundClick) self.failRetry.onClick(glob.MenuManager.ChangeMenu, type=Menus.Playing) self.failRetry.onHoverLost(self.failRetry.ScaleTo, scale=0.7, duration=200) self.failRetry.enabled = False glob.foregroundSprites.add(self.failRetry) self.failQuit = pSprite("fail-back.png", vector2(0, 260), SkinSource.user, Positions.centre, Positions.centre) self.failQuit.Fade(0) self.failQuit.Scale(0.7) self.failQuit.onHover(self.failQuit.ScaleTo, scale=0.75, duration=200) self.failQuit.onHover(glob.AudioManager.play, sound=self.SoundHover) self.failQuit.onClick(glob.AudioManager.play, sound=self.SoundClick) self.failQuit.onClick(glob.MenuManager.ChangeMenu, type=Menus.SongSelection) self.failQuit.onHoverLost(self.failQuit.ScaleTo, scale=0.7, duration=200) self.failQuit.enabled = False glob.foregroundSprites.add(self.failQuit) glob.foregroundSprites.add(self.Loading) self.UpperSprite = pSprite("hitObject.png", vector2(0, 0), SkinSource.user, Positions.topCentre, Positions.centre, Color(102, 66, 245), Clocks.audio) self.UpperSprite.Scale(0.2) self.LowerSprite = pSprite("hitObject.png", vector2(0, 0), SkinSource.user, Positions.bottomCentre, Positions.centre, Color(245, 64, 64), Clocks.audio) self.LowerSprite.Scale(0.2) glob.Scheduler.AddNow(self.loadElements)
def init(self): glob.Framerate = 30 try: self.SongName = glob.AudioManager.currentSong["artist"] + " | "+glob.AudioManager.currentSong["name"] except: self.SongName = "" upperBar = pSprite(glob.PixelWhite,vector2(0,0), SkinSource.local, Positions.topCentre, Positions.topCentre, Color(50,50,50)) upperBar.VectorScale(vector2(1920,50)) self.upperBar = upperBar glob.foregroundSprites.add(upperBar) bottomBar = pSprite(glob.PixelWhite, vector2(0,0), SkinSource.local, Positions.bottomCentre, Positions.bottomCentre, Color(50,50,50)) bottomBar.VectorScale(vector2(1920,50)) glob.foregroundSprites.add(bottomBar) self.lowerBar = bottomBar menuBg = pSprite(glob.PixelWhite, vector2(0,0), SkinSource.local, Positions.centreLeft, Positions.centre, Color(50,50,50,230)) menuBg.Scale(1000) menuBg.VectorScale(vector2(3, 1.5)) menuBg.Rotate(-69.7) self.background = menuBg glob.foregroundSprites.add(menuBg) version = pText("Delta Dash pre-alpha", 50,position=vector2(5,15), field=Positions.bottomLeft, origin=Positions.bottomLeft) glob.foregroundSprites.add(version) self.version = version button = pButton("Play", vector2(475,200),position=vector2(460,660), color=Color(110, 214, 69)) self.Playbutton = button self.Playbutton.onHover(glob.AudioManager.play, sound=self.SoundHover) self.Playbutton.onClick(glob.MenuManager.ChangeMenu, type= Menus.SongSelection) self.Playbutton.onClick(glob.AudioManager.play, sound=self.SoundClick) glob.foregroundSprites.add(button) optbutton = pButton("Exit", vector2(550,200),position=vector2(500,870), color=Color(209, 44, 44)) self.exit = optbutton self.exit.onHover(glob.AudioManager.play, sound=self.SoundHover) self.exit.onClick(helper.GameQuit) glob.foregroundSprites.add(optbutton) LogoHero = pSprite("logo-hero.png", vector2(-500,0), SkinSource.user, Positions.centreRight, Positions.centre) self.logoHero = LogoHero glob.foregroundSprites.add(LogoHero) Title = pSprite("title.png", vector2(400,200), SkinSource.local, Positions.topLeft, Positions.centre) self.title = Title glob.foregroundSprites.add(Title) NowPlaying = pText(self.SongName, 40, position=vector2(50,-3), field=Positions.topRight, origin=Positions.topRight) self.NowPlaying = NowPlaying glob.foregroundSprites.add(NowPlaying) if glob.Starting: self.Transition = True Title.Fade(0) upperBar.Fade(0) bottomBar.Fade(0) menuBg.Fade(0) NowPlaying.Fade(0) button.Fade(0) button.position = vector2(-500,0) optbutton.Fade(0) optbutton.position = vector2(-500,0) version.Fade(0) LogoHero.Fade(0) LogoHero.position = vector2(500,0) glob.Background.Fade(0) IntroTitle = pSprite("menu-big-title.png", vector2(0,0), SkinSource.local, Positions.centre, Positions.centre) IntroTitle.Fade(0) IntroTitle.FadeTo(1, 800, EaseTypes.easeInOut) self.introLogo = IntroTitle ClickButton = pText("Click Anywhere to start", 100, FontStyle.heavy, vector2(0,200), Positions.centre, Positions.centre) ClickButton.Fade(0) self.clickButton = ClickButton IntroTitleBackground = pSprite("menu-big-title-bg.png", vector2(0,0), SkinSource.local, Positions.centre, Positions.centre) IntroTitleBackground.Fade(0) self.introLogoBg = IntroTitleBackground glob.Scheduler.AddDelayed(2426, IntroTitleBackground.FadeTo, value=1, duration=800, easing=EaseTypes.easeInOut) glob.Scheduler.AddDelayed(4415, glob.Background.FadeTo, value=1, duration=800, easing=EaseTypes.easeInOut) glob.Scheduler.AddDelayed(6234, IntroTitle.MoveTo,x=0, y=-50, duration=2000,easing=EaseTypes.easeInOut) glob.Scheduler.AddDelayed(6234, IntroTitleBackground.MoveTo,x=0, y=-50, duration=2000,easing=EaseTypes.easeInOut) glob.Scheduler.AddDelayed(6234, ClickButton.FadeTo, value=0.9, duration=2100,easing=EaseTypes.easeInOut, loop=True) glob.Scheduler.AddDelayed(7234, NowPlaying.FadeTo, value=1, duration=800,easing=EaseTypes.easeInOut) glob.Scheduler.AddDelayed(8234, self.endTransformation) glob.foregroundSprites.add(IntroTitleBackground) glob.foregroundSprites.add(IntroTitle) glob.foregroundSprites.add(ClickButton) else: self.Transition = True for sprite in glob.foregroundSprites.sprites: sprite.Fade(0) sprite.FadeTo(1, 400) glob.AudioManager.ChangeBackground("/data/sprites/background.png", 400) glob.Scheduler.AddDelayed(400, self.endTransformation)
def setIdle(self): bgAlreadyPresent = False for sprite in glob.foregroundSprites.sprites: if sprite.tag not in ["idleOverlaySprites", "idleBackgroundSprite"]: sprite.FadeTo(0,1000) if sprite.tag == "idleOverlaySprites": sprite.FadeTo(0,200) glob.Scheduler.AddDelayed(200, glob.foregroundSprites.remove, sprite=sprite) if sprite.tag == "idleBackgroundSprite": bgAlreadyPresent = True if not bgAlreadyPresent: bgSprite = pSprite(glob.PixelWhite, vector2(0,0), SkinSource.local, Positions.centre, Positions.centre, Color(0,0,0)) bgSprite.VectorScale(vector2(1000,500)) bgSprite.Fade(0) bgSprite.FadeTo(0.6,500) bgSprite.tag = "idleBackgroundSprite" glob.foregroundSprites.add(bgSprite) if not path.exists(glob.AudioManager.currentSong["folder"]+"/thumb.png"): songLogo = pSprite("defaultThumb.png", vector2(-480,0), SkinSource.local, Positions.centre, Positions.centreLeft) songLogo.tag = "idleOverlaySprites" glob.foregroundSprites.add(songLogo) songLogo.Scale(460/songLogo.image.get_width()*glob.windowManager.getPixelSize()) else: songLogo = pSprite(glob.AudioManager.currentSong["folder"]+"/thumb.png", vector2(-480,0), SkinSource.absolute, Positions.centre, Positions.centreLeft) songLogo.Fade(0) glob.Scheduler.AddDelayed(200, songLogo.FadeTo, value=1, duration=500) songLogo.tag = "idleOverlaySprites" songLogo.Scale(460/songLogo.image.get_width() * glob.windowManager.getPixelSize()) songBg = pSprite(glob.PixelWhite, vector2(-490,0), SkinSource.local, Positions.centre, Positions.centreLeft) songBg.VectorScale(vector2(480,480)) songBg.tag = "idleOverlaySprites" songBg.Fade(0) glob.Scheduler.AddDelayed(200, songBg.FadeTo, value=1, duration=500) glob.foregroundSprites.add(songBg) glob.foregroundSprites.add(songLogo) glob.AudioManager.ChangeBackground(glob.AudioManager.currentSong["folder"]+"/background.png", 500) npName = glob.AudioManager.currentSong["name"] if len(npName) > 18: npName = npName[:16] + "..." songTitle = pText(npName, 50, FontStyle.regular, vector2(5, -140), Positions.centre, Positions.topLeft) songTitle.tag = "idleOverlaySprites" glob.foregroundSprites.add(songTitle) npArtist = glob.AudioManager.currentSong["artist"] if len(npArtist) > 18: npArtist = npArtist[:16] + "..." songArtist = pText(npArtist, 50, FontStyle.regular, vector2(5, -110), Positions.centre, Positions.topLeft) songArtist.tag = "idleOverlaySprites" glob.foregroundSprites.add(songArtist) if not bgAlreadyPresent: positionBarBg = pSprite(glob.PixelWhite, vector2(5,240), SkinSource.local, Positions.centre, Positions.bottomLeft, color=Color(0,0,0,150)) positionBarBg.VectorScale(vector2(485,10)) positionBarBg.tag = "idleBackgroundSprite" glob.foregroundSprites.add(positionBarBg) self.idleDisc = pSprite("idleDisc.png", vector2(240, 40), SkinSource.local, Positions.centre, Positions.centre) self.idleDisc.tag = "idleOverlaySprites" glob.foregroundSprites.add(self.idleDisc) self.positionBar = pSprite(glob.PixelWhite, vector2(5, 240), SkinSource.local, Positions.centre, Positions.bottomLeft) self.positionBar.tag = "idleOverlaySprites" glob.foregroundSprites.add(self.positionBar) seconds = str(int((glob.AudioManager.currentSong["length"] / 1000) % 60)) if len(seconds) == 1: seconds = "0"+seconds minutes = str(int((glob.AudioManager.currentSong["length"] / 1000 / 60) % 60)) self.idleLeftText = pText("0", 20, FontStyle.regular, vector2(5, 130), Positions.centre, Positions.bottomLeft) self.idleRightText = pText(minutes+":"+seconds, 20, FontStyle.regular, vector2(275, 130), Positions.centre, Positions.bottomRight) self.idleLeftText.tag = "idleOverlaySprites" self.idleRightText.tag = "idleOverlaySprites" glob.foregroundSprites.add(self.idleLeftText) glob.foregroundSprites.add(self.idleRightText) self.idleClickText = pText("Click anywhere to return to Delta Dash", 40, FontStyle.heavy, vector2(0, 150), Positions.centre, Positions.topCentre) self.idleClickText.tag = "idleOverlaySprites" glob.foregroundSprites.add(self.idleClickText)