Python Forum
use the print function in pygame
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
use the print function in pygame
#3
I found the below code to start with, problem is, when i try to click on any block it still prints the message. How to make the message appear on specific block?

for row in range(0,3,1):
    for column in range(3,6,1):
        color = GREEN
        mouse = pygame.mouse.get_pos()
        click = pygame.mouse.get_pressed()
        x = (MARGIN + WIDTH) * column + MARGIN
        y = (MARGIN + HEIGHT) * row + MARGIN
        pygame.draw.rect(screen,
                         color,
                         [x,
                          y,
                          WIDTH,
                          HEIGHT])
        if x+WIDTH > mouse[0] > x and y+HEIGHT > mouse[1] > y:
            if click[0] == 1:
                print("clicked")
Reply


Messages In This Thread
use the print function in pygame - by rwahdan - Jul-07-2019, 05:14 AM
RE: use the print function in pygame - by metulburr - Jul-07-2019, 12:13 PM
RE: use the print function in pygame - by rwahdan - Jul-07-2019, 03:58 PM
RE: use the print function in pygame - by metulburr - Jul-07-2019, 04:01 PM
RE: use the print function in pygame - by rwahdan - Jul-07-2019, 04:15 PM
RE: use the print function in pygame - by metulburr - Jul-07-2019, 04:52 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  [PyGame] pygame, help with making a function to detect collision between player and enemy. Kris1996 3 3,394 Mar-07-2020, 12:32 PM
Last Post: Kris1996
  [PyGame] pygame.draw.rect function stretches across the screen instead of moving BubblesTheGiraffe 2 3,712 Jun-11-2019, 08:32 PM
Last Post: metulburr

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020