08-19-2004, 01:54 PM
Heres a quick challenge I hope a few of you will enter.
Obfuscation of Qb code!
I got the idea when Nathan mention the IOCCC (The International Obfuscated C Code Contest). (if you dont know what obfuscated code looks like, try this and look at the .c files. they are all working programs.)
The point is to make your code as hard to read and different looking from the normal properly formattted language. Unfortunately this is quite hard in QB, and is really suited for C, but I thought we could have a go =)
I have written a small 3D wireframe app:
Your entry does not have to be big, but can be a even a small algo for (for example) printing the Fibbonachi numbers or working out prime numbers etc.
Obfuscation of Qb code!
I got the idea when Nathan mention the IOCCC (The International Obfuscated C Code Contest). (if you dont know what obfuscated code looks like, try this and look at the .c files. they are all working programs.)
The point is to make your code as hard to read and different looking from the normal properly formattted language. Unfortunately this is quite hard in QB, and is really suited for C, but I thought we could have a go =)
I have written a small 3D wireframe app:
Code:
TYPE pt: x AS SINGLE: y AS SINGLE: z AS SINGLE: END TYPE
READ dps: DIM p(dps) AS pt: TYPE ln: l1 AS INTEGER: l2 AS INTEGER: END TYPE
FOR i = 1 TO dps: READ p(i).x, p(i).y, p(i).z: NEXT: READ dls
DIM l(dls) AS ln: FOR i = 1 TO dls: READ l(i).l1, l(i).l2: NEXT
pc = 3.14 / 180: zm = 20: SCREEN 7, , 1, 0: DO: kp = INP(96): d$ = INKEY$
SELECT CASE kp: CASE 1: CLS : END: CASE 78: zm = zm - 1: CASE 74: zm = zm + 1
CASE 72, 75, 73: d = 5: CASE 80, 77, 81: d = 355: END SELECT: SELECT CASE kp
CASE 75, 77: FOR i = 1 TO dps: nx = COS(d * pc) * p(i).x - SIN(d * pc) * p(i).z
nz = SIN(d * pc) * p(i).x + COS(d * pc) * p(i).z: p(i).x = nx: p(i).z = nz
NEXT: CASE 72, 80: FOR i = 1 TO dps: nz = COS(d * pc) * p(i).z - SIN(d * pc) * p(i).y
ny = SIN(d * pc) * p(i).z + COS(d * pc) * p(i).y: p(i).z = nz: p(i).y = ny
NEXT: CASE 73, 81: FOR i = 1 TO dps: ny = COS(d * pc) * p(i).y - SIN(d * pc) * p(i).x
nx = SIN(d * pc) * p(i).y + COS(d * pc) * p(i).x: p(i).y = ny
p(i).x = nx: NEXT: END SELECT: FOR i = 1 TO dls
IF p(l(i).l1).z + zm > 0 AND p(l(i).l2).z + zm > 0 THEN
x11 = p(l(i).l1).x * 256: xy11 = (p(l(i).l1).z + zm): y11 = p(l(i).l1).y * 256
x21 = p(l(i).l2).x * 256: xy21 = (p(l(i).l2).z + zm): y21 = p(l(i).l2).y * 256
x1 = x11 / xy11 + 160: y1 = y11 / xy11 + 100: x2 = x21 / xy21 + 160
y2 = y21 / xy21 + 100: LINE (x1, y1)-(x2, y2)
END IF: NEXT: WAIT &H3DA, 8: WAIT &H3DA, 8, 8: PCOPY 1, 0: CLS : LOOP
DATA 8,-5,2,-5,5,2,-5,-5,-2,-5,5,-2,-5,-5,2,5,5,2,5,-5,-2,5,5
DATA -2,5,12,1,2,4,2,6,2,7,3,1,3,4,3,6,5,8,6,8,7,5,7,4,8,5,1
Your entry does not have to be big, but can be a even a small algo for (for example) printing the Fibbonachi numbers or working out prime numbers etc.