コード例 #1
0
ファイル: main.py プロジェクト: papelpel123/doomengine.python
    elif mouserelX <= 1000 and mouserelX >= -1000:
        camera.angle += mouserelX * 0.005

    # draw floor and ceiling
    floor = [[0, display.height / 2], [display.width, display.height / 2],
             [display.width, display.height], [0, display.height]]
    ceiling = [[0, 0], [display.width, 0], [display.width, display.height / 2],
               [0, display.height / 2]]
    display.drawPolygon(floor, (60, 60, 60), 0)
    display.drawPolygon(ceiling, (100, 100, 100), 0)

    # render 3D walls
    walls = []
    solidBsp.getWallsSorted(camera.worldX, camera.worldY, walls)
    for i, wall in enumerate(walls):
        topLeft, topRight, bottomRight, bottomLeft = camera.projectWall(
            wall, display.width, display.height, i is 0)
        if topLeft:
            wallLines = [topLeft, topRight, bottomRight, bottomLeft]
            display.drawPolygon(wallLines, wall.drawColor, 0)

    # render the top down map
    if mode == 0:
        for lineDef in allLineDefs:
            display.drawLine([lineDef.start, lineDef.end], (0, 0, 255), 1)
            ln = 7
            mx = lineDef.mid[0]
            my = lineDef.mid[1]
            nx = lineDef.normals[lineDef.facing][0] * ln
            ny = lineDef.normals[lineDef.facing][1] * ln
            if lineDef.facing == 1:
                display.drawLine([[mx, my], [mx + nx, my + ny]], (0, 255, 255),