示例#1
0
    def show(self, tof):
        super().show(tof)

        self._btnMap1.show(tof)
        self._lblTitle.show(tof)

        Arcade.setSelectedGUI(self._btnMap1)
示例#2
0
    def initGUI(self):
        self.SpaceInvadersLogo = Label.Label(x=0, y=60)
        self.SpaceInvadersLogo.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self.SpaceInvadersLogo.addText("Space Invaders", Arcade.FONT,
                                       Arcade.GUI_COLOR_ORANGE, self.LOGOFONT)

        self.startBTN = Button.Button(y=215, width=250, height=50)
        self.startBTN.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self.startBTN.addText("START", Arcade.FONT, Arcade.WHITE, 24)
        self.startBTN._borderColor = Arcade.BLUE

        self.leaderboardBTN = Button.Button(y=275, width=250, height=50)
        self.leaderboardBTN.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self.leaderboardBTN.addText("LEADERBOARD", Arcade.FONT, Arcade.WHITE,
                                    24)
        self.leaderboardBTN._borderColor = Arcade.BLUE

        self.quitBTN = Button.Button(y=335, width=250, height=50)
        self.quitBTN.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self.quitBTN.addText("QUIT", Arcade.FONT, Arcade.WHITE, 24)
        self.quitBTN._borderColor = Arcade.BLUE

        Arcade.setSelectedGUI(self.startBTN)
        self.startBTN.setNeighbors(None, self.leaderboardBTN, None, None)
        self.leaderboardBTN.setNeighbors(self.startBTN, self.quitBTN, None,
                                         None)
        self.quitBTN.setNeighbors(self.leaderboardBTN, None, None, None)
示例#3
0
    def update(self, screen):
        super().update(screen)

        self._game.update(screen)

        if(self._game.isQuit()):
            Arcade.setCurrentState(Arcade.gamesState)
            self._game = None
    def show(self, defenders):
        if (len(defenders) > 0):
            self.setSelectedDefender(defenders[0])
            self._lblNoDefender.show(False)
            self._lblNoDefender2.show(False)

            Arcade.setSelectedGUI(self._btnSelect)
        else:
            self._lblNoDefender.show(True)
            self._lblNoDefender2.show(True)
示例#5
0
    def _updateGuiHovered(self):
        self._onNeighborBottom = False
        self._onNeighborLeft = False
        self._onNeighborRight = False
        self._onNeighborTop = False

        if (Arcade.SELECTED_GUI == self):
            if (Arcade.JOYSTICK_PRESSED_LEFT):  #Left
                if (self._neighborLeft != None
                        and self._neighborLeft.isShown()):
                    Arcade.setSelectedGUI(self._neighborLeft)
                    Arcade.JOYSTICK_PRESSED_LEFT = False
                    self._onNeighborLeft = True
            elif (Arcade.JOYSTICK_PRESSED_UP):  #Top
                if (self._neighborTop != None and self._neighborTop.isShown()):
                    Arcade.setSelectedGUI(self._neighborTop)
                    Arcade.JOYSTICK_PRESSED_UP = False
                    self._onNeighborTop = True
            elif (Arcade.JOYSTICK_PRESSED_DOWN):  #Bottom
                if (self._neighborBottom != None
                        and self._neighborBottom.isShown()):
                    Arcade.setSelectedGUI(self._neighborBottom)
                    Arcade.JOYSTICK_PRESSED_DOWN = False
                    self._onNeighborBottom = True
            elif (Arcade.JOYSTICK_PRESSED_RIGHT):  #Right
                if (self._neighborRight != None
                        and self._neighborRight.isShown()):
                    Arcade.setSelectedGUI(self._neighborRight)
                    Arcade.JOYSTICK_PRESSED_RIGHT = False
                    self._onNeighborRight = True
示例#6
0
    def __init__(self):
        super().__init__()

        self._image = GUI.GUI(width=300, height=300)
        self._image.alignHorizontally(None, Arcade.ALIGN_CENTER, 200)
        self._image.alignVertically(None, Arcade.ALIGN_CENTER)
        self._image.addImage(pygame.image.load("res/images/logo.png"))

        self._frame = Frame.Frame(x=200, y=200, width=320, height=400)
        self._frame.addBorder(2, Arcade.GUI_COLOR_BLUE)
        self._frame.alignHorizontally(None, Arcade.ALIGN_CENTER, -200)
        self._frame.alignVertically(None, Arcade.ALIGN_CENTER, 20)

        self._lblTitle = Label.Label()
        self._lblTitle.addText("SIMPLE ARCADE UF", Arcade.FONT,
                               Arcade.GUI_COLOR_BLUE, 60)
        self._lblTitle.addUnderline(2, Arcade.GUI_COLOR_BLUE, -5)
        self._lblTitle.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self._lblTitle.alignVertically(None, Arcade.ALIGN_TOP, 25)

        self._lblWelcome = Label.Label()
        self._lblWelcome.addText("VÄLKOMMEN", Arcade.FONT,
                                 Arcade.GUI_COLOR_BLUE, 35)
        self._lblWelcome.addUnderline(2, Arcade.GUI_COLOR_BLUE, -5)
        self._lblWelcome.alignHorizontally(self._frame, Arcade.ALIGN_CENTER)
        self._lblWelcome.alignVertically(self._frame, Arcade.ALIGN_TOP, 25)

        self._btnGames = Button.Button(width=270, height=50)
        self._btnGames.addText("SPEL", Arcade.FONT, Arcade.GUI_COLOR_RED, 30)
        self._btnGames.alignHorizontally(self._frame, Arcade.ALIGN_CENTER)
        self._btnGames.alignVertically(self._frame, Arcade.ALIGN_CENTER, -50)

        self._btnHighScores = Button.Button(width=270, height=50)
        self._btnHighScores.addText("HIGHSCORES", Arcade.FONT,
                                    Arcade.GUI_COLOR_RED, 30)
        self._btnHighScores.alignHorizontally(self._frame, Arcade.ALIGN_CENTER)
        self._btnHighScores.alignVertically(self._frame, Arcade.ALIGN_CENTER,
                                            30)

        self._btnExit = Button.Button(width=270, height=50)
        self._btnExit.addText("AVSLUTA", Arcade.FONT, Arcade.GUI_COLOR_RED, 30)
        self._btnExit.alignHorizontally(self._frame, Arcade.ALIGN_CENTER)
        self._btnExit.alignVertically(self._frame, Arcade.ALIGN_CENTER, 110)

        self._btnGames.setNeighbors(None, self._btnHighScores, None, None)
        self._btnHighScores.setNeighbors(self._btnGames, self._btnExit, None,
                                         None)
        self._btnExit.setNeighbors(self._btnHighScores, None, None, None)

        Arcade.setSelectedGUI(self._btnGames)
示例#7
0
    def __init__(self):

        #Main frame
        self.Main_frame = Frame.Frame(x=0, y=200, width=500, height=300)
        self.Main_frame.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self.Main_frame.updateAttachedGuis(True)

        #subframe top
        self.Sub_frame_top = Frame.Frame(x=0, y=200, width=500, height=150)
        self.Sub_frame_top.alignVertically(self.Main_frame, Arcade.ALIGN_TOP)
        self.Sub_frame_top.alignHorizontally(self.Main_frame,
                                             Arcade.ALIGN_CENTER)
        self.Sub_frame_top.updateAttachedGuis(True)

        #subframe bottom
        self.Sub_frame_bottom = Frame.Frame(x=0, y=350, width=500, height=150)
        self.Sub_frame_bottom.alignVertically(self.Main_frame,
                                              Arcade.ALIGN_BOTTOM)
        self.Sub_frame_bottom.alignHorizontally(self.Main_frame,
                                                Arcade.ALIGN_CENTER)
        self.Sub_frame_bottom.updateAttachedGuis(True)

        #Main menu label
        self.Label = Label.Label(x=0, y=10)
        self.Label.alignHorizontally(None, Arcade.ALIGN_CENTER)
        self.Label.addText("GeoRush", Arcade.FONT, "white", 100)

        #Main menu button | Start
        self.B_START = Button.Button(x=0, y=0, width=120, height=60)
        self.B_START.alignHorizontally(self.Sub_frame_top, Arcade.ALIGN_CENTER)
        self.B_START.alignVertically(self.Sub_frame_top, Arcade.ALIGN_CENTER)
        self.B_START.addText("Start", Arcade.FONT, "white", 20)

        #Main menu button | Quit
        self.B_QUIT = Button.Button(x=0, y=30, width=120, height=60)
        self.B_QUIT.alignHorizontally(self.Sub_frame_bottom,
                                      Arcade.ALIGN_CENTER)
        self.B_QUIT.alignVertically(self.Sub_frame_bottom, Arcade.ALIGN_TOP)
        self.B_QUIT.addText("Quit", Arcade.FONT, "white", 20)

        self.Main_frame.attachGui(self.Sub_frame_top)
        self.Main_frame.attachGui(self.Sub_frame_bottom)

        self.Sub_frame_top.attachGui(self.B_START)
        self.Sub_frame_bottom.attachGui(self.B_QUIT)

        Arcade.setSelectedGUI(self.B_START)
        self.B_START.setNeighbors(None, self.B_QUIT, None, None)
        self.B_QUIT.setNeighbors(self.B_START, None, None, None)
示例#8
0
    def update(self, screen, balloons):
        if (self._use == False): return

        super().update(screen, balloons)

        self._attackRange = int(self._startAttackRange *
                                self._upgrades[0].getRangeBonus())

        if (self._targetBalloon != None):
            self.removeTargetIfNotInRange()

        self._iceAnim.update()
        if (self._onFire):
            self._iceAnim.start()
        if (self._iceAnim.isStarted()):
            screen.blit(self._iceAnim.getCurrentFrame(),
                        (self._x + self._size / 2 -
                         self._iceAnim.getCurrentFrame(0).get_width() / 2,
                         self._y + self._size / 2 -
                         self._iceAnim.getCurrentFrame(0).get_height() / 2))

        if (self._iceAnim.isDone()):
            self._iceAnim.reset()
            for balloon in balloons:
                currentDistance = Arcade.getDistance(
                    (self._x + self._size / 2, self._y + self._size / 2),
                    (balloon.getX() + balloon.getSize() / 2,
                     balloon.getY() + balloon.getSize() / 2))
                if (currentDistance < self._attackRange * 2):
                    balloon.hit(createNextFrozen=True)
示例#9
0
    def updateSelect(self, defenders):
        global SELECT
        if (SELECT == False): return

        keys = pygame.key.get_pressed()

        if (Arcade.BUTTON_PRESSED_1):
            Arcade.BUTTON_PRESSED_1 = False

            minDist = 0
            closestDefender = None

            for defender in defenders:
                dist = Arcade.getDistance(
                    (defender.getX() + defender.getSize() / 2,
                     defender.getY() + defender.getSize() / 2),
                    (self._cursorX + self._cursorSize / 2,
                     self._cursorY + self._cursorSize / 2))
                if (dist < minDist or closestDefender == None):
                    minDist = dist
                    closestDefender = defender

            self._defender = closestDefender
            self._selected = True
            SELECT = False

        if (Arcade.BUTTON_PRESSED_2 or Arcade.BUTTON_PRESSED_3
                or Arcade.BUTTON_PRESSED_4):
            SELECT = False
            self._cancel = True
示例#10
0
    def update(self, screen, money):

        self._frame.update(screen)
        self._lblSelectedName.update(screen)

        for i in range(len(self._buttons)):
            btn = self._buttons[i]
            btn.update(screen)

            if (btn.isHovered()):
                self._lblSelectedName.setText(self._defenders[i].getName())

            if (btn.isClicked() and money >= int(btn.getLabel().getText())):
                Arcade.BUTTON_PRESSED_1 = False
                PlaceDefenderGUI.DEFENDER = self._defenders[i]
                self._hasBoughtDefender = True
                self._boughtDefender = self._defenders[i]
                self._boughtDefenderCost = int(btn.getLabel().getText())
                Arcade.setSelectedGUI(None)
示例#11
0
    def update(self, screen):
        super().update(screen)

        self._lblTitle.update(screen)
        self._image.update(screen)

        self._frame.update(screen)
        self._lblWelcome.update(screen)
        self._btnGames.update(screen)
        self._btnExit.update(screen)
        self._btnHighScores.update(screen)

        if (self._btnGames.isClicked()):
            Arcade.setCurrentState(Arcade.gamesState)

        if (self._btnExit.isClicked()):
            Arcade.isRunning = False

            if (Arcade.PLATFORM == Arcade.PLATFORM_ARCADE):
                call("sudo shutdown -P now", shell=True)
示例#12
0
    def update(self, screen):
        self._frame.update(screen)
        self._lblTitle.update(screen)
        self._lblNoDefender.update(screen)
        self._lblNoDefender2.update(screen)

        if (self._selectedDefender == None): return

        self._btnSelect.update(screen)
        self._btnMove.update(screen)
        self._lblUpgrades.update(screen)

        for btn in self._upgradeButtons:
            btn.update(screen)

        if (self._btnMove.isClicked()):
            PlaceDefenderGUI.DEFENDER = self._selectedDefender
            Arcade.setSelectedGUI(None)

        if (self._btnSelect.isClicked()):
            SelectDefenderGUI.SELECT = True
            Arcade.setSelectedGUI(None)
示例#13
0
    def updateCollision(self, balloons):
        if (self._use == False or self._update == False): return

        for balloon in balloons:
            currentDistance = Arcade.getDistance(
                (self._x + self._width / 2, self._y + self._height / 2),
                (balloon.getX() + balloon.getSize() / 2,
                 balloon.getY() + balloon.getSize() / 2))

            if (currentDistance < balloon.getSize() / 2):
                balloon.hit(self)
                self._projectileHealth -= 1
                self._hit = True

                if (self._projectileHealth == 0):
                    if (self._waitToRemove == True):
                        self._update = False
                    else:
                        PROJECTILES.remove(self)
                    self._hitRemove = True
示例#14
0
    def updatePlace(self, defenders):
        global DEFENDER
        if(self._defender == None): return

        canPlace = True

        for d in defenders:
            if(d == self._defender): continue
            
            dist = Arcade.getDistance((self._defender.getX()+self._defender.getSize()/2, self._defender.getY()+self._defender.getSize()/2), (d.getX()+d.getSize()/2, d.getY()+d.getSize()/2))

            if(dist < self._defender.getSize()/2 + d.getSize()/2):
                canPlace = False

        #[TODO] Check for roads

        keys = pygame.key.get_pressed()

        if(Arcade.BUTTON_PRESSED_1 and canPlace):
            Arcade.BUTTON_PRESSED_1 = False
            if(self._placeNewDefender == True):
                defenders.append(self._defender)
            else:
                self._defender.setSelected(True)
            self._defender.setCanAttack(True)
            self._defender.showAttackRange(False)
            self._defender = None
            DEFENDER = None
            self._placed = True
        
        if(Arcade.BUTTON_PRESSED_2 or Arcade.BUTTON_PRESSED_3 or Arcade.BUTTON_PRESSED_4):
            if(self._placeNewDefender == False):
                self._defender.showAttackRange(False)
                self._defender.setCanAttack(True)
                self._defender.setSelected(True)
                self._defender.setX(self._startX)
                self._defender.setY(self._startY)
            
            self._defender = None
            DEFENDER = None
            self._cancel = True
示例#15
0
    def update(self, screen, balloons):
        if(self._use == False): return

        if(self._hitRemove == True):
            self._animExplosion.start()
            self._hitRemove = False

            for balloon in balloons:
                currentDistance = Arcade.getDistance((self._x+self._width/2,self._y+self._height/2), (balloon.getX()+balloon.getSize()/2,balloon.getY()+balloon.getSize()/2))
                if(currentDistance < self._explosionRange*2):
                    balloon.hit(self)

        if(self._animExplosion.isStarted()):
            self._animExplosion.update()
            screen.blit(self._animExplosion.getCurrentFrame(), (self._x - self._animExplosion.getCurrentFrame().get_width()/2, self._y - self._animExplosion.getCurrentFrame().get_height()/2))
        
        if(self._animExplosion.isDone()):
            Projectile.PROJECTILES.remove(self)

        if(self._update == False): return

        super().update(screen, balloons)
示例#16
0
    def __init__(self, image, speed, x, y, balloon, health, angle=0, use=True):
        super().__init__(x, y, 1, draw=False, color=None)

        self._image = image
        self._speed = speed
        self._width = image.get_width()
        self._height = image.get_height()
        self._projectileHealth = health
        self._use = use
        self._hit = False
        self._hitRemove = False
        self._waitToRemove = False
        self._update = True
        self._id = 0

        if (use == False): return
        self._dir = math.atan2(
            (y + self._height / 2) - (balloon.getY() + balloon.getSize() / 2),
            (x + self._width / 2) -
            (balloon.getX() +
             balloon.getSize() / 2)) + math.radians(180) + math.radians(angle)
        self._xVel = math.cos(self._dir) * self._speed
        self._yVel = math.sin(self._dir) * self._speed
        self._collisionDistance = Arcade.getDistance(
            (x + self._width / 2, y + self._height / 2),
            (balloon.getX() + balloon.getSize() / 2,
             balloon.getY() + balloon.getSize() / 2))

        self._x += self._xVel * 2
        self._y += self._yVel * 2

        self._image = pygame.transform.rotate(self._image,
                                              -(math.degrees(self._dir) + 90))
        self._rect = self._image.get_rect(center=image.get_rect(
            center=(self._x, self._y)).center)

        PROJECTILES.append(self)
示例#17
0
 def show(self):
     Arcade.setSelectedGUI(self._buttons[0])
     self.resetNewOpenMenu()
示例#18
0
 def show(self):
     Arcade.setSelectedGUI(self._btnStartOver)
示例#19
0
 def onShow(self):
     Arcade.setSelectedGUI(self.PerClickUpgrade)
     self.Labels()
示例#20
0
import pygame, os
dir_path = os.path.dirname(os.path.realpath(__file__))
os.chdir(dir_path)

from libs.SimpleArcade.gui import Frame, Button, Label, GUI
from libs.SimpleArcade import Arcade, GameList
from states import StartState, GamesState, PlayState

Arcade.init()
GameList.initGames()

Arcade.startState = StartState.StartState()
Arcade.gamesState = GamesState.GamesState()
Arcade.playState = PlayState.PlayState()

Arcade.setCurrentState(Arcade.startState)

while Arcade.isRunning:
    for event in pygame.event.get():
        if (event.type == pygame.QUIT):
            Arcade.isRunning = False

    Arcade.screen.fill((20, 20, 20))
    Arcade.update()
    Arcade.currentState.update(Arcade.screen)

    key_pressed = pygame.key.get_pressed()
    if (key_pressed[pygame.K_ESCAPE]):
        Arcade.isRunning = False

    pygame.display.flip()
示例#21
0
    def onShow(self):
        super().onShow()

        Arcade.setSelectedGUI(self._btnGames)
示例#22
0
 def show(self):
     Arcade.setSelectedGUI(self._buttons[0])