I'm trying to make a memory game where there a four colors, and you have to match the pattern while the program keeps adding +1 to the list.
right now i cant figure out how to get the the game to Display the pattern. and then wait for player input to end the game or add another color to the pattern.
This is all i can come up with:
def addlist():
if playerpattern == pattern:
pattern.append(random.randint(1, 4))
def listcheck():
if playerpattern == pattern:
for i in pattern:
if i == 1:
topleft.color = (255, 0, 0)
else:
topleft.color = (100, 0, 0)
if i == 2:
topright.color = (0, 0, 255)
else:
topright.color = (0, 0, 175)
if i == 2:
bottomleft.color = (0, 255, 0)
else:
bottomleft.color = (0, 175, 0)
if i ==4:
bottomright.color = (255, 255, 0)
else:
bottomright.color = (175, 175, 0)
pattern = []
playerpattern = []
playing = True
while playing:
clock.tick(10)
print(pattern)
for event in pygame.event.get():
if event.type == pygame.QUIT:
playing = False
if event.type == MOUSEBUTTONDOWN:
mouseclick()
mousehover()
addlist()
listcheck()
draw()
pygame.quit()
Basically when the game starts I want the game to light up pattern[0] (one of the 4 squares).
Then when the player gets it right display pattern[0] and then pattern[1] with a delay and then repeat until its over. Thanks for helping