Kivy游戏的等距视图

2024-06-01 07:58:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我有一些问题渲染一个等距游戏在Kivy。在

在Pygame中,我成功地运行了以下代码:

for row in map_data:
    for tile in row:
        cartx = currentTile * tileWidth    #x is the index of the currentTile * the tile width
        carty = currentRow * tileHeight     #y is the index of the currentRow * the tile height

        x = WIN_WIDTH_HALF + (cartx - carty) / 2
        print(x)
        y = WIN_HEIGHT_QUARTER + (cartx + carty) / 4
        print(y)
        print('\n')

        if tile == 1:
            tileImage = wall
        else:
            tileImage = grass

        DISPLAYSURF.blit(tileImage, (x, y)) #display the actual tile
        currentTile += 1
    currentTile = 0
    currentRow += 1

但是现在,我已经在Kivy玩了一个简单的等距游戏,我正在努力思考如何用Kv设计语言来表达上述内容。在

我是Kivy的新手,而且我承认我仍然能理解*.py和*.kv文件之间的联系,比如在what-go-where中,所以任何建议都将被感激。基本上,我需要与上面代码相同的功能,但是要在Kivy中无缝运行。在

提前谢谢你, 伊米翁


Tags: the代码in游戏forrowprinttile