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?
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…