nnekymoe 0 Newbie Poster

Spatial_Recall_2 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

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

score = 0

# Width and Height of game box

# Margin between each cell
margin = 5

# Create a 2 dimensional array. A two dimesional
# array is simply a list of lists.
for row in range(20):
    # Add an empty array that will hold each cell
    # in this row
    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][5] = 1  

# Set title of screen
pygame.display.set_caption("Spatial Recall")

#Loop until the user clicks the close button.

# Used to manage how fast the screen updates

# -------- 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[0] // (width+margin)
            row=pos[1] // (height+margin)
            # Sete t hat location to zero
            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

    # Limit to 20 frames per second

    # Go ahead and update the screen with what we've drawn.

screen.blit(screen, rect)     

def play_again():
    # indicates that the player can replay
    mess = police.render('click to replay',1,gray, orange)
    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
            for y in range(0,scrrect.h,cellsize):
                for x in range(0,scrrect.w,cellsize):

pygame.quit ()
Be a part of the DaniWeb community

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