带有读取和def fn的Raycaster引擎错误

时间:2019-03-01 05:34:07

标签: qb64

程序运行时,它将OUT OF DATA返回到read nw

DIM vx1(15), vx2(20), vy1(20), vy2(20)
    DIM tx1(20), tz1(20), tx2(20), tz2(20), wc(20) AS INTEGER
    DIM w AS INTEGER
    DIM nw AS INTEGER
    READ nw
    FOR w = 1 TO nw: READ vx1(w), vy1(w), vx2(w), vy2(w), wc(w): NEXT

    vx1 = 70: vy1 = 20
    vx2 = 70: vy2 = 70

    px = 50
    py = 50
    angle = 0

def fn尚未实现

 SCREEN 0, 1, 0, 0: WIDTH 80, 25
    def fncross (x1, y1, x2, y2) = x1 * y2 - y1 * x2
    SUB intersect (x1, y1, x2, y2, x3, y3, x4, y4, x, y)
        x = fncross(x1, y1, x2, y2)
        y = fncross(x3, y3, x4, y4)
        det = fncross(x1 - x2, y1 - y2, x3 - x4, y3 - y4)
        x = fncross(x, x1 - x2, y, x3 - x4) / det
        y = fncross(x, y1 - y2, y, y3 - y4) / det
    END SUB

在这里被称为相交

IF tz1 > 0 OR tz2 > 0 THEN

    CALL intersect(tx1, tx1, tx2, tz2, -0.0001, 0.0001, -20, 5, ix1, iz1)
    CALL intersect(tx1, tz1, tx2, tz2, 0.0001, 0.0001, 20, 5, ix2, iz2)
    IF tz1 <= 0 THEN IF iz1 > 0 THEN tx1 = ix1: tz1 = iz1 ELSE tx1 = tx2: tz1 = iz2
    IF tz2 <= 0 THEN IF iz1 > 0 THEN tx2 = ix1: tz2 = iz1 ELSE tx2 = ix2: tz2 = iz2

END IF

3 个答案:

答案 0 :(得分:1)

此外,根据您有关QB中的DEF FN的问题,以下内容是有效的:

可以在QB11,QB45,BC7和VBDOS中声明单行函数:

DEF FNcross (x1, y1, x2, y2) = x1 * y2 - y1 * x2
PRINT FNcross(10, 20, 30, 40)

但是,由于QB64不支持单行FN,请改用多行功能:

PRINT FNcross(10, 20, 30, 40)
FUNCTION FNcross (x1, y1, x2, y2)
    FNcross = x1 * y2 - y1 * x2
END FUNCTION

答案 1 :(得分:0)

如何在QB64中使用读取/数据功能:

DIM nw AS INTEGER
READ nw
FOR w = 1 TO nw: READ vx1(w), vy1(w), vx2(w), vy2(w), wc(w): NEXT
DATA 2
DATA 1,2,3,4,5
DATA 6,7,8,9,10

答案 2 :(得分:0)

据我所知,要获取实际的C ++编译错误,请在批处理文件中使用此代码:

@echo off 
ECHO. 
ECHO Diagnosing Latest Compilation Error 
ECHO. 
ECHO Please wait...     
ECHO. cd .\internal\c
.\bin\g -w -Wall -I.\i -I..\..\ -L.\l qbx.cpp libqbx.o -mwindows   .\i686-w64-mingw32\lib\libimm32.a -lwinspool -lmingw32 -ln -lmix -limg -lttf -lmn   -lSDL -s -o ..\..\ >..\..\0utput64.txt 2>&1 
cd ..\.. 
ECHO. 
ECHO 0utput64.txt created! 
ECHO. PAUSE