Doom like ^^ !
i wrapped textures on the walls and roofs, this gives a better scary feeling
Use mouse and control keys to move in the different paths.
"Q" to quit.
I compiled it and attached it to the post with the textures i used ^^
Have fun!!
AUTODEFINE "OFF"
'Direct3D Test
'Requires IBasic 1.97 or greater
IF GETDXVERSION < 7
MESSAGEBOX 0,"This program requires" + chr$(13) + "DirectX 7.0 or greater","Error"
END
ENDIF
DECLARE "user32.dll",SetCursorPos(x:INT, y:INT),INT
'Set up timer
'When called,this returns the number of milliseconds since the computer was turned on
DECLARE "kernel32",GetTickCount(),int
DEF win:window
DEF scene,camera,shape,shape2,light,light2,cameradummy,floorobject:int
DEF mX,mY,sX,sY:int
DEF wrap[13],wrap2[13],lc:FLOAT
def shapes[10,10],map[10,10],flr[10,10],ceiling[10,10]:INT
def crsr,x,y,xx,yy,x1,y1:INT
DEF time,timesincelastflip,lastfliptime,run:INT
'open a window
WINDOW win,0,0,640,480,@NOCAPTION|@NOAUTODRAW,0,"",mainwindow :'Do not use a caption else can mess up mouse coordinates
FRONTPEN win,RGB(255,255,255)
BACKPEN win,0
DRAWMODE win,@TRANSPARENT
'create the 3D screen
IF CREATE3DSCREEN(win,640,480,16) <> 0
MESSAGEBOX win, "Could not create Direct3D screen","Error"
CLOSEWINDOW win
END
ENDIF
'set the default 3D rendering quality
'since our shapes have curves use Gouraud shading
D3DSETQUALITY win,@LIGHTON | @FILLSOLID | @SHADEGOURAUD
'create the master scene
scene = D3DSCENE(win)
D3DCOMMAND scene,@SETSCENEBACKCOLOR,.3,.3,1:'Set background colour
'Dummy object for camera position
'Moved by arrow keys and by x movement of mouse
cameradummy=D3DSHAPE(scene,@CSCUSTOM)
D3DCOMMAND cameradummy,@SETPOSITION,scene,25,0,25
D3DCOMMAND cameradummy,@SETORIENTATION,scene,0,0,1,0,1,0
'The camera.Attached to camera dummy so moves with it
'Also moved by y movement of mouse to look up/down
camera = D3DCAMERA(cameradummy)
'Create directional light as child of camera so moves with it
light = D3DLIGHT(camera,@LIGHTSPOT,.6,.5,.6)
'Create an ambient light which illuminates all objects
light2=D3DLIGHT(scene,@LIGHTAMBIENT,.2,.2,.2)
'Generate a random maze
for y=1 to 8
for x=1 to 8
map[x,y]=int(rnd(4))
next x
next y
for x=0 to 9
map[x,0]=2
map[0,x]=1
map[x,9]=0
map[9,x]=3
next x
map[0,0]=2
map[9,0]=3
'Generate 3d shapes from the maze
wrap=0,0,0, 1,0,0, 0,0,1, 0,0,.04,.04
wrap2=0,0,0,0,1,0,0,0,1,0,0,.04,.04
for y=0 to 9
for x=0 to 9
x1=0
y1=0
if map[x,y]=0 | map[x,y]=2
xx=52
yy=2
endif
if map[x,y]=1 | map[x,y]=3
xx=2
yy=52
endif
if map[x,y]=0 then x1=-25
if map[x,y]=1 then y1=-25
if map[x,y]=2 then x1=25
if map[x,y]=3 then y1=25
shapes[x,y]=D3DSHAPE(scene,@SHAPECUBE,xx,30,yy)
D3DCOMMAND shapes[x,y],@SETPOSITION,scene,x*50+x1,0,y*50+y1
D3DCOMMAND shapes[x,y],@CREATEWRAP,shapes[x,y],@WRAPBOX,wrap
D3DCOMMAND shapes[x,y],@LOADTEXTURE,GETSTARTPATH+"Texture61.bmp"
'Floor
flr[x,y]=D3DSHAPE(scene,@SHAPECUBE,52,1,52)
D3DCOMMAND flr[x,y],@SETPOSITION,scene,x*50,-15,y*50
D3DCOMMAND flr[x,y],@CREATEWRAP,flr[x,y],@WRAPBOX,wrap2
D3DCOMMAND flr[x,y],@LOADTEXTURE,GETSTARTPATH+"Texture51.bmp"
'Ceiling
ceiling[x,y]=D3DSHAPE(scene,@SHAPECUBE,52,1,52)
D3DCOMMAND ceiling[x,y],@SETPOSITION,scene,x*50,15,y*50
D3DCOMMAND ceiling[x,y],@CREATEWRAP,ceiling[x,y],@WRAPBOX,wrap2
D3DCOMMAND ceiling[x,y],@LOADTEXTURE,GETSTARTPATH+"Texture41.bmp"
next x
next y
'Floor (grass outside)
floorobject=D3DSHAPE(scene,@SHAPECUBE,3500,1,3000)
D3DCOMMAND floorobject,@SETPOSITION,scene,0,-16,0
D3DCOMMAND floorobject,@SETSHAPECOLOR,0,.5,0
crsr = LOADIMAGE(GETSTARTPATH + "crosshair.gif", @IMGCURSOR)
SETCURSOR win,@CSCUSTOM,crsr
GETSCREENSIZE sX,sY
SetCursorPos(sX/2,sY/2)
run=1
lastfliptime=GetTickCount()
'process messages until somebody closes us
waituntil run=0
'delete all the frames
for y=0 to 9
for x=0 to 9
D3DDELETE shapes[x,y]
D3DDELETE flr[x,y]
D3DDELETE ceiling[x,y]
next x
next y
D3DDELETE floorobject
D3DDELETE light
D3DDELETE light2
D3DDELETE camera
D3DDELETE cameradummy
D3DDELETE scene
closewindow win
end
SUB mainwindow
SELECT @class
CASE @IDCHAR
if (@CODE = ASC("Q")) | (@CODE = ASC("q")) THEN run = 0
CASE @IDCREATE
centerwindow win
CASE @IDMOUSEMOVE
mX=@MOUSEX q
mY=@MOUSEY
CASE @IDCLOSEWINDOW
run=0
CASE @IDDXUPDATE
time=GetTickCount()
timesincelastflip=time-lastfliptime
IF timesincelastflip>2
lastfliptime=time
SetCursorPos(sX/2,sY/2)
D3DCOMMAND cameradummy,@ADDROTATION,0,1,0,.002*(mX-sX/2)
D3DCOMMAND camera,@ADDROTATION,1,0,0,.002*(mY-sY/2)
IF(GETKEYSTATE(0x26))
D3DCOMMAND cameradummy,@ADDTRANSLATION,0,0,timesincelastflip*.06:'Use timesincelastflip as multiplier to translation so runs at the same speed on all PCs
ENDIF
IF(GETKEYSTATE(0x28))
D3DCOMMAND cameradummy,@ADDTRANSLATION,0,0,-timesincelastflip*.06
ENDIF
IF(GETKEYSTATE(0x25))
D3DCOMMAND cameradummy,@ADDTRANSLATION,-timesincelastflip*.06,0,0
ENDIF
IF(GETKEYSTATE(0x27))
D3DCOMMAND cameradummy,@ADDTRANSLATION,timesincelastflip*.06,0,0
ENDIF
D3DRENDER scene,camera
DXFLIP win,0,0
ENDIF
ENDSELECT
RETURN