Hi everyone.
I just done a bare-boned pacman clone, just to demonstrate how would I convert a 2D game to a 3D one.
Look at this
set display mode 800, 600, 32
set window on
sync on
gosub inizia
gosub imposta
do
rem cls
gosub tasti
gosub elabora
gosub vedi
gosub senti
sync
loop
tasti:
kx = rightkey() - leftkey()
kz = downkey() - upkey()
if kx <> 0 then dx = kx
if kz <> 0 then dz = kz
if schema(pz, px + dx) <> 1
px = px + dx
else
dx = 0
endif
if schema(pz + dz, px) <> 1
pz = pz + dz
else
dz = 0
endif
schema(pz, px) = 2
return
vedi:
vuoti = 0
for a = 1 to 16
for b = 1 to 16
if schema(a, b) <> 0
rem muro
if (schema(a, b))=(1)
color = RGB(0,64,128)
rad = 0
else
color = RGB(128,255,128)
rad = 3
endif
else
rem vuoto
color = RGB(128,128,255)
vuoti = vuoti + 1
rad = 9
endif
rem box 401 + (b - 8) * 32, 301 + (a - 9) * 32, 400 + (b - 7) * 32, 300 + (a - 8) * 32, color, color, color, color
line 400 + (b - 8) * 32, 300 + (a - 9) * 32, 400 + (b - 7) * 32, 300 + (a - 9) * 32
line 400 + (b - 8) * 32, 300 + (a - 8) * 32, 400 + (b - 7) * 32, 300 + (a - 8) * 32
line 400 + (b - 8) * 32, 300 + (a - 9) * 32, 400 + (b - 8) * 32, 300 + (a - 8) * 32
line 400 + (b - 7) * 32, 300 + (a - 9) * 32, 400 + (b - 7) * 32, 300 + (a - 8) * 32
circle 416 + (b - 8) * 32, 316 + (a - 9) * 32, rad
if (not (object exist(((a - 1) * 16) + b)))
make object cube ((a - 1) * 16) + b, 1
position object ((a - 1) * 16) + b, (a - 7), 0, (b - 8)
endif
color object ((a - 1) * 16) + b, color
text (b - 1) * 10, (a + 3) * 16, str$(schema(a, b))
next b
next a
position object 256, pz - 7, 1, px - 8
circle 416 + (px - 8) * 32, 316 + (pz - 9) * 32, 11
text 0, 0, "Tasti - (" + str$(kx) + ", " + str$(kz) + ")."
text 0, 16, "Direzione - (" + str$(dx) + ", " + str$(dz) + ")."
text 0, 32, "Posizione - (" + str$(pz) + ", " + str$(px) + ")."
text 0, 48, "Vuoti: " + str$(vuoti)
if spacekey() then cls
text 0, 500, str$(camera position x()) + " " + str$(camera position y()) + " " + str$(camera position z())
position camera 11, 9, 4
point camera 0, 0, 0
if (vuoti)=(0) then gosub imposta
return
senti:
return
elabora:
return
inizia:
dx as integer
dz as integer
kx as integer
kz as integer
px as integer
pz as integer
vuoti as integer
rad as integer
dim livello(16) as word
dim schema(16, 16) as byte
position camera 6, 13, 9
point camera 0, 0, 0
make object sphere 256, 1
return
imposta:
gosub veroLivello
for a = 1 to 16
for b = 1 to 16
schema(a, b) = ((livello(a) && power(2, 16 - b)) <> 0)
next b
next a
px = 3
pz = 3
dx = 0
dy = 0
return
function power(b as integer, e as integer)
c = b
if e > 0
while e > 1
c = c * b
e = e - 1
endwhile
else
c = 1
endif
endfunction c
veroLivello:
livello(1) = 65535
livello(2) = 32769
livello(3) = 36861
livello(4) = 34817
livello(5) = 64511
livello(6) = 33421
livello(7) = 47649
livello(8) = 41981
livello(9) = 43521
livello(10) = 44029
livello(11) = 43521
livello(12) = 43775
livello(13) = 43521
livello(14) = 43775
livello(15) = 43009
livello(16) = 65535
return
.
.
Bye, Berserk.
.