Untitled
unknown
plain_text
10 months ago
1.7 kB
5
Indexable
import pygame
# Initialize Pygame
pygame.init()
# Screen dimensions
SCREEN_WIDTH = 800
SCREEN_HEIGHT = 600
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
pygame.display.set_caption("Football Game")
# Colors
WHITE = (255, 255, 255)
GREEN = (0, 128, 0)
BLACK = (0, 0, 0)
# Fonts
font = pygame.font.Font(None, 48)
# Load assets
field_logo = pygame.image.load("logo.png") # Add your logo file here
field_logo = pygame.transform.scale(field_logo, (100, 100)) # Adjust size as needed
endzone_team1 = "Team A"
endzone_team2 = "Team B"
# Function to draw the field
def draw_field():
# Draw field background
screen.fill(GREEN)
# Draw the field logo at the center
logo_x = (SCREEN_WIDTH - field_logo.get_width()) // 2
logo_y = (SCREEN_HEIGHT - field_logo.get_height()) // 2
screen.blit(field_logo, (logo_x, logo_y))
# Draw endzone names
team1_text = font.render(endzone_team1, True, WHITE)
team2_text = font.render(endzone_team2, True, WHITE)
# Position names in the endzones
team1_x = (SCREEN_WIDTH - team1_text.get_width()) // 2
team1_y = 20 # Top endzone
team2_x = (SCREEN_WIDTH - team2_text.get_width()) // 2
team2_y = SCREEN_HEIGHT - team2_text.get_height() - 20 # Bottom endzone
# Render team names
screen.blit(team1_text, (team1_x, team1_y))
screen.blit(team2_text, (team2_x, team2_y))
# Main game loop
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# Draw the field with logo and endzone names
draw_field()
# Update the display
pygame.display.flip()
# Quit Pygame
pygame.quit()Editor is loading...
Leave a Comment