我在游戏里做一个塔防游戏。我设置了背景,地图是一组以这种方式闪烁的图块:
for x in range(0,640, tile_size): #x starta od 0 i mice se po 32 sve do 640
for y in range (0, 480, tile_size): #y isto
window.blit(Tile.Grass, (x,y)
现在很容易获得鼠标位置:
^{pr2}$
但是瓷砖是20乘20的,我需要以某种方式确定瓷砖的中心位置,这样我就可以在适当的地方装载我的矩形和精灵。在
Tags:
我想你已经在一个列表中存储了这些瓷砖。您可以对事件坐标进行平分,以获得列表中瓷砖的索引。例如,如果单击(164,97)并将这些坐标除以平铺大小(20),则可以得到索引(8,4),并可以使用它们交换平铺。在
相关问题 更多 >
编程相关推荐