👻 Check our latest review to choose the best laptop for Machine Learning engineers and Deep learning tasks!
I"m currently working on a map editor for a game in pygame, using tile maps. The level is built up out of blocks in the following structure (though much larger):
level1 = (
(1,1,1,1,1,1)
(1,0,0,0,0,1)
(1,0,0,0,0,1)
(1,0,0,0,0,1)
(1,0,0,0,0,1)
(1,1,1,1,1,1))
where "1" is a block that"s a wall and "0" is a block that"s empty air.
The following code is basically the one handling the change of block type:
clicked = pygame.mouse.get_pressed()
if clicked[0] == 1:
currLevel[((mousey+cameraY)/60)][((mousex+cameraX)/60)] = 1
But since the level is stored in a tuple, I"m unable to change the values of the different blocks. How do I go about changing the different values in the level in an easy manner?
👻 Read also: what is the best laptop for engineering students?
We hope this article has helped you to resolve the problem. Apart from Convert tuple to list and back, check other code Python module-related topics.
Want to excel in Python? See our review of the best Python online courses 2023. If you are interested in Data Science, check also how to learn programming in R.
By the way, this material is also available in other languages:
- Italiano Convert tuple to list and back
- Deutsch Convert tuple to list and back
- Français Convert tuple to list and back
- Español Convert tuple to list and back
- Türk Convert tuple to list and back
- Русский Convert tuple to list and back
- Português Convert tuple to list and back
- Polski Convert tuple to list and back
- Nederlandse Convert tuple to list and back
- 中文 Convert tuple to list and back
- 한국어 Convert tuple to list and back
- 日本語 Convert tuple to list and back
- हिन्दी Convert tuple to list and back
Rome | 2023-01-27
Thanks for explaining! I was stuck with Convert tuple to list and back for some hours, finally got it done 🤗. Will use it in my bachelor thesis
Moscow | 2023-01-27
Thanks for explaining! I was stuck with Convert tuple to list and back for some hours, finally got it done 🤗. Will use it in my bachelor thesis
Warsaw | 2023-01-27
Maybe there are another answers? What Convert tuple to list and back exactly means?. Checked yesterday, it works!