import pygame
import math
cell_size = 5
def update():
global selected_x
global selected_y
mouse_x, mouse_y = pygame.mouse.get_pos()
selected_x = math.floor(mouse_x / cell_size)
selected_y = math.floor(mouse_y / cell_size)
def draw():
screen.fill((255, 255, 255))
for y in range(50):
for x in range(70):
cell_draw_size = cell_size - 1
screen.draw.filled_rect(
Rect(
(x * cell_size, y * cell_size),
(cell_draw_size, cell_draw_size)
),
color=(220, 220, 220)
)
screen.draw.text(
'selected x: ' + str(selected_x) +
', selected y: ' + str(selected_y),
(0, 0),
color=(0, 0, 0)
)