Example #1
0
class GameOver(dotworld.DotWorld):
    def __init__(self, score):
        dotworld.DotWorld.__init__(self)
        self.counter = 0
        self.limit = 400
        self.alpha = 0
        self.animState = 1

        self.label = DotText("Game Over", 32, (0, 0, 0), (255, 255, 255))
        self.scorelabel = DotText(
            "Score: " + str(int(score / GameDefine.SCORE_DECIMAL)), 24,
            (0, 0, 0), (255, 255, 255))

    def onAttachScreen(self):
        pygame.mixer.music.stop()
        self.label.centerX(self.screen.width)
        self.label.centerY(self.screen.height)

        self.scorelabel.centerX(self.screen.width)
        self.scorelabel.marginTop(dotget(1))
        self.scorelabel.below(self.label)

    def changeAlpha(self):
        self.label.surface.set_alpha(self.alpha)
        self.scorelabel.surface.set_alpha(self.alpha)

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_BOOST:
            self.pause()

    def step(self):
        if self.active:
            self.changeAlpha()

            self.label.draw(self.screen.displaysurf)
            self.scorelabel.draw(self.screen.displaysurf)

            self.counter += 1

            if self.animState == 1:
                self.alpha += 2

                if self.alpha > 255:
                    self.animState = 2
                    self.counter = 0

            if self.animState == 2:
                self.counter += 1
                if self.counter > self.screen.fps * 3:
                    self.animState = 3

            if self.animState == 3:
                self.alpha -= 2
                if self.alpha <= 0:
                    self.pause()

        else:
            self.screen.setWorld(menuworld.MenuWorld())
            del self
Example #2
0
class GameOver(dotworld.DotWorld):

    def __init__(self, score):
        dotworld.DotWorld.__init__(self)
        self.counter = 0
        self.limit = 400
        self.alpha = 0
        self.animState = 1

        self.label = DotText("Game Over", 32, (0, 0, 0), (255, 255, 255))
        self.scorelabel = DotText("Score: " + str(int(score / GameDefine.SCORE_DECIMAL)), 24, (0, 0, 0), (255, 255, 255))

    def onAttachScreen(self):
        pygame.mixer.music.stop()
        self.label.centerX(self.screen.width)
        self.label.centerY(self.screen.height)

        self.scorelabel.centerX(self.screen.width)
        self.scorelabel.marginTop(dotget(1))
        self.scorelabel.below(self.label)

    def changeAlpha(self):
        self.label.surface.set_alpha(self.alpha)
        self.scorelabel.surface.set_alpha(self.alpha)

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_BOOST:
            self.pause()

    def step(self):
        if self.active:
            self.changeAlpha()

            self.label.draw(self.screen.displaysurf)
            self.scorelabel.draw(self.screen.displaysurf)

            self.counter += 1

            if self.animState == 1:
                self.alpha += 2

                if self.alpha > 255:
                    self.animState = 2
                    self.counter = 0

            if self.animState == 2:
                self.counter += 1
                if self.counter > self.screen.fps * 3:
                    self.animState = 3

            if self.animState == 3:
                self.alpha -= 2
                if self.alpha <= 0:
                    self.pause()

        else:
            self.screen.setWorld(menuworld.MenuWorld())
            del self
Example #3
0
class MenuWorld(dotworld.DotWorld):

    SELECTION_RACE = 0
    SELECTION_CREDITS = 1
    SELECTION_OPTIONS = 2

    UNSELECTED_ALPHA = 125

    def __init__(self):
        dotworld.DotWorld.__init__(self)

        self.label = DotText("", 32)
        self.logo = DotText("", 32, (0, 0, 0), (255, 255, 255), "assets/fonts/8-BIT-WONDER.ttf")
        self.goblet = DotGoblet()
        self.flag = DotFlag()
        self.heart = DotHeart()

        self.possibleLabels = {
            self.SELECTION_RACE: _("Start Race"),
            self.SELECTION_CREDITS: _("Credits"),
            self.SELECTION_OPTIONS: _("Options")
        }
        self.isPressing = False
        self.selected = self.SELECTION_RACE

    def onAttachScreen(self):
        self.drawMenu()

    def drawMenu(self):
        self.goblet = DotGoblet()
        self.flag = DotFlag()
        self.heart = DotHeart()

        self.logo.setText("Steering All", 32, (0, 0, 0), (255, 255, 255), "assets/fonts/8-BIT-WONDER.ttf")
        self.logo.x = dotget(3)
        self.logo.centerX(self.screen.width)

        selectedItem = self.getSelectedItem()
        selectedItem.setMedium()
        selectedItem.createSurface()
        selectedItem.centerX(self.screen.width)
        selectedItem.centerY(self.screen.height)

        self.label.setText(self.possibleLabels[self.selected], 32)
        self.label.marginTop(dotget(1))
        self.label.below(selectedItem)
        self.label.centerX(self.screen.width)

        # previousItem = self.getPreviousItem()
        # previousItem.setDotAlpha(self.UNSELECTED_ALPHA)
        # previousItem.setSmall()
        # previousItem.createSurface()
        # previousItem.marginLeft(dotget(1))
        # previousItem.alignLeft()
        #
        # previousItem.centerY(self.screen.height)
        #
        # nextItem = self.getNextItem()
        # nextItem.setDotAlpha(self.UNSELECTED_ALPHA)
        # nextItem.setSmall()
        # nextItem.createSurface()
        # nextItem.marginRight(dotget(1))
        # nextItem.alignRight(self.screen.width)
        #
        # nextItem.centerY(self.screen.height)


    def getSelectedItem(self):
        if self.selected == self.SELECTION_RACE:
            return self.goblet

        if self.selected == self.SELECTION_CREDITS:
            return self.heart

        if self.selected == self.SELECTION_OPTIONS:
            return self.flag

    def getPreviousItem(self):
        if self.selected == self.SELECTION_RACE:
            return self.flag

        if self.selected == self.SELECTION_CREDITS:
            return self.goblet

        if self.selected == self.SELECTION_OPTIONS:
            return self.heart

    def getNextItem(self):
        if self.selected == self.SELECTION_RACE:
            return self.heart

        if self.selected == self.SELECTION_CREDITS:
            return self.flag

        if self.selected == self.SELECTION_OPTIONS:
            return self.goblet

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_EXIT:
            self.screen.turnOff()

        # if inputResult == GameDefine.COMMAND_RIGHT:
        #     play_sound('assets/music/effects/select.wav')
        #     self.selected = (self.selected + 1) % 3
        #     self.drawMenu()
        #
        # if inputResult == GameDefine.COMMAND_LEFT:
        #     play_sound('assets/music/effects/select.wav')
        #     nextSelect = (self.selected - 1)
        #     if(nextSelect < 0):
        #         nextSelect = 2
        #     self.selected = nextSelect
        #     self.drawMenu()

        if inputResult == GameDefine.COMMAND_BOOST:
            play_sound('assets/music/effects/levelup.wav')
            self.isPressing = True

        if (inputResult == GameDefine.COMMAND_UNBOOST) and self.isPressing == True:
            self.screen.setWorld(DotGame(3, 0, 1, True))
            del self

    def step(self):
        self.logo.draw(self.screen.displaysurf)
        self.goblet.draw(self.screen.displaysurf)
        # self.flag.draw(self.screen.displaysurf)
        # self.heart.draw(self.screen.displaysurf)
        self.label.draw(self.screen.displaysurf)
Example #4
0
class LogoSplashWorld(dotworld.DotWorld):
    def __init__(self):
        dotworld.DotWorld.__init__(self)
        self.counter = 0
        self.limit = 400
        self.alpha = 0
        self.animState = 1

        self.logo = DotPairg()
        self.label = DotText(
            "PAIRG - Physical Artifacts of Interaction Research Group", 16,
            (0, 0, 0), (255, 255, 255))
        self.sublabel = DotText(
            _("Developed by") + " Alison Bento", 16, (0, 0, 0),
            (255, 255, 255))

    def onAttachScreen(self):
        self.logo.setMedium()
        self.logo.centerX(self.screen.width)
        self.logo.centerY(self.screen.height)
        self.logo.createSurface()

        self.label.centerX(self.screen.width)
        self.label.marginTop(dotget(1))
        self.label.below(self.logo)

        self.sublabel.centerX(self.screen.width)
        self.sublabel.marginTop(dotget(1))
        self.sublabel.below(self.label)

    def changeAlpha(self):
        self.logo.setDotAlpha(self.alpha)
        # self.logo.createSurface()

        self.label.surface.set_alpha(self.alpha)
        self.sublabel.surface.set_alpha(self.alpha)

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_EXIT:
            self.screen.turnOff()

        if inputResult == GameDefine.COMMAND_BOOST:
            self.pause()

    def step(self):
        if self.active:
            self.changeAlpha()

            self.logo.draw(self.screen.displaysurf)
            self.label.draw(self.screen.displaysurf)
            self.sublabel.draw(self.screen.displaysurf)

            self.counter += 1

            if self.animState == 1:
                self.alpha += 2

                if self.alpha > 255:
                    self.animState = 2
                    self.counter = 0

            if self.animState == 2:
                self.counter += 1
                if self.counter > self.screen.fps * 3:
                    self.animState = 3

            if self.animState == 3:
                self.alpha -= 2
                if self.alpha <= 0:
                    self.pause()

        else:
            self.screen.setWorld(ufrnsplashworld.UfrnSplashWorld())
            del self
Example #5
0
class UfrnSplashWorld(dotworld.DotWorld):
    def __init__(self):
        dotworld.DotWorld.__init__(self)
        self.counter = 0
        self.limit = 400
        self.alpha = 0
        self.animState = 1

        self.logo = DotUFRN()
        self.label = DotText(_("Universidade Federal do Rio Grande do Norte"),
                             16, (0, 0, 0), (255, 255, 255))

    def onAttachScreen(self):
        self.logo.centerX(self.screen.width)
        self.logo.centerY(self.screen.height)
        self.logo.createSurface()

        self.label.centerX(self.screen.width)
        self.label.marginTop(dotget(1))
        self.label.below(self.logo)

    def changeAlpha(self):
        self.logo.setDotAlpha(self.alpha)
        self.logo.createSurface()

        self.label.surface.set_alpha(self.alpha)

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_EXIT:
            self.screen.turnOff()

        if inputResult == GameDefine.COMMAND_BOOST:
            self.pause()

    def step(self):
        if self.active:
            self.changeAlpha()

            self.logo.draw(self.screen.displaysurf)
            self.label.draw(self.screen.displaysurf)

            self.counter += 1

            if self.animState == 1:
                self.alpha += 2

                if self.alpha > 255:
                    self.animState = 2
                    self.counter = 0

            if self.animState == 2:
                self.counter += 1
                if self.counter > self.screen.fps * 3:
                    self.animState = 3

            if self.animState == 3:
                self.alpha -= 2
                if self.alpha <= 0:
                    self.pause()
        else:
            self.screen.setWorld(MenuWorld())
            del self
class LogoSplashWorld(dotworld.DotWorld):

    def __init__(self):
        dotworld.DotWorld.__init__(self)
        self.counter = 0
        self.limit = 400
        self.alpha = 0
        self.animState = 1

        self.logo = DotPairg()
        self.label = DotText("PAIRG - Physical Artifacts of Interaction Research Group", 16, (0, 0, 0), (255, 255, 255))
        self.sublabel = DotText(_("Developed by") + " Alison Bento", 16, (0, 0, 0), (255, 255, 255))

    def onAttachScreen(self):
        self.logo.setMedium()
        self.logo.centerX(self.screen.width)
        self.logo.centerY(self.screen.height)
        self.logo.createSurface()

        self.label.centerX(self.screen.width)
        self.label.marginTop(dotget(1))
        self.label.below(self.logo)

        self.sublabel.centerX(self.screen.width)
        self.sublabel.marginTop(dotget(1))
        self.sublabel.below(self.label)

    def changeAlpha(self):
        self.logo.setDotAlpha(self.alpha)
        # self.logo.createSurface()

        self.label.surface.set_alpha(self.alpha)
        self.sublabel.surface.set_alpha(self.alpha)

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_EXIT:
            self.screen.turnOff()

        if inputResult == GameDefine.COMMAND_BOOST:
            self.pause()

    def step(self):
        if self.active:
            self.changeAlpha()

            self.logo.draw(self.screen.displaysurf)
            self.label.draw(self.screen.displaysurf)
            self.sublabel.draw(self.screen.displaysurf)

            self.counter += 1

            if self.animState == 1:
                self.alpha += 2

                if self.alpha > 255:
                    self.animState = 2
                    self.counter = 0

            if self.animState == 2:
                self.counter += 1
                if self.counter > self.screen.fps * 3:
                    self.animState = 3

            if self.animState == 3:
                self.alpha -= 2
                if self.alpha <= 0:
                    self.pause()

        else:
            self.screen.setWorld(ufrnsplashworld.UfrnSplashWorld())
            del self
class UfrnSplashWorld(dotworld.DotWorld):

    def __init__(self):
        dotworld.DotWorld.__init__(self)
        self.counter = 0
        self.limit = 400
        self.alpha = 0
        self.animState = 1

        self.logo = DotUFRN()
        self.label = DotText(_("Universidade Federal do Rio Grande do Norte"), 16, (0, 0, 0), (255, 255, 255))

    def onAttachScreen(self):
        self.logo.centerX(self.screen.width)
        self.logo.centerY(self.screen.height)
        self.logo.createSurface()

        self.label.centerX(self.screen.width)
        self.label.marginTop(dotget(1))
        self.label.below(self.logo)

    def changeAlpha(self):
        self.logo.setDotAlpha(self.alpha)
        self.logo.createSurface()

        self.label.surface.set_alpha(self.alpha)

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_EXIT:
            self.screen.turnOff()

        if inputResult == GameDefine.COMMAND_BOOST:
            self.pause()

    def step(self):
        if self.active:
            self.changeAlpha()

            self.logo.draw(self.screen.displaysurf)
            self.label.draw(self.screen.displaysurf)

            self.counter += 1

            if self.animState == 1:
                self.alpha += 2

                if self.alpha > 255:
                    self.animState = 2
                    self.counter = 0

            if self.animState == 2:
                self.counter += 1
                if self.counter > self.screen.fps * 3:
                    self.animState = 3

            if self.animState == 3:
                self.alpha -= 2
                if self.alpha <= 0:
                    self.pause()
        else:
            self.screen.setWorld(MenuWorld())
            del self
Example #8
0
class MenuWorld(dotworld.DotWorld):

    SELECTION_RACE = 0
    SELECTION_CREDITS = 1
    SELECTION_OPTIONS = 2

    UNSELECTED_ALPHA = 125

    def __init__(self):
        dotworld.DotWorld.__init__(self)

        self.label = DotText("", 32)
        self.logo = DotText("", 32, (0, 0, 0), (255, 255, 255),
                            "assets/fonts/8-BIT-WONDER.ttf")
        self.goblet = DotGoblet()
        self.flag = DotFlag()
        self.heart = DotHeart()

        self.possibleLabels = {
            self.SELECTION_RACE: _("Start Race"),
            self.SELECTION_CREDITS: _("Credits"),
            self.SELECTION_OPTIONS: _("Options")
        }
        self.isPressing = False
        self.selected = self.SELECTION_RACE

    def onAttachScreen(self):
        self.drawMenu()

    def drawMenu(self):
        self.goblet = DotGoblet()
        self.flag = DotFlag()
        self.heart = DotHeart()

        self.logo.setText("Steering All", 32, (0, 0, 0), (255, 255, 255),
                          "assets/fonts/8-BIT-WONDER.ttf")
        self.logo.x = dotget(3)
        self.logo.centerX(self.screen.width)

        selectedItem = self.getSelectedItem()
        selectedItem.setMedium()
        selectedItem.createSurface()
        selectedItem.centerX(self.screen.width)
        selectedItem.centerY(self.screen.height)

        self.label.setText(self.possibleLabels[self.selected], 32)
        self.label.marginTop(dotget(1))
        self.label.below(selectedItem)
        self.label.centerX(self.screen.width)

        # previousItem = self.getPreviousItem()
        # previousItem.setDotAlpha(self.UNSELECTED_ALPHA)
        # previousItem.setSmall()
        # previousItem.createSurface()
        # previousItem.marginLeft(dotget(1))
        # previousItem.alignLeft()
        #
        # previousItem.centerY(self.screen.height)
        #
        # nextItem = self.getNextItem()
        # nextItem.setDotAlpha(self.UNSELECTED_ALPHA)
        # nextItem.setSmall()
        # nextItem.createSurface()
        # nextItem.marginRight(dotget(1))
        # nextItem.alignRight(self.screen.width)
        #
        # nextItem.centerY(self.screen.height)

    def getSelectedItem(self):
        if self.selected == self.SELECTION_RACE:
            return self.goblet

        if self.selected == self.SELECTION_CREDITS:
            return self.heart

        if self.selected == self.SELECTION_OPTIONS:
            return self.flag

    def getPreviousItem(self):
        if self.selected == self.SELECTION_RACE:
            return self.flag

        if self.selected == self.SELECTION_CREDITS:
            return self.goblet

        if self.selected == self.SELECTION_OPTIONS:
            return self.heart

    def getNextItem(self):
        if self.selected == self.SELECTION_RACE:
            return self.heart

        if self.selected == self.SELECTION_CREDITS:
            return self.flag

        if self.selected == self.SELECTION_OPTIONS:
            return self.goblet

    def listen(self, inputResult):
        if inputResult == GameDefine.COMMAND_EXIT:
            self.screen.turnOff()

        # if inputResult == GameDefine.COMMAND_RIGHT:
        #     play_sound('assets/music/effects/select.wav')
        #     self.selected = (self.selected + 1) % 3
        #     self.drawMenu()
        #
        # if inputResult == GameDefine.COMMAND_LEFT:
        #     play_sound('assets/music/effects/select.wav')
        #     nextSelect = (self.selected - 1)
        #     if(nextSelect < 0):
        #         nextSelect = 2
        #     self.selected = nextSelect
        #     self.drawMenu()

        if inputResult == GameDefine.COMMAND_BOOST:
            play_sound('assets/music/effects/levelup.wav')
            self.isPressing = True

        if (inputResult
                == GameDefine.COMMAND_UNBOOST) and self.isPressing == True:
            self.screen.setWorld(DotGame(3, 0, 1, True))
            del self

    def step(self):
        self.logo.draw(self.screen.displaysurf)
        self.goblet.draw(self.screen.displaysurf)
        # self.flag.draw(self.screen.displaysurf)
        # self.heart.draw(self.screen.displaysurf)
        self.label.draw(self.screen.displaysurf)