Hi all,
i need help on how to change a grid line((x1,y1), (x2,y2)) to another color. I have a 6 * 6 grid(black lines), made using pygame and i want to change the colour, with response to a mouse click on the coordinates. Is this possible? Below is the code i used in creating the grid. Thanks in advance.

import pygame
from pygame.locals import *
#grid creation code
def main():

screen = pygame.display.set_mode((640, 480))
pygame.display.set_caption('cheese box')


while True:
for event in pygame.event.get():
if event.type == QUIT:
exit()


#Create The Backgound
background = pygame.Surface(screen.get_size())
background = background.convert()
background.fill((250, 250, 250))
b = background

line_color = (0,0,0)
c = line_color
d = pygame.draw

# draw lines for the grid
for y in range(7):
d.line(b, c, (0,y*50), (300,y*50), 6)

for x in range(7):
d.line(b, c, (x*50,0), (x*50,300), 6)


screen.blit(b, (0,0))
pygame.display.flip()
if __name__ == '__main__': main()

Thanks. will try that.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.