0

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()

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by ifemi
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.