0

Specifically the issue is getting the logo to show up with the transparency

enter image description here

logo = pygame.image.load(".//assets//LegendOfDragoonLogo.png").convert_alpha()
logo = pygame.transform.scale(logo,(400,300))
screen.blit(logo,(100,100))

Main Code:

import pygame
from pygame.locals import *
import os
# Game Initialization
pygame.init()
 
# Center the Game Application
os.environ['SDL_VIDEO_CENTERED'] = '1'
 
# Game Resolution
screen_width=800
screen_height=600
screen=pygame.display.set_mode((screen_width, screen_height))
 
# Text Renderer
def text_format(message, textSize, textColor):
    newFont=pygame.font.Font(None, textSize)
    newText=newFont.render(message, 0, textColor)
    return newText
 
# Colors
white=(255, 255, 255)
black=(0, 0, 0)
gray=(50, 50, 50)
red=(255, 0, 0)
green=(0, 255, 0)
blue=(0, 0, 255)
yellow=(255, 255, 0)
 
# Game Framerate
clock = pygame.time.Clock()
FPS=30
def main_menu():
 
    menu=True
    selected="start"
 
    while menu:
        for event in pygame.event.get():
            if event.type==pygame.QUIT:
                pygame.quit()
                quit()
            if event.type==pygame.KEYDOWN:
                if event.key==pygame.K_UP:
                    selected="start"
                elif event.key==pygame.K_DOWN:
                    selected="quit"
                if event.key==pygame.K_RETURN:
                    if selected=="start":
                        print("Start")
                    if selected=="quit":
                        pygame.quit()
                        quit()
        # Main Menu UI
        #screen.fill(blue)
        logo = pygame.image.load(".//assets//LegendOfDragoonLogo.png").convert_alpha()
        logo = pygame.transform.scale(logo,(400,300))
        if selected=="start":
            text_start=text_format("START",  75, white)
        else:
            text_start = text_format("START",  75, black)
        if selected=="quit":
            text_quit=text_format("QUIT",  75, white)
        else:
            text_quit = text_format("QUIT",  75, black)

        start_rect=text_start.get_rect()
        quit_rect=text_quit.get_rect()
        # Main Menu Text
        screen.blit(logo,(100,100))
        screen.blit(text_start, (screen_width/2 - (start_rect[2]/2), 300))
        screen.blit(text_quit, (screen_width/2 - (quit_rect[2]/2), 360))
        pygame.display.update()
        clock.tick(FPS)
        pygame.display.set_caption("Legend of Dragoon")
        
main_menu()
pygame.quit()
quit()
Arundeep Chohan
  • 9,779
  • 5
  • 15
  • 32
  • 6
    There is nothing wrong with your code. Most likely your image is not transparent. Did you only download a preview with a checkered background? – Rabbid76 Sep 22 '22 at 06:19
  • Could you provide a link to the image, such that we find out whether the image is causing the problem or not? – The_spider Sep 23 '22 at 19:59
  • https://www.pngwing.com/en/free-png-nktgy grabbed it from here. – Arundeep Chohan Sep 23 '22 at 20:54
  • If you open the image with your usual image viewer is the background transparent ? If not, your problem comes from the image itself not code. – Anto Oct 03 '22 at 13:26

0 Answers0