コード例 #1
0
 def playSnd(self):
     self.channelPlay = OPTIONS.getReg("currentChannel")
     pygame.mixer.Channel(self.channelPlay).play(self.sound)
     if self.channelPlay < 19:
         OPTIONS.setReg("currentChannel", self.channelPlay + 1)
     elif self.channelPlay == 19:
         OPTIONS.setReg("currentChannel", 0)
コード例 #2
0
 def update(self):
     if OPTIONS.getReg("scene") == 0:
         self.menuWindow.start(60)
     elif OPTIONS.getReg("scene") == 1:
         self.gameWindow.start(60)
     elif OPTIONS.getReg("scene") == 2:
         self.optionWindow.start(60)
コード例 #3
0
 def preInitFullscreen(self):
     if OPTIONS.getReg("fullScreen") == 1:
         self.surf_main = pygame.display.set_mode(
             (OPTIONS.getReg("width"), OPTIONS.getReg("height")),
             pygame.FULLSCREEN)
         OPTIONS.setReg("surf_main", self.surf_main)
     elif OPTIONS.getReg("fullScreen") == 0:
         self.surf_main = pygame.display.set_mode(
             (OPTIONS.getReg("width"), OPTIONS.getReg("height")))
         OPTIONS.setReg("surf_main", self.surf_main)
コード例 #4
0
 def start(self, fps):
     self.fps = fps
     OPTIONS.setReg("fps", self.fps)
     self.clock = pygame.time.Clock()
     self.preInitFullscreen()
     self.preInit()
     while self.run:
         self.events()
         self.postInit()
         pygame.display.update()
         self.clock.tick(OPTIONS.getReg("fps"))
         self.changeScene()
コード例 #5
0
    def preInit(self):
        pygame.mixer.music.stop()
        self.time = 0

        # createStaticImage: posX, posY, pos, name,
        #                    path=None, sizeX=1, sizeY=1
        # createImage: name, path=None, sizeX=1, sizeY=1
        self.backgroundMenuImage = Image()
        self.backgroundMenuImage.createStaticImage(960, 540, "center",
                                                   "backgroundmenuimage",
                                                   "backgroundmenu")

        #self.backgroundMenuPapichImage = Image()
        #self.backgroundMenuPapichImage.createStaticImage(650-480, 1080, "bottomleft",
        #                         "backgroundmenupapich", "backgroundmenu\\", 1.2, 1.2)
        self.backgroundMenuEpifImage = Image()
        self.backgroundMenuEpifImage.createStaticImage(0, 1080, "bottomleft",
                                                       "4", "backgroundmenu",
                                                       1.8, 1.8)

        self.backgroundMenuPahomImage = Image()
        self.backgroundMenuPahomImage.createStaticImage(
            1750, 800, "bottomright", "2.1", "backgroundmenu", 1.1, 1.1)

        self.backgroundMenuBlackImage = Image()
        self.backgroundMenuBlackImage.createStaticImage(
            960, 540, "center", "backgroundmenublack", "backgroundmenu")

        self.fog = Fog()
        self.fog.createImage("fog", "backgroundmenu\\")
        # createStaticAnimation: posX, posY, pos, sizeX=1, sizeY=1
        # createAnimation: sizeX=1, sizeY=1
        #self.snowAnimation = Animation("snow\\", 240)
        #self.snowAnimation.createStaticAnimation(960, 540, "center", 2.5, 2.5)

        # createStaticButton: name, posX, posY, pos, text, font,
        #                     sizeText, color, sizeX=1, sizeY=1
        # createButton: name, text, font, sizeText,
        #               color, sizeX=1, sizeY=1
        self.startButton = Button("start")
        self.startButton.createStaticButton("button",
                                            OPTIONS.getReg("width") / 2, 980,
                                            "center", "Начать игру", "times",
                                            32, COLOR.BLACK, 2, 1.5)

        self.settingsButton = Button("settings")
        self.settingsButton.createStaticButton("settings", 1920 - 10, 0 + 10,
                                               "topright", "", "times", 32,
                                               COLOR.BLACK, 1 / 16, 1 / 16)

        self.exitButton = Button("exit")
        self.exitButton.createStaticButton("exit", 1920 - 10, 1080 - 10,
                                           "bottomright", "", "times", 32,
                                           COLOR.BLACK, 1 / 16, 1 / 16)

        self.backgroundMusic = Music("music")
        self.backgroundMusic.start(300, -1)
コード例 #6
0
	def showCrop(self, x, y, xSize, ySize):
		OPTIONS.getReg("surf_main").blit(self.image, self.rect, (x, y, xSize, ySize))
コード例 #7
0
	def showStaticImage(self):
		OPTIONS.getReg("surf_main").blit(self.image, self.rect)
コード例 #8
0
	def changeSizeY(self, sizeY):
		if OPTIONS.getReg("height")>1080:
			return(sizeY*OPTIONS.getReg("height")/1080)
		else:
			return(sizeY)
コード例 #9
0
	def changeSizeX(self, sizeX):
		if OPTIONS.getReg("width")>1920:
			return(sizeX*OPTIONS.getReg("width")/1920)
		else:
			return(sizeX)
コード例 #10
0
	def changeY(self, y):
		return(round(y/1080*OPTIONS.getReg("height")))
コード例 #11
0
	def changeX(self, x):
		return(round(x/1920*OPTIONS.getReg("width")))
コード例 #12
0
ファイル: Text.py プロジェクト: zlidenskardanom/NonameProject
 def showStaticText(self):
     OPTIONS.getReg("surf_main").blit(self.text, self.textRect)
コード例 #13
0
 def changeScene(self):
     if not (OPTIONS.getReg("scene") == self.scene):
         self.run = False
コード例 #14
0
 def changeSpeed(self, speed):
     return (round(speed * OPTIONS.getReg("fps") / 60))
コード例 #15
0
ファイル: Text.py プロジェクト: zlidenskardanom/NonameProject
 def showText(self, posX, posY):
     self.changeRectText(posX, posY)
     OPTIONS.getReg("surf_main").blit(self.text, self.textRect)
コード例 #16
0
	def setVisisbleMouse(self):
		pygame.mouse.set_visible(OPTIONS.getReg("visibleMouse"))
コード例 #17
0
    def postInit(self):
        #Области
        self.volumeFillSurface = pygame.Surface((146, 146))
        self.volumeFillSurface.set_colorkey((0, 0, 0))
        self.fadeFillSurface = pygame.Surface((146, 146))
        self.fadeFillSurface.set_colorkey((0, 0, 0))

        #Изменения меню
        if self.isChangeInstrument:
            if self.numInstrument == 1:
                self.sfx = "Grand Piano"
            elif self.numInstrument == 2:
                self.sfx = "Flute"
            elif self.numInstrument == 3:
                self.sfx = "Contrabass"
            elif self.numInstrument == 4:
                self.sfx = "fork"
            elif self.numInstrument == 5:
                self.sfx = "oh"
            for i in range(1, 21):
                self.snd[i] = Sound(str(i), self.sfx)
                self.snd[i].setVolume(self.volumeSnd)
            self.instrumentImage.createStaticImage(494 + 78, 573 + 78,
                                                   "center", self.sfx,
                                                   "instruments")
            #self.textCurrentSamples.createText(self.sfx, "times", 36, COLOR.BLACK)
            self.isChangeInstrument = 0

        #Изменение громкости
        if self.isChangeVolumeSfx:
            for i in range(1, 21):
                self.snd[i].setVolume(self.volumeSnd)
            #self.textCurrentVolume.createText(self.volumeSnd, "times", 36, COLOR.BLACK)
            for i in range(1, 10):
                self.sndDrum[i].setVolume(self.volumeSnd)
            self.isChangeVolumeSfx = 0

        #Изменение fade
        if self.isChangeStrFade:
            self.textCurrentStrFade.createText(self.strFade, "times", 30,
                                               COLOR.DARKRED)
            self.isChangeStrFade = 0

        #Изменение нот
        if self.isChangeNotes:
            if self.numNotes == 0:
                self.notes = "None"
                self.isShowNotesPage = 0
            else:
                if self.numNotes == 1:
                    self.notes = "Samidare"
                elif self.numNotes == 2:
                    self.notes = "Shreksophone"
                self.numNotesPage = 1
                self.notesImage = Image()
                #self.notesImage.createStaticImage(960, 47, "top", str(self.numNotesPage), self.notes, "notes")
                self.notesImage.createStaticImage(960, 5, "top",
                                                  str(self.numNotesPage),
                                                  self.notes, "notes")
                self.isShowNotesPage = 1
            self.notesFrameImage.createStaticImage(494 + 78 + 204 + 204 + 204,
                                                   573 + 78, "center",
                                                   self.notes, self.notes,
                                                   "notes")
            self.textCurrentNotes.createText(self.notes, "times", 24,
                                             COLOR.BLACK)
            self.isChangeNotes = 0
            self.isChangeNotesPage = 0

        #Изменение страницы ноты
        if self.isChangeNotesPage and self.numNotes != 0:
            if self.numNotesPage < self.pagesOfNotes[self.numNotes]:
                self.numNotesPage += 1
                #self.notesImage.createStaticImage(960, 47, "top", str(self.numNotesPage), self.notes, "notes")
                self.notesImage.createStaticImage(960, 5, "top",
                                                  str(self.numNotesPage),
                                                  self.notes, "notes")
                self.isChangeNotesPage = 0

        #Изменение положения фрейма
        self.frameImage.changeRectImage(494 + 78 + 204 *
                                        (self.numNavigation - 1),
                                        573 + 78,
                                        pos="center")

        #Отрисовка изображений/текста
        self.backgroundGameImage.showStaticImage()
        if self.isShowNotesPage:
            self.notesImage.showStaticImage()
        self.pianoImage.showStaticImage()
        self.drumImage.showStaticImage()

        self.volumeFill.changeRectImage(0, (100 - self.volumeSnd) * 1.5,
                                        "topleft")
        self.volumeFillSurface.blit(self.volumeFill.image,
                                    self.volumeFill.rect)
        self.fadeFill.changeRectImage(0, (2000 - self.strFade) * 0.075,
                                      "topleft")
        self.fadeFillSurface.blit(self.fadeFill.image, self.fadeFill.rect)
        OPTIONS.getReg("surf_main").blit(self.volumeFillSurface,
                                         (494 + 5 + 204, 573 + 5))
        OPTIONS.getReg("surf_main").blit(self.fadeFillSurface,
                                         (494 + 5 + 204 + 204, 573 + 5))
        self.volumeFrame.showStaticImage()
        self.fadeFrame.showStaticImage()

        self.instrumentImage.showStaticImage()
        self.notesFrameImage.showStaticImage()
        #self.textSamples.showStaticText()
        #self.textVolume.showStaticText()
        self.textStrFade.showStaticText()
        self.textNotes.showStaticText()
        #self.textCurrentSamples.showText(200, 250)
        #self.textCurrentVolume.showText(200, 450)
        self.textCurrentStrFade.showText(494 + 78 + 204 + 204, 573 + 96)
        if self.numNotes > 0:
            self.textCurrentNotes.showText(960, 20)

        self.frameImage.showStaticImage()

        #Проверка на отжатие клавиши и её отрисовка
        for i in range(1, 21):
            if not pygame.mixer.Channel(self.snd[i].channelPlay).get_busy():
                self.isPressedKeyDict[i] = 0
            if self.isPressedKeyDict[i] == 1:
                self.imgPressedKey[i].showStaticImage()
        for i in range(1, 10):
            if self.isPressedKeyDictDrum[i] == 1:
                self.imgPressedKeyDrum[i].showStaticImage()

        for i in range(1, 12):
            self.textWhite[i].showStaticText()
        for i in range(12, 21):
            self.textBlack[i].showStaticText()

        if self.eggTimer != 0:
            self.eggTimer -= 1

        pygame.display.update()