"I've learned Spanish in one day! Thats a language!"
>> How well do you know Spanish? You won't be able to speak it fluently after one day's learning. Most people take at least 2 years learning for that (assuming 2/3 hours per week)
You can learn DB in a day, but you won't be able to use it.
@vivi2k
You misunderstand the kind of program that DBP is. It is not a "three clicks and you have Quake 4" program. DBP's main aim is to simplify a lot of the tasks in making a 3D game. For example, you can load models in one command instead of having to write hundreads of lines of code to do it.
I suggest you look at simple examples to get your code working.
Quite a bit of code is required for even fairly simple programs. Here is the code for a simple FPS which allows you to run around a level, jump, look up/down etc. and fire a gun. It also displays the frame-rate, a few statistics and a welcome message. It won't work because I haven't included the media, but you can get the gist of the code.
Rem Project: BSP check
Rem Created: 21/09/2002 17:40:11
Rem ***** Main Source File *****
sync on : sync rate 80 : hide mouse
rem setup camera
set camera range 0.1,50000
position camera 0, 5, 0
rem Load BSP File
Text 20,20,"Loading BSP File..."
sync
load bsp "City.pk3","nyk3dm1.bsp"
cls
Text 20,20,"Loaded BSP File"
`Set Camera Collision
set bsp camera collision 1, 0, 1, 0
set bsp collision threshhold 1, 0.0001
sync
Sleep 200
`Define Constants to use in main loop
timeinc = 0
timex = 0
timey = 0
timeinc2 = 0
spaceinc# = 0
alreadyjumping = 0
mouseytomove = 0
canjump = 1
xang# = 0
timeinc_flash = 0
` Load Gun
Load Object "Models/ak47.x",1
Show Object 1
` Load Bad Guy
Load Object "Models/German_attack.x",10
Position Object 10,17,3.75,-2
Show Object 10
Loop Object 10
YRotate Object 10,90
Set Object Speed 10,30
Set Global Collision On
Scale Object 10,75,75,75
` Load Sight
Load Image "images/sight.bmp",1
` Load Muzzle Flash
`Load Image "images/flash.bmp",2
`Sprite 1,(Screen Width()/2+45),(Screen Height()/2-80),2
`Hide Sprite 1
MAKE OBJECT PLAIN 5,0.5,0.5
Load Image "images/flash.bmp",6
Ghost Object On 5,0
Set Image Colorkey 0,0,0
Lock Object On 5
Position Object 5,0.3,0.05,2
Xrotate Object 5,-10
Texture Object 5,6
Set Object Transparency 5,1
Hide Object 5
` Load Music
Load Music "music/music.mp3",1
Loop Music 1
Set Music Volume 1,0
Load Sound "music/mg.wav",1
` Start Main Loop
do
set bsp collision height adjustment 1,100
` Get Time at start of loop
timex = timer()
`Display text which changes every 10 seconds
If timeinc < 10000
Text 20,40,"Welcome to the Quake3 BSP Demo"
endif
if Timeinc > 9999 and < 20000
Text 20,40,"http://www.darkbasicpro.com"
endif
If timeinc > 19999
timeinc = 0
endif
`Display the initial credits and Info after the program has been started
If timeinc2 < 5000
Text (Screen Width()/2-150),(Screen Height()/2), "Use the up key or 'W' and mouse to navigate"
Text (Screen Width()/2-150),(Screen Height()/2+20), "Press 'M' to enable music, 'X' to disable"
Text (Screen Width()/2-150),(Screen Height()/2+40), "thanks to HaggisMan, Gib007 and Asheron"
endif
`Move User as required
HandleCameraMovement()
`Toggle Music On / Off
`SC 50 = 'M'
If Scancode() = 50
Loop Music 1
EndIf
`SC 45 = 'X'
If Scancode() = 45
Stop Music 1
EndIf
`Fire Gun
If MouseClick() > 0
If timeinc_flash < 50
Show Object 5
If Sound Looping(1) = 0
Loop Sound 1
EndIf
Else
Hide Object 5
If Sound Looping(1) = 0
Loop Sound 1
EndIf
EndIf
If timeinc_flash > 100
Hide Object 5
timeinc_flash = 0
` Hide Light 1
EndIf
Set Sound Volume 1,100
Else
Hide Object 5
Stop Sound 1
timeinc_flash = 0
Endif
` Display Sight
Paste Image 1,(Screen Width() / 2),(Screen Height()/2-100),1
` Display FPS
text (Screen Width()-100),(Screen Height()-120),"FPS:" + Str$(screen fps())
text (Screen Width()-100),(Screen Height()-100),"X:" + Str$(Camera Position X(0))
text (Screen Width()-100),(Screen Height()-80),"Y:" + Str$(Camera Position Y(0))
text (Screen Width()-100),(Screen Height()-60),"Z:" + Str$(Camera Position Z(0))
text (Screen Width()-100),(Screen Height()-40),"BX:" + Str$(BSP Collision Y(1))
text (Screen Width()-100),(Screen Height()-20),"BH:" + Str$(BSP Collision Hit(1))
` SYNC
fastsync
` Update Timer for this loop
timey = timer()
timeinc = timeinc + (timey - timex)
If timeinc2 < 5000
timeinc2 = timeinc + (timey - timex)
Endif
If timeinc_flash < 1000
timeinc_flash = timeinc_flash + (timey - timex)
Endif
` Handle jumping
if spacekey() = 1 and alreadyjumping = 0 and canjump = 1 and BSP Collision Y(1) > 0.01
alreadyjumping = 1
endif
if alreadyjumping = 1
spaceinc# = spaceinc# + (timey - timex)
if spaceinc# < 300
position camera 0, camera position x(0), camera position y(0) + 0.5-(spaceinc#/300), camera position z(0)
else
spaceinc# = 0
alreadyjumping = 0
endif
endif
loop
Function HandleCameraMovement()
If BSP Collision Y(1) > 1
Set BSP Collision Threshhold 1,0.2
Endif
` YRotate handles Left / Right turning
yrotate camera 0, camera angle y(0)+ mousemovex()
` Position Gun on bottom right side of screen
Lock Object On 1
Position Object 1,+0.10,-0.15,0.05
Xrotate Object 1,-10
` XMOVEMENT CODE - DISABLED
` Check X angle before rotating camera to prevent user looking too high / too low
If wrapvalue(camera angle x(0)) > 85 and wrapvalue(camera angle x(0)) < 150
xrotate camera 0, 85
endif
if wrapvalue(camera angle x(0)) < 275 and wrapvalue(camera angle x(0)) > 150
xrotate camera 0, 275
endif
xrotate camera 0, wrapvalue(camera angle x(0))+ mousemovey()
` Basic Gravity effect, if the user is in midair (ie BSP Collision Y = 0) then
` the user is lowered
If BSP Collision Y(1) < 0.00001
position camera 0, camera position x(0), camera position y(0) - 0.2*(80.0/screen fps()), camera position z(0)
canjump = 0
else
canjump = 1
endif
` If Upkey pressed or if the 'W' key is pressed
if upkey()=1 or scancode() = 17
xang# = camera angle x(0)
xrotate camera 0,0
move camera 0, 0.2*(80.0/screen fps())
xrotate camera 0,xang#
endif
If Camera position Y(0) < -10
Text (Screen Width()/2-150),(Screen Height()/2), "LEVEL COLLISION ERROR - You Fell through the floor."
Text (Screen Width()/2-150),(Screen Height()/2+20), "Press any key to continue"
Sync
Suspend For Key
Execute File "Q3Demo.exe","",""
End
Endif
EndFunction
NOBODY has a forum name as stupid as Darth Shader. I do.