From 3a8b3b39abbec5da805ec060b31630f335d497a0 Mon Sep 17 00:00:00 2001 From: happy531 Date: Thu, 7 Apr 2022 20:06:09 +0200 Subject: [PATCH] get coords on mouse click --- main.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/main.py b/main.py index 4dbbb4c..ae78fe7 100644 --- a/main.py +++ b/main.py @@ -1,3 +1,4 @@ +from calendar import c import pygame as pg import sys from os import path @@ -6,6 +7,7 @@ from map import * # from house import House from sprites import * from settings import * +import math class Game(): @@ -101,6 +103,10 @@ class Game(): self.quit() if event.key == pg.K_h: self.draw_debug = not self.draw_debug + if event.type == pygame.MOUSEBUTTONUP: + pos = pygame.mouse.get_pos() + clicked_coords = [math.floor(pos[0] / TILESIZE), math.floor(pos[1] / TILESIZE)] + print(clicked_coords) def show_start_screen(self): pass