FreshRSS

Normální zobrazení

Jsou dostupné nové články, klikněte pro obnovení stránky.
PředevčíremHlavní kanál
  • ✇Recent Questions - Game Development Stack Exchange
  • How to make a tilemap in pygame?Joshua Carlson
    so I have some Python code to generate a random 10x10 grid in which a mine will be or won't be placed, I am having trouble trying to convert this list into a use-able set of coordinates. Any help would be appreciated fieldx = 10 fieldy = 10 objecs = 20 Field = [] for i in range(fieldy): Field.append([]) for j in range(fieldx): Field[i].append([0]) for i in range(objecs): x = random.randint(0,fieldx-1) y = random.randint(0,fieldy-1) if Field[y][x] == [0]: Field[y][x] =
     

How to make a tilemap in pygame?

so I have some Python code to generate a random 10x10 grid in which a mine will be or won't be placed, I am having trouble trying to convert this list into a use-able set of coordinates. Any help would be appreciated


fieldx = 10
fieldy = 10
objecs = 20
    
Field = []
for i in range(fieldy):
  Field.append([])
  for j in range(fieldx):
    Field[i].append([0])



for i in range(objecs):
  x = random.randint(0,fieldx-1)
  y = random.randint(0,fieldy-1)
  if Field[y][x] == [0]:
    Field[y][x] = [1]
❌
❌