This is my code, will eventually be a simple chess game so that's why all the variables and stuff are called chess.
import pygame
pygame.init()
win = pygame.display.set_mode((800,800))
pygame.display.set_caption('Chess')
Chess_Selection_Image = pygame.image.load(r'C:\Users\benja\Documents\Python\Chess project\Chess_Selection_Image.png')
run = True
while run:
win.fill((100,100,100))
CSIsize = Chess_Selection_Image.get_rect()[2::]
win.blit(Chess_Selection_Image,(400 - CSIsize[0]//2,400 - CSIsize[1]//2))
CSI_rect = Chess_Selection_Image.get_rect()
print(Chess_Selection_Image.get_rect())
for event in pygame.event.get():
if event.type == pygame.QUIT:
run = False
if event.type == pygame.MOUSEBUTTONDOWN:
if CSI_rect.collidepoint(pygame.mouse.get_pos()):
print(pygame.mouse.get_pos())
pygame.display.flip()
pygame.quit()
on line 18, it keeps printing [0,0,207,63] the last two elements are correct but as we can see on line 15 the image is not on coordinates [0,0] its on coordinates around [250,350]. What am I doing wrong?
For the record the image works and is in the right place https://i.stack.imgur.com/007x8.png