Skip to main content
added 120 characters in body
Source Link

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?

UPDATE:
To clarify if I have a list of lists like so:
[
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
] And dimensions 500x500,
I'd like the program to put a wall of rocks from x=0 to x=400, with each rock being 100x100.

What I mean is: I'd like to find x-y coordinates to place the rock based on where the 1 is on the map list of lists.

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?

UPDATE:
To clarify if I have a list of lists like so:
[
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
] And dimensions 500x500,
I'd like the program to put a wall of rocks from x=0 to x=400, with each rock being 100x100.

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?

UPDATE:
To clarify if I have a list of lists like so:
[
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
] And dimensions 500x500,
I'd like the program to put a wall of rocks from x=0 to x=400, with each rock being 100x100.

What I mean is: I'd like to find x-y coordinates to place the rock based on where the 1 is on the map list of lists.

added 243 characters in body
Source Link

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?

UPDATE:
To clarify if I have a list of lists like so:
[
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
] And dimensions 500x500,
I'd like the program to put a wall of rocks from x=0 to x=400, with each rock being 100x100.

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?

UPDATE:
To clarify if I have a list of lists like so:
[
[1, 1, 1, 1, 0],
[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]
] And dimensions 500x500,
I'd like the program to put a wall of rocks from x=0 to x=400, with each rock being 100x100.

Source Link

How to convert a list into coordinates in pygame

I'd like to have a map in my pygame game but don't want to waste time moving each individual object in it. To resolve this, I'd like to iterate over a list like this:
[1, 0, 0, 0, 0,
0, 0, 0, 0, 0,
0, 1, 0, 0, 0]
where 1 means there is a rock and 0 means there is nothing. How would I convert this list into coordinates of where to place each block?