- 2

Help?

Hi, i have a code, imports images, you can read it if you want: import os import pygame from pygame.locals import * pygame.init() WasItX = True Cells = ['', '', '', '', '', '', '', '', ''] screen = pygame.display.set_mode((600, 600),0,32) background = pygame.image.load("bg.png").convert_alpha() imgX = pygame.image.load("x.png").convert_alpha() imgO = pygame.image.load("o.png").convert_alpha() screen.blit(background, (0,0)) pygame.display.update() x, y =500, 300 def cellNum(x,y): if (x<200 and y<200): return 1 if (x>200 and x<400 and y<200): return 2 if (x>400 and y<200): return 3 if (x<200 and y>200 and y<400): return 4 if (x>200 and x<400 and y>200 and y<400): return 5 if (x>400 and x<600 and y>200 and y<400): return 6 if (x<200 and y>400): return 7 if (x>200 and x<400 and y>400 and y<600): return 8 if (x>400 and y>400): return 9 return 0 def getImg(): global WasItX if WasItX == True: WasItX = False return imgO else: WasItX = True return imgX def fillArray(cellNum): if WasItX == True: Cells[cellNum-1] = 'x' else: Cells[cellNum-1] = 'o' print(Cells) while True: for event in pygame.event.get(): if event.type == pygame.MOUSEBUTTONDOWN: x, y = pygame.mouse.get_pos() print(x, y) if cellNum(x,y)==1: screen.blit(getImg(), (0, 0)) pygame.display.update() fillArray(1) elif cellNum(x, y)==2: screen.blit(getImg(), (200, 0)) pygame.display.update() fillArray(2) elif cellNum(x, y)==3: screen.blit(getImg(), (400, 0)) pygame.display

5th Nov 2017, 12:33 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar
4 Respuestas
+ 1
Looks like it got out of maximum, i did give it clear description.
5th Nov 2017, 12:31 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar
+ 1
Look its in destruction, in future its gonna be a tic tac toe, it returns values of the "tiles" in game, returns numbers(1 to 9) by getting their x and y. and not gonna tell all the functions, just gonna skip to saying i want it to dont let me reassign a x to o or o to x if its been already assigned to x or o
5th Nov 2017, 12:36 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar
+ 1
Thanks, but can you give a bit more clear explanation?
5th Nov 2017, 12:44 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar
- 1
I have no redundant input, like you know what i mean? and there are no arbitrary inputs.
5th Nov 2017, 12:50 AM
DarkHorrorOfThirdEye
DarkHorrorOfThirdEye - avatar