I'm new to pygame and currently I'm working on creating a memory game where the computer displays boxes at random positions for like a second and then the user has to click on where he/she thinks those boxes are. It's kind of like this: Click Here
However right now I'm having a few problems.
I'm not really sure how to make the computer display the boxes with like a letter or symbol e.g. 'T' or '%'. (I've already made the grid).
Also does anyone know how to add increase the players score when they get the right box?
Any help would be appreciated. Thank you.
import pygame size=[500,500] pygame.init() screen=pygame.display.set_mode(size) # Colours LIME = (0,255,0) RED = (255, 0, 0) BLACK = (0,0,0) PINK = (255,102,178) SALMON = (255,192,203) WHITE = (255,255,255) LIGHT_PINK = (255, 181, 197) SKY_BLUE = (176, 226, 255) screen.fill(BLACK) score = 0 # Width and Height of game box width=50 height=50 # Margin between each cell margin = 5 # Create a 2 dimensional array. A two dimesional # array is simply a list of lists. grid= for row in range(20): # Add an empty array that will hold each cell # in this row grid.append() for column in range(20): grid[row].append(0) # Append a cell # Set row 1, cell 5 to one. (Remember rows and # column numbers start at zero.) grid = 1 # Set title of screen pygame.display.set_caption("Spatial Recall") #Loop until the user clicks the close button. done=False # Used to manage how fast the screen updates clock=pygame.time.Clock() # -------- Main Program Loop ----------- while done==False: for event in pygame.event.get(): # User did something if event.type == pygame.QUIT: # If user clicked close done=True # Flag that we are done so we exit this loop if event.type == pygame.MOUSEBUTTONDOWN: # User clicks the mouse. Get the position pos = pygame.mouse.get_pos() # Change the x/y screen coordinates to grid coordinates column=pos // (width+margin) row=pos // (height+margin) # Sete t hat location to zero grid[row][column]=1 print("Click ",pos,"Grid coordinates: ",row,column) # Draw the grid for row in range(10): for column in range(10): color = LIGHT_PINK if grid[row][column] == 1: color = RED pygame.draw.rect(screen,color,[(margin+width)*column+margin,(margin+height)*row+margin,width,height]) # Limit to 20 frames per second clock.tick(20) # Go ahead and update the screen with what we've drawn. pygame.display.flip() screen.blit(screen, rect) def play_again(): # indicates that the player can replay mess = police.render('click to replay',1,gray, orange) pygame.display.update(scr.blit(mess,mess.get_rect(center=scrrect.center))) while True: ev = pygame.event.wait() if ev.type == pygame.MOUSEBUTTONDOWN: return True elif ev.type == pygame.QUIT: return False def draw_hidden(): # draws and displays the cards faces hidden © es scr.fill(orange) for y in range(0,scrrect.h,cellsize): for x in range(0,scrrect.w,cellsize): scr.fill(noir,(x+1,y+1,cellsize-2,cellsize-2)) pygame.display.flip() pygame.quit ()