Beispiel #1
0
    def drawwood(self, time, settings, screen, scale, currentxscroll, bottomypos):

        shelfwidth = currentxscroll + screen.get_width()
        
        
        shelfheight = 7*scale
        shelfdepth = 18*scale
        shelfdepthoffset = 7*scale
        shelfyoffset = 2*scale
        frontcolor = (127, 88, 26)

        frontrect = Rect(-currentxscroll+10*scale, bottomypos-shelfheight+shelfyoffset, 80*scale, shelfheight)

        # draw depth
        depthplist = [(frontrect[0], frontrect[1]),
                      (frontrect[0]+shelfdepthoffset, frontrect[1]-shelfheight),
                      (frontrect[0]+frontrect.width+shelfdepthoffset,
                       frontrect[1]-shelfheight),
                      (frontrect[0]+frontrect.width, frontrect[1])]
        gfxdraw.filled_polygon(screen, depthplist, variables.brighten(frontcolor, 13))
        
        # draw front
        gfxdraw.box(screen, frontrect, frontcolor)

        # draw right side
        rsideplist = [depthplist[-2], depthplist[-1],
                      (frontrect[0]+frontrect.width, frontrect[1]+shelfheight),
                      (depthplist[-2][0], depthplist[-2][1]+shelfheight)]
        gfxdraw.filled_polygon(screen, rsideplist, variables.brighten(frontcolor, -3))
Beispiel #2
0
    def drawwood(self, time, settings, screen, scale, bottomypos,
                 currentxscroll, endscroll):
        shelfheight = 7 * scale
        shelfdepth = 18 * scale
        shelfdepthoffset = 7 * scale
        shelfyoffset = 2 * scale
        frontcolor = (127, 88, 26)
        left = 10 * scale - currentxscroll
        shelfwidth = max(endscroll - scale * 10, screen.get_width() / 2)

        frontrect = Rect(left, bottomypos - shelfheight + shelfyoffset,
                         shelfwidth, shelfheight)

        # draw depth
        depthplist = [(frontrect[0], frontrect[1]),
                      (frontrect[0] + shelfdepthoffset,
                       frontrect[1] - shelfheight),
                      (frontrect[0] + frontrect.width + shelfdepthoffset,
                       frontrect[1] - shelfheight),
                      (frontrect[0] + frontrect.width, frontrect[1])]
        gfxdraw.filled_polygon(screen, depthplist,
                               variables.brighten(frontcolor, 13))

        # draw front
        gfxdraw.box(screen, frontrect, frontcolor)

        # draw right side
        rsideplist = [
            depthplist[-2], depthplist[-1],
            (frontrect[0] + frontrect.width, frontrect[1] + shelfheight),
            (depthplist[-2][0], depthplist[-2][1] + shelfheight)
        ]
        gfxdraw.filled_polygon(screen, rsideplist,
                               variables.brighten(frontcolor, -3))
Beispiel #3
0
def _draw_grid(screen, game):
    start_off = [i + 2 for i in Config.board_position]
    rect = Config.cell_size

    food_location = (game.board.get_food_location())
    for y in range(Config.table_size):
        dy = start_off[1] + y * rect
        for x in range(Config.table_size):
            dx = start_off[0] + x * rect

            if food_location == (x, y):
                screen.blit(apple, (dx + 1, dy + 1))
            else:
                pygame.draw.rect(screen, Colors.deep_grey, (dx, dy, rect - 1, rect - 1))
            # draw snake
            head = game.player.head
            body: List[Body] = game.player.body
            if x == head.x and y == head.y:
                pygame.draw.rect(screen, Colors.green, (dx + 1, dy + 1, rect - 2, rect - 2))
                # Half and quarter size (1/4) of the cell
                half, q1 = Config.cell_size // 2, Config.cell_size // 4

                if game.player.direction == Direction.UP or game.player.direction == Direction.DOWN:
                    draw.filled_circle(screen, dx + q1, dy + half, 1, Colors.red)
                    draw.filled_circle(screen, dx + half + q1, dy + half, 1, Colors.red)
                else:
                    draw.filled_circle(screen, dx + half, dy + q1, 1, Colors.red)
                    draw.filled_circle(screen, dx + half, dy + half + q1, 1, Colors.red)

            for i, part in enumerate(body):
                if x == part.location.x and y == part.location.y:
                    # Striped color pattern for the snake
                    color = Colors.deep_dark_green if (i % 4 == 0 and i != 0) else Colors.dark_green
                    draw.box(screen, (dx + 1, dy + 1, rect - 2, rect - 2), color)
Beispiel #4
0
def hover_menu(fen, x_clic, y_clic):
    """Similaire a un hover en CSS, change la couleur lorsqu'on passe dessus"""

    for i in range(len(rect_menu)):
        if rect_menu[i][0] <= x_clic <= (
                rect_menu[i][0] + rect_menu[i][2]
        ) and rect_menu[i][1] <= y_clic <= (rect_menu[i][1] + rect_menu[i][3]):

            gfxdraw.box(fen, rect_menu[i], white)
            diff = "Niveau  " + str(
                i + 1
            )  #  "i+1" est nécessaire car sans ca on afficherai Niveau 0 car l'indice de la premiere valeur de la liste....
            texte(int(0.00013 * x_screen * y_screen), diff, black,
                  0.4 * x_screen,
                  (i + 1) * 0.25 * y_screen + 0.1166 * y_screen,
                  fen)  #  CF ligne.116 :/
            actualise()
        else:
            gfxdraw.box(fen, rect_menu[i], orange)
            diff = "Niveau  " + str(i + 1)  #  CF ligne.116 :/
            texte(int(0.00013 * x_screen * y_screen), diff, black,
                  0.4 * x_screen,
                  (i + 1) * 0.25 * y_screen + 0.1166 * y_screen,
                  fen)  #  CF ligne.116 :/

            actualise()
Beispiel #5
0
    def draw(self,
             time,
             settings,
             screen,
             scale,
             position,
             highlighted=False,
             highlightcolor=(211, 214, 64)):
        pic = getpic(self.pic, scale)
        potsurface = getpic(self.potpic, scale)
        potpos = self.pot_pos(position, scale)

        screen.blit(potsurface, potpos)
        screen.blit(
            pic,
            (position[0], -self.posoffset[1] * scale + potpos[1] + 5 * scale))
        if self.sunanimtime != None:
            timezerotoone = (time - self.sunanimtime) / sunanimduration
            sunypos = potpos[1] - (timezerotoone) * pic.get_height() * 0.75
            sunxpos = potpos[0] + potsurface.get_width() * 0.75
            picname = sunanim.current_frame(begin_time=self.sunanimtime,
                                            current_time=time)
            sunpic = getpic(picname, scale)
            screen.blit(sunpic, (sunxpos, sunypos))

        if highlighted:
            xspace = variables.potxspace()
            cursordrawpos = Rect(potpos[0] - xspace, potpos[1] - xspace,
                                 xspace, xspace)
            gfxdraw.box(screen, cursordrawpos, highlightcolor)
Beispiel #6
0
 def draw(self, screen):
     self.box.draw(screen)  # Draw Background
     self.numberWidth = self.fontSpacing * len(str(len(self.listOfLines)))
     counter = 0
     textBuffer = 15
     for x in range(self.firstLine, min(self.firstLine + int(self.getHeight()//self.lineHeight), len(self.listOfLines)), 1):
         # Graphical Settings
         textLinePosition = (self.getX() + self.numberWidth + textBuffer, self.getY() + (self.lineHeight * counter))
         textLineGBRect = (self.getX() + self.numberWidth, round(int(self.getY()) + (self.lineHeight * counter)), self.getWidth() - (self.getX() + self.numberWidth), self.lineHeight)
         # Drawing
         self.buttons[counter].draw(screen)
         gfxdraw.box(screen, textLineGBRect, self.listOfLines[x].getColor())
         
         # Draw Line of Text
         label = TextLine(textLinePosition[0], textLinePosition[1], self, alignment="center left", height=self.lineHeight,
                          width=self.getWidth(), background_color=(0, 0, 0, 0), border=False)
         label.label = self.listOfLines[x].label
         label.draw(screen)
         # draw line number
         label = TextLine(self.getX(), self.getY() + (self.lineHeight * counter), self, str(x), width=self.numberWidth,
                          height=self.lineHeight, font=self.fontType, alignment="center right",
                          text_color=self.numberColor, background_color=(0, 0, 0, 0), border=False)
         label.draw(screen)
         # Update
         counter += 1
     self.scrollBar.draw(screen)
Beispiel #7
0
 def render(self):
     super(WindowLayer, self).render()
     screen = display.get_surface()
     gfxdraw.box(screen, (self.x + 1, self.y + 1, self.x2 - 1, self.y2 - 1),
                 self.bgcolor)
     gfxdraw.rectangle(screen, (self.x, self.y, self.x2, self.y2),
                       self.fgcolor)
    def draw(self, screen):
        # draw roads
        for i in range(self.n_all):
            for j in range(i, self.n_all):
                if not self.nodes_distance[i, j] < float('inf'):
                    continue

                pos_i = utils.lb2lt(tuple(self.nodes_position[i]))
                pos_j = utils.lb2lt(tuple(self.nodes_position[j]))
                color = utils.get_color()
                size = 2
                if self.flags_main_road[i, j]:
                    color = utils.get_color('RED')
                    size = 3
                draw.aaline(screen, color, pos_i, pos_j)
        # draw nodes
        for i in range(self.n_all):
            pos = utils.lb2lt(tuple(self.nodes_position[i]))
            if 'D' in self.i2c[i]:
                xdraw.filled_circle(screen, pos[0], pos[1], 8,
                                    utils.get_color('RED'))
            elif 'Z' in self.i2c[i]:
                xdraw.filled_circle(screen, pos[0], pos[1], 6,
                                    utils.get_color('BLUE'))
            elif 'J' in self.i2c[i]:
                xdraw.filled_circle(screen, pos[0], pos[1], 4,
                                    utils.get_color('BLACK'))
            elif 'F' in self.i2c[i]:
                xdraw.box(screen, (pos[0] - 4, pos[1] - 4, 8, 8),
                          (139, 19, 69))
Beispiel #9
0
    def debug_drawing(self, surface):
        from pygame.gfxdraw import box

        surface.lock()

        # draw events
        for event in self.client.events:
            topleft = self.get_pos_from_tilepos((event.x, event.y))
            size = self.project((event.w, event.h))
            rect = topleft, size
            box(surface, rect, (0, 255, 0, 128))

        # We need to iterate over all collidable objects.  So, let's start
        # with the walls/collision boxes.
        box_iter = map(self._collision_box_to_pgrect, self.collision_map)

        # Next, deal with solid NPCs.
        npc_iter = map(self._npc_to_pgrect, self.npcs.values())

        # draw noc and wall collision tiles
        red = (255, 0, 0, 128)
        for item in itertools.chain(box_iter, npc_iter):
            box(surface, item, red)

        # draw center lines to verify camera is correct
        w, h = surface.get_size()
        cx, cy = w // 2, h // 2
        pygame.draw.line(surface, (255, 50, 50), (cx, 0), (cx, h))
        pygame.draw.line(surface, (255, 50, 50), (0, cy), (w, cy))

        surface.unlock()
Beispiel #10
0
    def draw(self):
        self.bg = DISPLAY.subsurface(self).copy()
        clipxy = DISPLAY.get_clip()
        DISPLAY.set_clip(self)
        gfxdraw.box(DISPLAY,self,BGCOLOR)
        x,y = self.itemsrect.topleft
        if self.index != None and not (1 << self.index)&self._exc:
            gfxdraw.box(DISPLAY,self.hlRect,BGHIGHTLIGHT)
            gfxdraw.rectangle(DISPLAY,self.hlRect,BORDER_HL)
        x += self.lineheight/3
        for idx,item in enumerate(self.itemslist):
            isExc = (1 << idx)&self._exc
            isStr = isinstance(item,str)
            text = FONT.render(item if isStr else item.label,1,FGLOWLIGHT if isExc else FGCOLOR)
            if not isStr:
                self.arrowRect.topright = self.itemsrect.right-self.lineheight/3,y
                DISPLAY.blit(FONT.render(Arrow,1,FGLOWLIGHT if isExc else FGCOLOR),self.arrowRect)
            r = DISPLAY.blit(text,(x,y))
            y += self.lineheight

        gfxdraw.vline(DISPLAY,self.left,self.top,self.bottom-1,BORDER_LEFT)
        gfxdraw.hline(DISPLAY,self.left,self.right-1,self.top,BORDER_LEFT)
        gfxdraw.vline(DISPLAY,self.right-1,self.top+1,self.bottom-1,BORDER_RIGHT)
        gfxdraw.hline(DISPLAY,self.left+1,self.right-1,self.bottom-1,BORDER_RIGHT)
        DISPLAY.set_clip(clipxy)
        return self
Beispiel #11
0
 def circ(s, r, p, c):
   filled_circle(i, p+r, p+r, r, c)
   filled_circle(i, p+2*s-r, p+r, r, c)
   filled_circle(i, p+r, p+2*s-r, r, c)
   filled_circle(i, p+2*s-r, p+2*s-r, r, c)
   box(i, (p+r, p+0, 2*s-2*r, 2*s+1), c)
   box(i, (p+0, p+r, 2*s+1, 2*s-2*r), c)
Beispiel #12
0
 def gamewon(self): #space to continue
     gfxdraw.box(screen,(0,0,screenWidth,screenHeight),(100,100,255,200))
     screen.blit(bigfont.render("You have succeded",1,(0,0,0)),(400,400))
     screen.blit(bigfont.render("Your score was: $"+str(self.score/100000000),1,(0,0,0)),(370,450))
     screen.blit(bigfont.render("Press space to restart",1,(0,0,0)),(350,500))
     self.won=True
     if keys[K_SPACE]:
         resetVariables()
Beispiel #13
0
def display_won(screen: pygame.display) -> None:
    text_rect_shadow = copy(win_rect)
    text_rect_shadow.w += 20
    text_rect_shadow.h += 20
    text_rect_shadow.x -= 10
    text_rect_shadow.y -= 10
    gfxdraw.box(screen, text_rect_shadow, (0, 0, 0, 120))
    screen.blit(win_text, win_rect)
    draw_play_again_button(screen)
Beispiel #14
0
def background(farbe):
    pos = 0
    reduzierung = 0
    for color in range(150, 0, -5):
        pos += hight / 150 * 5
        gfx.box(fenser, (0, pos - 17, widht, pos),
                (farbe[0] + 100 - reduzierung, farbe[1] + 100 - reduzierung,
                 farbe[2] + 100 - reduzierung))
        reduzierung += 5
Beispiel #15
0
 def draw(self):
     cellsize = self.settings.cellsize
     gfxdraw.box(self.display,
                 (self.apple[0] * cellsize, self.apple[1] * cellsize,
                  cellsize, cellsize), self.settings.apple_color)
     for x, y in self.snake:
         gfxdraw.box(self.display,
                     (x * cellsize, y * cellsize, cellsize, cellsize),
                     self.settings.snake_color)
Beispiel #16
0
	def update(self,screen):

		self.updateCount += 1

		if (self.updateCount == self.maxUpdateCount):
			
			self.updateCount = 0
			self.colorIndex = self.colorCycle(self.colorIndex)
		gfx.box(screen,pygame.Rect(self.x,self.y,20,20),self.colors[self.colorIndex])
Beispiel #17
0
 def gameover(self):
     gfxdraw.box(screen,(0,0,screenWidth,screenHeight),(255,255,255,200))
     screen.blit(bigfont.render("game over...",1,(0,0,0)),(400,400))
     screen.blit(bigfont.render("Your score was: "+str(self.score),1,(0,0,0)),(370,450))
     screen.blit(bigfont.render("Press space to restart",1,(0,0,0)),(350,480))
     self.energy = 1
     if keys[K_SPACE]:
         self.resetVariables()
         print(self.energy)
         print(self.lost)
Beispiel #18
0
def pantalla_init():
	global bw, fq
	global bwlabel, fqlabel
	global ftbw,ftdev1,ftdev2,ftqc,fbd
	global fft_sf, top_sf, dwn_sf
	global menusf,stereosf,linksf

	pg.init()
	os.environ["SDL_VIDEO_CENTERED"] = "TRUE"
	pg.display.set_mode(MAIN_SIZE)
	#print(pg.display.Info())
	sf = pg.display.get_surface()
	sf.fill(BGCOLOR)

	# Surfaces TOP & FFT (subsurfaces del main)
	top_sf= sf.subsurface((0,0,TOPANCHO,TOPALTO))		
	fft_sf= sf.subsurface((0,TOPALTO,FFTANCHO,FFTALTO))
	dwn_sf= sf.subsurface((0,TOPALTO+FFTALTO,FFTANCHO,DWNALTO))

	#print(pg.font.get_fonts())

	ftdev1 = pg.font.SysFont(FONT,18)						
	ftdev2 = pg.font.SysFont(FONT,16)						
	ftbw   = pg.font.SysFont(FONT,16)						
	ftqc   = pg.font.SysFont('ubuntumono',48)						

	# pinta smeter
	pgd.box(top_sf,(smx,0,sml,TOPALTO),(0,0,0))
	fsm = pg.font.SysFont('ubuntumono',14)						
	fsq = fsm.render(' S 1  3  5  7  9 +20 +40 +60', 1, (200,200,200),(0,0,0))
	top_sf.blit(fsq, (smx,5))													# Pinta smeter label
	fsq = fsm.render(' ||||||||||||||||||||||||||', 1, (200,200,200),(0,0,0))
	top_sf.blit(fsq, (smx,19))													# Pinta smeter guia
	pgd.box(top_sf,(smx+10,23,sml-25,2),(200,200,200))

	# Pinta signo de BIRDIE
	fbd = ftdev1.render('X',1,(250,150,0),BGCOLOR)

	# pinta boton menu principal
	menusf = pg.image.load(MENUIMG)
	top_sf.blit(menusf,(TOPANCHO-50,0))

	# pinta boton menu FFT
	top_sf.blit(menusf,(TOPANCHO-75,0))

	# icono stereo
	stereosf = pg.image.load(STEREOIMG)

	# icono link
	linksf = pg.image.load(LINKIMG)

	# Icono aplicación
	pg.display.set_icon(stereosf)

	return sf
Beispiel #19
0
 def _draw_cells(self):
     for y in range(len(self.grid)):  # зарисовка всех клеток матрицы
         for x in range(len(self.grid[y])):
             # зарисовка одной клетки её цветом
             if (self.grid[x, y] == self._current_cell):
                 gfxdraw.box(self.display,
                             (x * self.cellsize, y * self.cellsize,
                              self.cellsize, self.cellsize), CURRENT_COLOR)
             else:
                 gfxdraw.box(self.display,
                             (x * self.cellsize, y * self.cellsize,
                              self.cellsize, self.cellsize),
                             self.grid[x, y].color)
Beispiel #20
0
def render_hover(screen: pygame.display) -> None:
    mouse_x, mouse_y = pygame.mouse.get_pos()
    if mouse_x > window_padding and mouse_y > window_padding:
        mouse_x = int((mouse_x - window_padding) / cell_size)
        mouse_y = int((mouse_y - window_padding) / cell_size)
        if mouse_x < 8 and mouse_y < 8:
            piece = get_piece(mouse_x, mouse_y)
            if piece and not piece.black:
                if mouse_x < 8 and mouse_y < 8:
                    gfxdraw.box(screen, (mouse_x * cell_size + window_padding,
                                         mouse_y * cell_size + window_padding,
                                         cell_size, cell_size),
                                (120, 120, 120, 100))
Beispiel #21
0
 def draw(self):
     DISPLAY.blit(self.bg,self.rect)
     gfxdraw.box(DISPLAY,self.rect,BGCOLOR)
     gfxdraw.vline(DISPLAY,self.rect.left,self.rect.top,self.rect.bottom-1,BORDER_LEFT)
     gfxdraw.hline(DISPLAY,self.rect.left,self.rect.right-1,self.rect.top,BORDER_LEFT)
     gfxdraw.vline(DISPLAY,self.rect.right-1,self.rect.top+1,self.rect.bottom-1,BORDER_RIGHT)
     gfxdraw.hline(DISPLAY,self.rect.left+1,self.rect.right-1,self.rect.bottom-1,BORDER_RIGHT)
     x = self.rect.x + self.lineheigth/3
     if self.index > -1:
         gfxdraw.box(DISPLAY,self.rects[self.index].inflate(-2,-2),BGHIGHTLIGHT)
     for item in self.menuboxlist:
         x = DISPLAY.blit(FONT.render(item.label,1,FGCOLOR),(x,self.rect.y)).right+self.lineheigth
     return self.rect
Beispiel #22
0
 def draw(self, screen):
     """
     """
     if not (self.hollow):
         gfxdraw.box(screen, (int(self.getX()), self.getY(), self.getWidth(), self.getHeight()),
                     self.background_color)
     if (self.border):
         gfxdraw.rectangle(screen, (int(self.getX()), self.getY(), self.getWidth(), self.getHeight()),
                           self.border_color)
     if (self.image is not None):
         screen.blit(self.image)
     elif (self.obj is not None):
         self.obj.draw(screen)
Beispiel #23
0
 def draw(self):
     DISPLAY.blit(self.bg,self.rect)
     gfxdraw.box(DISPLAY,self.rect,BGCOLOR)
     gfxdraw.vline(DISPLAY,self.rect.left,self.rect.top,self.rect.bottom-1,BORDER_LEFT)
     gfxdraw.hline(DISPLAY,self.rect.left,self.rect.right-1,self.rect.top,BORDER_LEFT)
     gfxdraw.vline(DISPLAY,self.rect.right-1,self.rect.top+1,self.rect.bottom-1,BORDER_RIGHT)
     gfxdraw.hline(DISPLAY,self.rect.left+1,self.rect.right-1,self.rect.bottom-1,BORDER_RIGHT)
     x = self.rect.x + self.lineheigth/3
     if self.mouse_in or self: gfxdraw.box(DISPLAY,self.rect.inflate(-2,-2),BGHIGHTLIGHT)
     clipxy = DISPLAY.get_clip()
     DISPLAY.set_clip(self.rect.inflate(-self.lineheigth/3*2,-2))
     DISPLAY.blit(FONT.render(self.menu.label,1,FGCOLOR),(x,self.rect.y))
     DISPLAY.set_clip(clipxy)
     return self.rect
Beispiel #24
0
 def draw(bgcolor,fgcolor,topleftcolor,bottomrightcolor):
     gfxdraw.box(DISPLAY,self,bgcolor)
     gfxdraw.vline(DISPLAY,self.left,self.top,self.bottom-1,topleftcolor)
     gfxdraw.hline(DISPLAY,self.left,self.right-1,self.top,topleftcolor)
     gfxdraw.vline(DISPLAY,self.right-1,self.top+1,self.bottom-1,bottomrightcolor)
     gfxdraw.hline(DISPLAY,self.left+1,self.right-1,self.bottom-1,bottomrightcolor)
     clipxy = DISPLAY.get_clip()
     DISPLAY.set_clip(self.inflate(-2,-2))
     if self.type == SWITCH:
         label = FONT.render(self.label if not self.switch else self.switchlabel,1,fgcolor)
     else:
         label = FONT.render(self.label,1,fgcolor)
     DISPLAY.blit(label,label.get_rect(center=self.center))
     DISPLAY.set_clip(clipxy)
Beispiel #25
0
def roundCorners(textRect, color):
    # Get the corners of the buttons
    x0, y0 = textRect.topleft
    x1, y1 = textRect.topright
    x2, y2 = textRect.bottomleft
    x3, y3 = textRect.bottomright

    # Adjust sizes to center text
    y2 = y2 - 3
    y3 = y3 - 3

    # Draw the arcs for each button
    gfxdraw.aacircle(screen, x0, y0, 5, color)
    gfxdraw.filled_circle(screen, x0, y0, 5, color)

    gfxdraw.aacircle(screen, x1, y1, 5, color)
    gfxdraw.filled_circle(screen, x1, y1, 5, color)

    gfxdraw.aacircle(screen, x2, y2, 5, color)
    gfxdraw.filled_circle(screen, x2, y2, 5, color)

    gfxdraw.aacircle(screen, x3, y3, 5, color)
    gfxdraw.filled_circle(screen, x3, y3, 5, color)

    # Extend the size of each button to smooth the corners
    gfxdraw.box(screen, pygame.Rect(x0, y0 - 5, x1 - x0, 5), color)
    gfxdraw.box(screen, pygame.Rect(x1, y1, 6, y3 - y1), color)
    gfxdraw.box(screen, pygame.Rect(x2, y2, x3 - x2, 6), color)
    gfxdraw.box(screen, pygame.Rect(x0 - 5, y0, 5, y2 - y0), color)
Beispiel #26
0
def menu(fen):
    """Fonction de menu principal"""  #premiere fonction a etre appelée
    fen.fill(black)
    texte(int(0.00020 * x_screen * y_screen), "Ramassez-les Tous!", orange,
          0.1125 * x_screen, 0.133 * y_screen,
          fen)  #caler les tailles proportionellement a la taille de l'écran
    for i in range(1, 4):
        gfxdraw.box(fen,
                    (0.275 * x_screen, i * 0.25 * y_screen + y_screen * 0.033,
                     0.5 * x_screen, 0.2 * y_screen), orange)

        diff = "Niveau  " + str(i)
        texte(int(0.00013 * x_screen * y_screen), diff, black, 0.4 * x_screen,
              i * 0.25 * y_screen + 0.1166 * y_screen, fen)

    return 0
Beispiel #27
0
    def render(self):
        scr = pygame.display.get_surface()
        res = self.app.config['screen']

        if self.bg:
            gfxdraw.box(scr, ((0, 0), res), self.bg)

        x = (self.x + self.app.context.offset_x) % self.size
        y = (self.y + self.app.context.offset_y) % self.size

        while x < res[0]:
            gfxdraw.vline(scr, x, 0, res[1], self.fg)
            x += self.size
        while y < res[1]:
            gfxdraw.hline(scr, 0, res[0], y, self.fg)
            y += self.size
Beispiel #28
0
def draw_play_again_button(screen: pygame.display):
    text_rect_shadow = copy(play_again_rect)
    text_rect_shadow.w += 10
    text_rect_shadow.h += 10
    text_rect_shadow.x -= 5
    text_rect_shadow.y -= 5

    mouse_x, mouse_y = pygame.mouse.get_pos()
    if in_rect(mouse_x, mouse_y, text_rect_shadow):
        gfxdraw.box(screen, text_rect_shadow, (0, 0, 0, 120))
        if mouse_clicked:
            board.state = board.State.initializing
    else:
        gfxdraw.box(screen, text_rect_shadow, (0, 0, 0, 80))

    screen.blit(play_again_text, play_again_rect)
Beispiel #29
0
 def process_requests(self, requests):
     rect = (0, 0, self.window_size[0], self.window_size[1])
     for req in requests:
         if req.action == REQUEST_ACTION_EXIT:
             exit()
         elif req.action == REQUEST_ACTION_REFRESH:
             # rect = req.rect
             pass
         elif req.action == REQUEST_ACTION_CONTRAST:
             self.contrast = req.value
         elif req.action == REQUEST_ACTION_INVERT:
             self.invert = False if req.value == 0 else True
         elif req.action == REQUEST_ACTION_POWER_ON:
             self.power = True
         elif req.action == REQUEST_ACTION_POWER_OFF:
             self.power = False
             pyg_gfxdraw.box(self.surface, (0, 0, self.window_size[0], self.window_size[1]), (0, 0, 0))
     self.refresh_area(rect)
Beispiel #30
0
 def checkButtons(self,mx,my, mousebuttonup): #To go through the list of buttons and check if something collides with its Rect hitbox in the list
     for i in range(0,len(self.buttons)):
         screen.blit(smallfont.render(self.buttons[i][1]+str(self.buttons[i][2]),1,(0,0,0)),(self.buttons[i][0][0]+10,self.buttons[i][0][1]+10))
         if self.buttons[i][0].collidepoint(mx,my):
             gfxdraw.box(screen,self.buttons[i][0],(255,255,255,100))
             if mousebuttonup==True:
                 if self.buttons[i][2] < themap.total:
                     if i==0 and themap.maxenergy<themap.energycap:
                         print("maxenergy+")
                         themap.total-=self.buttons[i][2]
                         self.buttons[i][2]=int(100*1.4**self.buttons[i][self.UPGRADE_NUM])
                         self.buttons[i][self.UPGRADE_NUM] +=1;
                         themap.maxenergy+=10
                     elif i==1 and themap.maxhealth<themap.healthcap:
                         print("maxhealth+")
                         themap.total-=self.buttons[i][2]
                         themap.maxhealth+=10
                         themap.health+=10
                     elif i==2 and themap.dolariumdigger==False:
                         print("dolariumdigger+")
                         themap.total-=self.buttons[i][2]
                         themap.digcooldownimet=10
                         themap.dolariumdigger=True
                         self.buttons[i][self.UPGRADE_NUM] +=1;
                         
                     elif i==3 and themap.energydrain>.05:
                         print("energydrain-")
                         themap.total-=self.buttons[i][2]
                         themap.energydrain-=.01
                         self.buttons[i][2]=int(1000*2**self.buttons[i][self.UPGRADE_NUM])
                         self.buttons[i][self.UPGRADE_NUM] +=1;
                     elif i==4:
                         print("Teleported")
                         themap.total-=self.buttons[i][2]
                         themap.posy=-1
                     elif i==5 and themap.digcooldowntime>15:
                         print("Digspeed+")
                         themap.total-=self.buttons[i][2]
                         self.buttons[i][2]=int(150*2**self.buttons[i][self.UPGRADE_NUM])
                         self.buttons[i][self.UPGRADE_NUM] +=1;
                         if themap.digcooldowntime>40:
                             themap.digcooldowntime-=5
                         else:
                             themap.digcooldowntime-=1
Beispiel #31
0
    def Inventory(self, mousebuttonup):
        gfxdraw.box(screen,(125,100,800,700),(255,255,255,100))
        screen.blit(Font.render("Inventory",1,(0,0,0)),(470,150))
        screen.blit(Font.render("Dirt          "+str(themap.inventory[0])+ " * 1        "+" "*(5-(len(str(themap.inventory[0]))))+str(themap.inventory[0]*1),1,(0,0,0)),(150,250))
        screen.blit(Font.render("Copper        "+str(themap.inventory[1])+ " * 4        "+" "*(5-(len(str(themap.inventory[1]))))+str(themap.inventory[1]*4),1,(0,0,0)),(150,280))
        screen.blit(Font.render("Tin           "+str(themap.inventory[2])+ " * 8        "+" "*(5-(len(str(themap.inventory[2]))))+str(themap.inventory[2]*8),1,(0,0,0)),(150,310))
        screen.blit(Font.render("Amethyst      "+str(themap.inventory[3])+ " * 16       "+" "*(5-(len(str(themap.inventory[3]))))+str(themap.inventory[3]*16),1,(0,0,0)),(150,340))
        screen.blit(Font.render("Silver        "+str(themap.inventory[4])+ " * 32       "+" "*(5-(len(str(themap.inventory[4]))))+str(themap.inventory[4]*32),1,(0,0,0)),(150,370))
        screen.blit(Font.render("Gold          "+str(themap.inventory[5])+ " * 64       "+" "*(5-(len(str(themap.inventory[5]))))+str(themap.inventory[5]*64),1,(0,0,0)),(150,430))
        screen.blit(Font.render("Emerald       "+str(themap.inventory[6])+ " * 128      "+" "*(5-(len(str(themap.inventory[6]))))+str(themap.inventory[6]*128),1,(0,0,0)),(150,460))
        screen.blit(Font.render("Ruby          "+str(themap.inventory[8])+ " * 256      "+" "*(5-(len(str(themap.inventory[8]))))+str(themap.inventory[8]*256),1,(0,0,0)),(150,490))
        screen.blit(Font.render("Platinum      "+str(themap.inventory[9])+ " * 512      "+" "*(5-(len(str(themap.inventory[9]))))+str(themap.inventory[9]*512),1,(0,0,0)),(150,520))
        screen.blit(Font.render("Diamond       "+str(themap.inventory[10])+" * 1024     "+" "*(5-(len(str(themap.inventory[10]))))+str(themap.inventory[10]*1024),1,(0,0,0)),(150,550))
        screen.blit(Font.render("Einsteinium   "+str(themap.inventory[11])+" * 2048     "+" "*(5-(len(str(themap.inventory[11]))))+str(themap.inventory[11]*2048),1,(0,0,0)),(150,580))
        screen.blit(Font.render("Dolarium      "+str(themap.inventory[12])+" * 10,000,00"+" "*(5-(len(str(themap.inventory[12]))))+str(themap.inventory[12]*10000000),1,(0,0,0)),(150,610))

        screen.blit(Font.render("Money         "+str(themap.total),1,(0,0,0)),(150,650))
        screen.blit(Font.render("Score         "+str(themap.score)+"/100,000,000",1,(0,0,0)),(150,680))
        self.checkButtons(mx,my, mousebuttonup)
Beispiel #32
0
def demod_mode_response():
	global mn,opt
	global modelabel,tmode,mode
	global sdr,decimation,decirate
	global maxbw,audrate

	tmode 	= opt.texto
	mode 	= opt.value
	modelabel = ftbw.render(tmode, 0, MODECOLOR,BGCOLOR)	# Pinta el label del modo

	if opt.value != "FM ST": pgd.box(top_sf,(250,0,40,TOPALTO),BGCOLOR) # Borra preventivamente el icono de stereo

	calc_bw()
	if REAL: 
		#sdr.set_decimation(decimation)
		calc_dev()			# Calcula deviation para USB y LSB
		sdr.set_mode(mode)
	mn = None
	opt = None
Beispiel #33
0
	def handle(self):
		global	opt,rec,dev

		salir = False
		data = []
		sk = self.request
		print("[+] ==== Conexión desde {}".format(self.client_address))
		top_sf.blit(linksf,(390,0))
		while not salir:
			data = sk.recv(1024).strip()
			if not data: return	
			resp = ""
			print("[+] >>>> {}".format(data))
			if data[:1]=='F':
				tf = int(data[1:])
				if m.fabs(tf-(fqc-15000)) < (SAMPLERATE/3):
					dev = tf-(fqc-15000)-15000
					calc_xdev(dev)
					#dev = tf-(fqc-15000)-15000 # chAPUXILLA
					#t = 0 											# AÑADO DESFASE A LA DESVIACION SOLO PARA USB y LSB
					#if tmode=="USB" or tmode=="LSB": t = bw;		# APLICA SOLO A LA LOGICA; NO A LOS VALORES
					#if REAL: sdr.set_dev(int(dev+t))	# set dev
				else:	
					calc_freq_f(int(data[1:])-15000)
					calc_xdev(15000)
				resp='RPRT 0\n'
			if data[:1]=='M':
				opt.texto = data[1:].strip()
				#opt.value = 
				demod_mode_response()
			if data[:3]=='AOS':	rec = True 
			if data[:3]=='LOS':	rec = False 
			if data[:1]=='f':	resp=str(fqc+dev).strip()+'\n'
			if data[:1]=='l':	resp=str(smval).strip()+'\n'
			if data[:1]=='m':	resp=tmode.strip()+'\n'
			if data[:1].upper()=='Q' or data[:1].upper()=='C': 
				salir=True
				print("[+] ==== Desconectado {}".format(self.client_address))
			else:
				sk.send(resp)
				print("[+] <<<< {}".format(resp).strip())
		pgd.box(top_sf,(390,0,50,TOPALTO),BGCOLOR)
 def show_info(self):
     """显示得分/排行榜"""
     if self.rank_state == RankState.WIN_INFO:
         self.screen.blit(self.win_image, self.win_rect)
         self.screen.blit(self.trophy_image, self.trophy_rect)
         self.screen.blit(self.bullet_left_image, self.bullet_left_rect)
         self.screen.blit(self.time_used_image, self.time_used_rect)
         self.screen.blit(self.total_score_image, self.total_score_rect)
     else:
         self.screen.blit(self.crown_image, self.crown_rect)
         self.screen.blit(self.rank_title_image, self.rank_title_rect)
         self.screen.blit(self.center_image, self.center_rect)
         gfxdraw.box(self.screen, self.rank_bg_rect, (255, 255, 255, 128))
         # 显示列名
         for image, rect in zip(self.column_images, self.column_rects):
             self.screen.blit(image, rect)
         for image, rect in zip(self.result_images, self.result_rects):
             self.screen.blit(image, rect)
     self.restart_button.draw_button()
     self.show_tops_button.draw_button()
Beispiel #35
0
    def draw(self, time, settings, screen : Surface, scale, bottomypos : float, cursoroffset = 0, currentxscroll = 0, drawcursorindex = None, nodraw = False):

        # first draw wood
        if not nodraw:
            self.drawwood(time, settings, screen, scale, currentxscroll, bottomypos)
        
        xspace = screen.get_width()/50
        currentx = xspace
        cursordrawpos = None
        
        for i in range(cursoroffset, len(self.plants)):
            currentpos = (currentx, bottomypos)
            if not nodraw:
                self.plants[i].draw(time, settings, screen, scale,
                                    currentpos)
            if drawcursorindex == i:
                potpos = self.plants[i].pot_pos(currentpos, scale)
                cursordrawpos = Rect(potpos[0]-xspace, potpos[1]-xspace,
                                     xspace, xspace)
                gfxdraw.box(screen, cursordrawpos, (211, 214, 64))
            currentx += self.plants[i].plantwidth*scale + xspace
        
        return cursordrawpos
Beispiel #36
0
def render_choices(screen: pygame.display) -> None:
    mouse_x, mouse_y = pygame.mouse.get_pos()
    mouse_x = int((mouse_x - window_padding) / cell_size)
    mouse_y = int((mouse_y - window_padding) / cell_size)
    for x in range(8):
        for y in range(8):
            color = green_dot_color_hover if x == mouse_x and y == mouse_y else green_dot_color
            red_color = (255, 23, 14,
                         130) if x == mouse_x and y == mouse_y else (230, 20,
                                                                     12, 130)

            if board.choices[x][y]:
                if get_piece(x, y):
                    x_pos = int(x * cell_size + window_padding)
                    y_pos = int(y * cell_size + window_padding)
                    gfxdraw.box(screen, (x_pos, y_pos, cell_size, cell_size),
                                red_color)
                else:
                    x_pos = int(x * cell_size + window_padding + cell_size / 2)
                    y_pos = int(y * cell_size + window_padding + cell_size / 2)
                    for i in range(1, shadow_radius + 1):
                        if (x + y) % 2:
                            multiplicator = int(20 -
                                                20 / shadow_radius * i) + 110
                        else:
                            multiplicator = int(30 -
                                                30 / shadow_radius * i) + 170
                        shadow_color = (multiplicator, multiplicator,
                                        multiplicator)
                        pygame.draw.circle(
                            screen, shadow_color, (x_pos, y_pos),
                            green_dot_radius + shadow_radius - i)
                    gfxdraw.aacircle(screen, x_pos, y_pos, green_dot_radius,
                                     color)
                    gfxdraw.filled_circle(screen, x_pos, y_pos,
                                          green_dot_radius, color)
Beispiel #37
0
def draw_popup_bar_meter(output, items, centre_pos, width, item_height):
    """Draw partially transparent bar meters floating over map items"""
    alpha = (140,)
    r1 = Rect(0, 0, width, (item_height * len(items)) + 1)
    r1.center = centre_pos
    y = r1.top + 1
    w = width - 2
    h = item_height - 1

    for (var, var_colour, total, total_colour) in items:
        r2 = Rect(r1.left + 1, y, w, h)  # (total)
        gfxdraw.box(output, r2, total_colour + alpha)

        if var > 0:
            if var > total:
                var = total
            if var != total:
                alpha = (200,)  # highlight broken items
            r3 = Rect(r1.left + 1, y, ((w * var) / total), h)
            gfxdraw.box(output, r3, var_colour + alpha)

        y += item_height

    return r1  # bounding box
Beispiel #38
0
text = INFONT.render(current.date,True,black)
Fenster.blit(text,(width / 2 + 5 ,5))

for forecast in forecasts:
    text = INFONT.render(str(forecast.date),True,black)
    Fenster.blit(text,(10, a))
    a += 15

    inhalt = 'Day: ' +forecast.high + ' Night: ' + forecast.low + '    ' + forecast.text
    text = INFONT.render(inhalt,True,black)
    Fenster.blit(text,(10, a))
    a += 32

    x +=40
    gfx.box(Fenster,(x - 40,400, 38, -1 * (10 * int(forecast.high))),dayColor)# Tag
    gfx.box(Fenster,(x - 40,400, 38, (10 * int(forecast.low) * -1 )),nightColor)#
    text = INFONT.render(forecast.high,True,black)
    Fenster.blit(text,(x-25, 300))
    text = INFONT.render(forecast.low,True,black)
    Fenster.blit(text,(x-25, 460))

    #print(forecast.date)
    #print('Day: ' +forecast.high + ' Night: ' + forecast.low + '    ' + forecast.text)
    #print()
gfx.line(Fenster,400,400,800-4,400,(200,0,0))
pygame.display.flip()


while True:
    for event in pygame.event.get():
Beispiel #39
0
	def show(self):
		gfx.box(self.screen,pygame.Rect(self.x,self.y,20,20),self.colors[self.colorIndex])
Beispiel #40
0
def draw_panel(position, size, border_color, background):
    x, y, w, h = position[0], position[1], size[0], size[1]
    pygame.draw.rect(canvas, border_color, (x, y, w, h), 2)
    draw.box(canvas, [x + 2, y + 2, w - 3, h - 3], background)
Beispiel #41
0
    def render(self) -> None:
        super().render()
        if self.auth is None:
            if self.username is None:
                # still have to select login or register
                self.screen.fill((0, 0, 0))
                if self.registration_qr is None:
                    self.screen.blit(self.login_button.render(), self.login_button.pos)
                    self.screen.blit(self.register_button.render(), self.register_button.pos)

                    rendered_username_prompt = self.username_field.render(ScreenSize.SMALL)

                    render_prompt = font_small.render("Login/Register", False, (255, 255, 255))
                    self.screen.blit(render_prompt, (self.screen.get_width() // 2 - render_prompt.get_width() // 2,
                                                     self.screen.get_height() // 2 - render_prompt.get_height() - rendered_username_prompt.get_height()))
                    self.screen.blit(rendered_username_prompt, (
                        self.screen.get_width() // 2 - rendered_username_prompt.get_width() // 2,
                        self.screen.get_height() // 2 - rendered_username_prompt.get_height()))
                    if self.login_error_text:
                        rendered_reason = font_small.render(self.login_error_text, False, (255, 0, 0))
                        self.screen.blit(rendered_reason, (
                            self.screen.get_width() // 2 - rendered_reason.get_width() // 2,
                            self.screen.get_height() - rendered_reason.get_height() - 1))
                else:
                    registration_qr = OCSimpleImage().deserialize(self.registration_qr, 2).get_surface()
                    draw.rect(self.screen, (255, 255, 255), (
                        self.screen.get_width() // 2 - registration_qr.get_width() // 2, 0, registration_qr.get_width(),
                        self.screen.get_height()))
                    self.screen.blit(registration_qr,
                                     (self.screen.get_width() // 2 - registration_qr.get_width() // 2, 0))

                    self.screen.blit(self.scanned_button.render(), self.scanned_button.pos)
                    # rendered_qr_label = font_mono_light.render(f"Use a 2FA app", False, (0, 0, 0))
                    # self.screen.blit(rendered_qr_label, (self.screen.get_width()//2 - rendered_qr_label.get_width()//2, self.screen.get_height() - rendered_qr_label.get_height() - 1))
            else:
                self.screen.fill((0, 0, 0))
                rendered_totp_field = self.totp_field.render(ScreenSize.SMALL)
                self.screen.blit(rendered_totp_field, (
                    self.screen.get_width() // 2 - rendered_totp_field.get_width() // 2,
                    self.screen.get_height() // 2 - rendered_totp_field.get_height() // 2))
                prompt_text = font_small.render(f"Enter the TOTP for {self.username}", False, (255, 255, 255))
                self.screen.blit(prompt_text, (self.screen.get_width() // 2 - prompt_text.get_width() // 2,
                                               self.screen.get_height() // 2 - rendered_totp_field.get_height() // 2 - prompt_text.get_height() - 1))
                self.screen.blit(self.login_submit_button.render(), self.login_submit_button.pos)
                self.screen.blit(self.cancel_totp_button.render(), self.cancel_totp_button.pos)
        else:
            self.screen.fill((0, 120, 0))
            game_data = self.game_state.split("\n")
            game_phase = self.get_game_phase()
            if game_phase != "GAME":
                bets = self.get_bets()
                if bets:
                    rendered_bet = font_small.render(f"Bets:", False, (255, 255, 255))
                    self.screen.blit(rendered_bet, (1, 1))
                    y_height = 1 + rendered_bet.get_height()
                    for i, bet in enumerate(bets):
                        rendered_bet = font_small.render(f"Hand {i+1}: {bet}", False, (255, 255, 255))
                        self.screen.blit(rendered_bet, (1, y_height))
                        y_height += rendered_bet.get_height()
            if game_phase == "betting":
                bet_amount = int(game_data[1].split(" ")[1])
                moves = game_data[2].strip().split(" ")
                num_bet_options = moves[1]
                bet_options = moves[2:]
                bet_text = font_small.render("Place a bet!", False, (255, 255, 255))
                self.screen.blit(bet_text, (self.screen.get_width() // 2 - bet_text.get_width() // 2, 5))

                bet_amount_text = font_large.render(str(bet_amount), False, (255, 255, 255))
                self.screen.blit(bet_amount_text, (
                    self.screen.get_width() // 2 - bet_amount_text.get_width() // 2, 6 + bet_text.get_height()))
                if bet_options != ['0']:
                    if 'submitbet' in bet_options:
                        self.submit_bet_button.background_colour = (255, 255, 255)
                        self.submit_bet_button.text_colour = (0, 0, 0)
                    else:
                        self.submit_bet_button.background_colour = (150, 150, 150)
                        self.submit_bet_button.text_colour = (180, 180, 180)
                    self.screen.blit(self.submit_bet_button.render(), self.submit_bet_button.pos)
                    for amount, button in zip(self.get_positive_bets(), self.add_coins):
                        button.label = f"+{amount[0]}"
                        self.screen.blit(button.render(), button.pos)

                    for amount, button in zip(self.get_negative_bets(), self.remove_coins):
                        button.label = amount[0]
                        self.screen.blit(button.render(), button.pos)
                else:
                    print("Not enough funds")
            elif game_phase == 'playermove':
                num_active_hands, hands = self.get_player_hands()
                hand_offset_x = self.screen.get_width() // (num_active_hands + 1)
                active_hand, move_buttons = self.get_move_buttons()
                for i, hand in enumerate(hands):
                    hand_center = hand_offset_x * (i + 1)
                    if hand.hand_state & HandState.ACTIVE:
                        min_hand_x = 0
                        max_hand_x = 0
                        card_height = 0
                        for j, card in enumerate(hand.cards):
                            rendered_card = blackjackcard.render(card, ScreenSize.SMALL)
                            card_offset_x = int(-len(hand.cards) / 2 * rendered_card.get_width() + (
                                    rendered_card.get_width() + 1) * j)
                            self.screen.blit(rendered_card, (hand_center + card_offset_x,
                                                             self.screen.get_height() // 2 - rendered_card.get_height() // 2 + 23))
                            min_hand_x = min(min_hand_x, card_offset_x)
                            max_hand_x = max(max_hand_x, card_offset_x + rendered_card.get_width())
                            card_height = rendered_card.get_height()
                        if not (hand.hand_state & HandState.STANDING) and i == active_hand:
                            draw.rect(self.screen, (100, 100, 255), (hand_center + min_hand_x - 2, self.screen.get_height()//2 - card_height//2 + 21, max_hand_x - min_hand_x + 4, 20), 1)
                self.draw_dealer_hand()

                for button, command, button_enabled in move_buttons:
                    self.screen.blit(button.render(), button.pos)

                current_game_phase_render = font_small.render("Your Move", False, (255, 255, 255))
                self.screen.blit(current_game_phase_render, (self.screen.get_width()//2 - current_game_phase_render.get_width()//2, 1))
            elif game_phase == 'dealermove':
                self.basic_draw_game()

                self.screen.blit(self.acknowledge_button.render(), self.acknowledge_button.pos)

                current_game_phase_render = font_small.render("Dealer's Move", False, (255, 255, 255))
                self.screen.blit(current_game_phase_render, (self.screen.get_width()//2 - current_game_phase_render.get_width()//2, 1))
            elif game_phase == 'payout':

                game_result = self.game_state.split("\n")[2].split(" ")
                if game_result[0] == 'won':
                    self.screen.fill((50, 210, 235))
                    self.screen.blit(self.acknowledge_button.render(), self.acknowledge_button.pos)

                    current_game_phase_render = font_small.render("Payout", False, (255, 255, 255))
                    self.screen.blit(current_game_phase_render, (self.screen.get_width()//2 - current_game_phase_render.get_width()//2, 1))

                    victory_text = font_large.render("You Won!", False, (255, 255, 255))
                    self.screen.blit(victory_text, (self.screen.get_width()//2 - victory_text.get_width()//2, 5 + current_game_phase_render.get_height()))

                    winnings_amount = font_large.render(game_result[1], False, (255, 255, 255))
                    self.screen.blit(winnings_amount, (self.screen.get_width()//2 - winnings_amount.get_width()//2, victory_text.get_height() + current_game_phase_render.get_height()))
                    self.screen.blit(shekel, (self.screen.get_width()//2 + winnings_amount.get_width()//2 + 2, 8 + victory_text.get_height() + current_game_phase_render.get_height()))
                elif game_result[0] == 'tie':
                    self.screen.fill((150, 150, 150))
                    self.screen.blit(self.acknowledge_button.render(), self.acknowledge_button.pos)

                    current_game_phase_render = font_small.render("Payout", False, (255, 255, 255))
                    self.screen.blit(current_game_phase_render, (self.screen.get_width()//2 - current_game_phase_render.get_width()//2, 1))

                    victory_text = font_large.render("Tie", False, (255, 255, 255))
                    self.screen.blit(victory_text, (self.screen.get_width()//2 - victory_text.get_width()//2, 5 + current_game_phase_render.get_height()))
                elif game_result[0] == 'loss':
                    self.screen.fill((150, 100, 100))
                    self.screen.blit(self.acknowledge_button.render(), self.acknowledge_button.pos)

                    current_game_phase_render = font_small.render("Payout", False, (255, 255, 255))
                    self.screen.blit(current_game_phase_render, (self.screen.get_width()//2 - current_game_phase_render.get_width()//2, 1))

                    victory_text = font_large.render("You Lose", False, (255, 255, 255))
                    self.screen.blit(victory_text, (self.screen.get_width()//2 - victory_text.get_width()//2, 5 + current_game_phase_render.get_height()))
            elif game_phase == 'continueplaying':
                self.basic_draw_game()
                gfxdraw.box(self.screen, (10, 10, self.screen.get_width() - 20 , self.screen.get_height() - 20), (0, 0, 0, 220))

                play_again_prompt = font_small.render("Play Again?", False, (255, 255, 255))
                self.screen.blit(play_again_prompt, (self.screen.get_width()//2 - play_again_prompt.get_width()//2, 22))
                self.screen.blit(self.play_again_yes_button.render(), self.play_again_yes_button.pos)
                self.screen.blit(self.play_again_no_button.render(), self.play_again_no_button.pos)
            self.screen.blit(self.exit_button.render(), self.exit_button.pos)
Beispiel #42
0
 def drawBars(self):
     BARLENGTH=300
     #Health bar
     gfxdraw.box(screen,(screenWidth-70,100,40,themap.health*2),(255,100,100,150))
     gfxdraw.box(screen,(screenWidth-70,100,40,themap.maxhealth*2),(255,100,100,100))
     gfxdraw.box(screen,(screenWidth-70,100,40,themap.healthcap*2),(255,100, 100, 50))
     #Energy Bar
     if themap.energy>40:
         gfxdraw.box(screen,(screenWidth-230-themap.maxenergy,20,themap.energy/themap.energycap*BARLENGTH,30),(30,40,255,150))
     else:
         gfxdraw.box(screen,(screenWidth-230-themap.maxenergy,20,themap.energy/themap.energycap*BARLENGTH,30),(255,0,0,150))
     gfxdraw.box(screen,(screenWidth-230-themap.maxenergy,20,BARLENGTH,30),(30,40,255,100))
     gfxdraw.box(screen,(screenWidth-230-themap.maxenergy,20,themap.energycap/themap.energycap*BARLENGTH,30),(30,40,255,50))
     #Height Bar
     gfxdraw.box(screen,(20,100,30,(-themap.posy-1234)/(themap.sizey*themap.tilesize+1234)*200),(30,40,255,100))
     screen.blit(smallfont.render(str(-(-themap.posy-1234)),1,(0,0,0)),(60,(-themap.posy-1234)/(themap.sizey*themap.tilesize+1234)*200+93))
     gfxdraw.box(screen,(20,100+(-1-1234)/(themap.sizey*themap.tilesize+1234)*200,30,200+abs((-1-1234)/(themap.sizey*themap.tilesize+1234)*200)),(20,100,30,50))
     draw.line(screen,(0,0,0),(20,100),(49,100),2)
     draw.line(screen,(0,0,0),(60,(-themap.posy-1234)/(themap.sizey*themap.tilesize+1234)*200+100),(20,100+(-themap.posy-1234)/(themap.sizey*themap.tilesize+1234)*200))
     #Mining Speed Bar
     gfxdraw.box(screen,(screenWidth-230-themap.maxenergy,50, themap.digcooldown/(themap.digcooldowntime+1)*BARLENGTH,10),(200,100,10,150))
Beispiel #43
0
 def box(self, pos, size, color):
     """Draws a rectangle."""
     gfxdraw.box(self.screen, (*pos, *size), color)
Beispiel #44
0
def endScreen(win, score, level):

    running = True

    # Sound init
    pygame.mixer.music.load('Audio/BACKGROUND.ogg')
    pygame.mixer.music.set_volume(1.0)
    pygame.mixer.music.play(-1)

    text_box = pygame.Rect(400, 425, 100, 32)
    text_result = ''
    high_score = 0

    with open("Data/Score.sdwp", "r+") as f:
        high_score = f.readline()
        if int(high_score) < score:
            f.seek(0)
            f.truncate()
            f.write(str(score))

    # Play losing animation

    if win == False:
        loseAnimate = pygame.image.load('Assets/LostEnd_Sprite.png').convert()
        for y in range(3):
            for x in range(9):
                getimage = pygame.Surface((800, 600))
                getimage.blit(loseAnimate, (0, 0),
                              ((20 * (x + 1)) + (800 * x),
                               (20 * (y + 1)) + (600 * y), 800, 600))
                screen.blit(getimage, (0, 0))
                gameClock.tick(10)
                pygame.display.update()
    elif win == True:
        winAnimate = pygame.image.load('Assets/End_Win2.png').convert()
        for y in range(6):
            for x in range(4):
                getimage = pygame.Surface((800, 600))
                getimage.blit(winAnimate, (0, 0),
                              ((20 * (x + 1)) + (800 * x),
                               (20 * (y + 1)) + (600 * y), 800, 600))
                screen.blit(getimage, (0, 0))
                gameClock.tick(10)
                pygame.display.update()

    while running:

        screen.fill(black)

        bg = pygame.image.load("Assets/TransitionScreenBackground.png")
        screen.blit(bg, (0, 0))

        # Labels
        if win == True:
            label('You won!', 400, 200, white, fontBig)
            label('Your score was {} through level {}!'.format(score, level),
                  400, 275, white, fontSmall)

            # Enter button
            text = fontBig.render('Enter', True, white, grey)
            textRect = text.get_rect()
            textRect.center = (600, 425)

            mouse = pygame.mouse.get_pos()

            if textRect.right + 7 > mouse[
                    0] > textRect.left - 5 and textRect.bottom + 6 > mouse[
                        1] > textRect.top - 5:
                text = fontBig.render('Enter', True, white, light_grey)
                roundCorners(textRect, light_grey)

                clicked = False
                for event in pygame.event.get():
                    if event.type == pygame.MOUSEBUTTONDOWN:
                        clicked = True

                if clicked == True:
                    if text_result == '':
                        text_result = 'Anonymous'
                    with open("Data/History.sdwp", "a+") as f:
                        f.write('{}, {}, {}, {}, {}, \n'.format(
                            win, level, score, text_result, high_score))
                    highscores()
            else:
                text = fontBig.render('Enter', True, white, grey)
                roundCorners(textRect, grey)

            screen.blit(text, textRect)

            # Typing
            label('Type name:', 200, 425, white, fontSmall)

        else:
            label('Game Over', 400, 200, white, fontBig)
            label(
                'You failed, try again! Your score was {} through level {}.'.
                format(score, level), 400, 275, white, fontSmall)
            button('Try Again', 400, 425, white, grey, light_grey, fontBig,
                   newLevelNotifier, level, score)

        if int(high_score) < score:
            label(
                'New High Score! Yours: {}, Previous: {}'.format(
                    score, high_score), 400, 325, white, fontSmall)
        else:
            label('High Score: {}'.format(high_score), 400, 325, white,
                  fontSmall)

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                running = False
            if event.type == pygame.KEYDOWN:
                if event.key == pygame.K_BACKSPACE and win == True:
                    text_result = text_result[:-1]
                if event.key == pygame.K_RETURN and win == True:
                    if text_result == '':
                        text_result = 'Anonymous'
                    with open("Data/History.sdwp", "a+") as f:
                        f.write('{}, {}, {}, {}, {}, \n'.format(
                            win, level, score, text_result, high_score))
                    highscores()
                elif win == True:
                    text_result += event.unicode

        if win == True:
            # text box background
            gfxdraw.box(screen, pygame.Rect(270, 409, 260, 32), light_grey)

            # render text
            stext = fontSmall.render(text_result, True, white)
            if stext.get_width() > 260:  # truncate if too long
                text_result = text_result[:-1]
                stext = fontSmall.render(text_result, True, white)
            stextRect = stext.get_rect()
            stextRect.center = (400, 425)
            screen.blit(stext, stextRect)

        pygame.display.update()

    pygame.quit()
    quit()
Beispiel #45
0
def pantalla_refresh(sf):
	global pts,mpts
	global xbw,xdev
	global fq,fqc,bw
	global modelabel,bwlabel,fqlabel1,fqlabel2
	global ftqc, numx
	global maxfill_enable, maxpts_enable, refreshfq
	global azoom, base
	global fft_sf,top_sf
	global sq,xsq,asq,smval,smvaladj,possq,sqstate
	global frame, count
	global menusf, stereosf

	a = FFTANCHO/2 										# media pantalla
	pleft = fqlabel1.get_size()[0]/2 + fqlabel2.get_size()[0]/2 

	fft_sf.fill(BGCOLOR) 									# Borra BW Más rapido que reescribir.

	# PINTA ESCALA
	for x in range(12):										# Escala FFT
		y = int(FFTALTO - (x*(FFTALTO/12))*azoom) + base
		if y > 0 :
			pgd.hline(fft_sf,0,FFTANCHO,y,ESCCOLOR)
			lb = ftdev1.render(str((12-x)*-10), 0, ESCCOLOR,BGCOLOR) # pinta db text
			fft_sf.blit(lb, (0,y-10))	# Pinta db label

	# Pinta BW
	if nobaile: txdev = FFTANCHO/2;
	else:		txdev = xdev
	txbw 	= 2*xbw
	tcodo 	= txdev - txbw/2
	if not nobaile or (nobaile and (frame % 10) > 4 ):			# parapedea dev si introscan
		if 	tmode != "FM W" and tmode != "FM ST":			# WFM no tiene ancho de banda
			if 	tmode == "USB":						
				txbw /= 2	
				tcodo = txdev
			elif tmode == "LSB": 	
				txbw /= 2	
				tcodo = txdev - txbw
			fft_sf.fill(BWCOLOR2,(tcodo,BWY,txbw,FFTALTO-BWY),0) 		# Pinta BW
			pgd.rectangle(fft_sf,(tcodo,BWY,txbw,FFTALTO-BWY),BWCOLOR)
	pgd.vline(fft_sf,int(txdev),0,FFTALTO,DEVCOLOR)		# Pinta linea dev

	# PINTA MAX
	if maxpts_enable:												# Pintta puntos de max
		mpts += [(FFTANCHO,FFTALTO),(0,FFTALTO)]
		pgd.polygon(fft_sf,mpts,MAXCOLOR)

	# PINTA FILL
	if fftfill_enable:												# Pintta FFT relleno (Más rápido que el fill)
		for x in pts: pgd.vline(fft_sf,x[0],x[1],FFTALTO,FILLCOLOR)				

	# PINTA FFT
	pgd.polygon(fft_sf,pts,FGCOLOR)									# pinta FFT

	# PINTA DETECT
	if detect_enable :												# Pinta detector picos
		for x in dtc :	pgd.circle(fft_sf,x[0],x[1],10,DETECTCOLOR)

	# PINTA DEV text
	if not nobaile or (nobaile and  (frame % 10) > 4):
		if 	tmode != "FM W" and tmode != "FM ST":
			fft_sf.blit(bwlabel,  (txdev-bwlabel.get_size()[0]/2,BWY+2))	# Pinta bw label
			fft_sf.blit(fqlabel1, (txdev-pleft,BWY-22))						# Pinta dev label 
			fft_sf.blit(fqlabel2, (txdev-pleft+fqlabel1.get_size()[0]+4,BWY-20))	
		fft_sf.blit(modelabel,(txdev-modelabel.get_size()[0]/2,BWY-40))	# Pinta mode label

	# pinta Sqelch
	tc 	= SQCOLOR
	if not sqstate:	tc = (0,200,0)			# Si está levantado pinta verde
	pgd.hline(fft_sf,0,FFTANCHO,xsq+base, tc)
	fsq = ftdev2.render(' SQ '+str(sq)+ ' ', 0, DEVCOLORHZ,(100,25,25))
	fft_sf.blit(fsq, (FFTANCHO-fsq.get_size()[0],xsq-10+base))		# Pinta bw label

	possq = (FFTANCHO-fsq.get_size()[0]+25,xsq-12+base+12)	# Guardo posicion para el botón
	#pgd.circle(fft_sf,possq[0],possq[1],50,(200,200,200))
	#asq = tsq

	# pinta smeter
	pgd.box(top_sf,(smx+13,25,sml-28,9),(0,0,0))
	pgd.box(top_sf,(smx+13,27,smval*smvaladj,6),(255,50,50))

	# PINTA CIFRAS DE FREQ SI HAN CAMBIADO
	if refreshfq:	
		sp 	 = 4
		size = 24
		numx = []	# Repinta el indicador de frecuencia
		txt = format(fqc,'010d')
		txt = txt[:-9]+'.'+txt[-9:-6]+'.'+txt[-6:-3]+','+txt[-3:]
		lon = len(txt)
		anc = 0
		for x in range(lon):
			if txt[x] in ['.',','] : 
				col = BGCOLOR
				anc = size / 2
			else :	
				col = BGFQCCOLOR
				anc = size
			px = (TOPANCHO/2) - (lon+sp)*size/2 + (x*(size+sp)) 	# Calcula posición
			fqclabel = ftqc.render(txt[x], 1, FQCCOLOR, col)		# pinta fqc text
			top_sf.blit(fqclabel,(px,0))							# blit
			if txt[x] not in ['.',','] : numx += [px]				# Almacena la coordenada del numero

	# PARPADEA BOTON ROJO IF REC
	if rec:
		if frame == FPS/2: 
			pgd.filled_circle(top_sf, smx+sml+TOPALTO/2, TOPALTO/2, TOPALTO/4, BGCOLOR)		#Borra botón rojo izquierda smeter
		if frame == 1:
			pgd.filled_circle(top_sf, smx+sml+TOPALTO/2, TOPALTO/2, TOPALTO/4, tc)			#Pinta botón del color del smeter

	# Pinta STEREO si STEREO
	if REAL and tmode == "FM ST":
		if (sdr.probe_st.level() > 0.5 ): 
			top_sf.blit(stereosf,(250,8))
		else:
			pgd.box(top_sf,(250,0,40,TOPALTO),BGCOLOR)

	# Pinta BIRDIES
	for i in birds:
		fft_sf.blit(fbd, (i+((birdsize-16)/2),FFTALTO-16))

	# PINTA MENU IF ANY
	if mn : mn.refresca()

	# Flipea/Vuelca la pantalla
	pg.display.flip()							
	refreshfq = False
	frame = (frame % FPS) +1	
	count += 1
Beispiel #46
0
def background():
    pos = 0
    for backcolor in range(150,0,-2):
        gfx.box(Fenster,(0,pos,800,height/15),(backcolor+100,backcolor+100,backcolor+100))
        pos += height/15
    gfx.line(Fenster ,int(width/2),0,int(width/2),height,(200,0,0))
 def draw_square(self, x, y, colour):
     "Draws a single square at tile x,y w with colour"
     to_draw = pygame.Rect(x*self.tile_size, y*self.tile_size, self.tile_size , self.tile_size)
     gfxdraw.box(self.my_surf, to_draw, colour)
Beispiel #48
0
            if event.key == pygame.K_F1:
                print(pygame.ver)
                key = pygame.ver

            if event.key == pygame.K_q:
                exit()
            if event.key == pygame.K_e:
                #color = (random.randrange(50,250,10),random.randrange(50,250,10),random.randrange(50,250,10))
                pygame.draw.rect(fenster, (0, 0, 0), (0, 0, xmax, ymax))
                pygame.display.flip()
            if event.key == pygame.K_w:
                color = (random.randrange(50, 250,
                                          10), random.randrange(50, 250, 10),
                         random.randrange(50, 250, 10))
            if event.key == pygame.K_t:
                gfx.box(fenster, (20, 20, 40, 40), color)
                gfx.pie(fenster, 80, 80, 30, 20, 340, color)

            if event.key == pygame.K_0:
                werkzeug = 0
            if event.key == pygame.K_1:
                werkzeug = 1
            if event.key == pygame.K_2:
                werkzeug = 2
            if event.key == pygame.K_3:
                werkzeug = 3

        if event.type == pygame.KEYUP:
            print("stop")
    x = 0
    for event in pygame.mouse.get_pressed():
Beispiel #49
0
	def draw(self, screen):			
		my_surface, tmp_surface = self.my_surface, self.tmp_surface
		if self.needs_static_redraw:
			self.my_surface = my_surface = self.background.copy()
			
			# Draw the current piece background
			if self.get_last_pos():
				(c, r) = self.get_last_pos()
				pos = (c*self.piece_w, r*self.piece_h)
				box(my_surface, pos+(self.piece_w, self.piece_h), THECOLORS["blue"])
			
			# Draw the complete board
			for c in range(self.columns):
				for r in range(self.rows):
					piece_id = self.get_piece((c, r))
					if piece_id != 0:									
						pos = (c*self.piece_w, r*self.piece_h)
						rectangle(my_surface, pos+(self.piece_w, self.piece_h), 
							THECOLORS["white"] )
						if (c, r) in self._play_path[:-1]:
							continue
						text_color =  THECOLORS["white"]
						text = self.font.render(str(piece_id), True, text_color)	
						xpos = (c*self.piece_w) + (self.piece_w/2) - (text.get_width()/2)
						ypos = (r*self.piece_h) + (self.piece_h/2) - (text.get_height()/2)
						my_surface.blit(text, (xpos, ypos))
						
			# Turn those on play path gray
			for i in range(len(self._play_path)-1):
				c, r = self._play_path[i]
				piece_id = self.get_piece(self._play_path[i])
				pos = (c*self.piece_w+1, r*self.piece_h+1)
				box(my_surface, pos+(self.piece_w-1, self.piece_h-1), 
					PLAYED_BACKGROUND_COLOR )	
				if (c, r)  == self.start_pos:
					text_color = THECOLORS["green"]		
				else:
					text_color = PLAYED_COLOR
				text = self.font.render(str(piece_id), True, text_color)	
				xpos = (c*self.piece_w) + (self.piece_w/2) - (text.get_width()/2)
				ypos = (r*self.piece_h) + (self.piece_h/2) - (text.get_height()/2)				
				my_surface.blit(text, (xpos, ypos))				

			# Paint goals
			for c, r in self.goals:
				piece_id = self.get_piece((c, r))
				pos = (c*self.piece_w+1, r*self.piece_h+1)
				#box(my_surface, pos+(self.piece_w-1, self.piece_h-1), 
				#	THECOLORS["green"] )			
				#if (c, r) in self.touched_goals:
				#	box(my_surface, pos+(self.piece_w-1, self.piece_h-1), 
				#		THECOLORS["green"] )				
					
				text = self.font.render(str(piece_id), True, THECOLORS["yellow"])	
				xpos = (c*self.piece_w) + (self.piece_w/2) - (text.get_width()/2)
				ypos = (r*self.piece_h) + (self.piece_h/2) - (text.get_height()/2)				
				my_surface.blit(text, (xpos, ypos))				
								
			
			self.needs_static_redraw = False
		tmp_surface.blit(my_surface, (0,0))
		
		
		screen.blit(tmp_surface, (self.h_border, self.header_height))
 def draw_rect(self, x, y, width, height, color=(0, 0, 0), alpha=1):
     gfxdraw.box(self.window, (x, y, width, height),
                 list(color) + [int(alpha * 255)])