#๐Ÿ”’ How Could I move my play button in Pygame.

16 messages ยท Page 1 of 1 (latest)

winter bay
#

I've made made a circle to show where I want to move it.

glad glenBOT
#

@winter bay

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

winter bay
#

Here is my code ```python
import pygame
from pygame.locals import *

pygame.init()

def load_and_scale_image(image_path, size):
image = pygame.image.load(image_path)
return pygame.transform.scale(image, size)

def draw_background(screen, background, screen_size):
scaled_background = pygame.transform.scale(background, screen_size)
screen.blit(scaled_background, (0, 0))

def draw_play_button(screen, play_button, screen_size):
button_position = (
screen_size[0] // 2 - play_button.get_width() // 2,
screen_size[1] // 2 - play_button.get_height() // 2
)
screen.blit(play_button, button_position)

def draw_elements(screen, background, play_button, screen_size):
draw_background(screen, background, screen_size)
draw_play_button(screen, play_button, screen_size)
pygame.display.flip()

def run():
screen_size = (500, 500)
screen = pygame.display.set_mode(screen_size, HWSURFACE | DOUBLEBUF | RESIZABLE)
background = pygame.image.load("Stick dance cover art.png")
play_button = load_and_scale_image("Stick dance play button.png", (100, 100))

draw_elements(screen, background, play_button, screen_size)

running = True
while running:
    for event in pygame.event.get():
        if event.type == QUIT:
            running = False
        elif event.type == VIDEORESIZE:
            screen_size = event.dict['size']
            screen = pygame.display.set_mode(screen_size, HWSURFACE | DOUBLEBUF | RESIZABLE)
            draw_elements(screen, background, play_button, screen_size)

pygame.quit()

run()

#

My background:

#

my play button:

#

And finally here is where I want to move it:

#

How can I change my play buttons position in Pygame.

#

o

#

just have to wait I guess

#

:3

winter bay
#

w

winter bay
#

a

winter bay
#

i

glad glenBOT
#

@winter bay

Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.