(Aug-12-2019, 08:15 PM)SheeppOSU Wrote: You can make a dictionary for the spaces. You can type out the dictionary or do this
mapDict = {} for x in range(1, 17): #repeat 16 times mapDict.update({x : None}) #None means it isn't occupiedThis function will check if the card can be moved
def CheckIfPossible(direction, space): #direction is the direction they are trying to move the card in. space is the space the card is in coordDict = {'x1' : 'left', 'x4' : 'right', 'y1' : 'up', 'y4' : 'down'} #Directions the card cannot go if at a specific coord y = #Get y coord as in 2 if it were in the 2nd row x = #Get x coord for example 1 if it were in the first column if x == 1 and coordDict['x1'] == direction.lower(): return False elif x == 4 and coordDict['x4'] == direction.lower(): return False elif y == 1 and coordDict['y1'] == direction.lower(): return False elif y == 4 and coordDict['y4'] == direction.lower(): return False return TrueHope this helps!
Your code looks good, and I tried it. Every time I run the code, I'm getting an error on this line. Exactly I'm getting an error on the #2nd row
y = #Get y coord as in 2 if it were in the 2nd row x = #Get x coord for example 1 if it were in the first columnI am not sure, what I shall write, before both Hashtags. I wrote x = 2 and y = 1 and every time I run the code, Python crashes. Eh...yeah. Python crashes. When I'm running other Pygame-Projects, it's not crashing. I ran your code a few times, and the first few times, Python just crashed. I tried it again and then it was not crashing anymore, but just nothing happened (I didn't got an error message).
Thanks for the help, but still not working.
Edit: I just imported pygame. So above the code, I just have the lines:
import pygame
and
pygame.init()(But I'm not sure, if I really need the pygame.init()).