예제 #1
0
def main():
    # 初期化
    pygame.init()
    pygame.mixer.init()

    # 画面生成
    pygame.display.set_mode((w, h), 0, 32)
    screen = pygame.display.get_surface()
    pygame.display.set_caption('Dangomushi')

    title = None
    gs = None
    scene = SC_Title

    # ゲームループ
    while True:
        # タイトル
        if scene == SC_Title:
            if title == None:
                title = Title(screen)
            title.Update()
            title.Draw()
            if title.finished:
                scene = SC_GetStar
                title = None

        # 星集め
        elif scene == SC_GetStar:
            if gs == None:
                gs = GetStar(screen)
            gs.Update()
            gs.Draw()
            if gs.finished:
                scene = SC_Title
                gs = None
예제 #2
0
class App:
    def __init__(self):
        pyxel.init(160, 120, caption="Kotonoha Run")
        pyxel.load(os.getcwd() + "/my_resource.pyxel")

        self.gama_state = GamaState.Title
        self.title = Title()
        self.gama_main = GamaMain()
        self.gama_result = GamaResult()

        pyxel.run(self.Update, self.Draw)

    def Update(self):
        prev_gama_state = self.gama_state
        if self.gama_state == GamaState.Title:
            self.gama_state = self.title.Update()
        elif self.gama_state == GamaState.GamaMain:
            self.gama_state = self.gama_main.Update()
        elif self.gama_state == GamaState.GamaResult:
            self.gama_state = self.gama_result.Update()
        elif self.gama_state == GamaState.Exit:
            pyxel.quit()
        else:
            raise Exception("updateで存在しないGamaStateが選択されました。")

        if prev_gama_state != self.gama_state:
            if self.gama_state == GamaState.GamaMain:
                self.gama_main = GamaMain()
            if self.gama_state == GamaState.GamaResult:
                self.gama_result.SetResutl(self.gama_main)

    def Draw(self):
        pyxel.cls(0)
        if self.gama_state == GamaState.Title:
            self.title.Draw()
        elif self.gama_state == GamaState.GamaMain:
            self.gama_main.Draw()
        elif self.gama_state == GamaState.GamaResult:
            self.gama_result.Draw()
        elif self.gama_state == GamaState.Exit:
            pass
        else:
            raise Exception("drowで存在しないGamaStateが選択されました。")