CodeBase Entries

Welcome to our CodeBase where you can search through DarkBASIC, DarkBASIC Professional and AppGameKit source code covering a wide range of topics from full games to demo effects to object loaders.

All registered users can submit their own code from their account page, so why not contribute?

Search
Found 2,053 entries over 69 pages.
CodeBase Description Category

A code for saving and loading values in an external file.

Version: 1.0
Created: 2nd Dec 2007 01:09
0
0
Functions

A code that says the current time, or tells the time at the top of hour. (sounds included in ZIP)

Version: 1.1
Created: 27th Nov 2007 20:47
0
0
Sound

Make your own TV! Add your own channals!

Version: 1.0
Created: 26th Nov 2007 16:00
0
0
Animation

A nice little computer program that talks, well, he gets annoying. He's yours now ;)

Version: 1.0
Created: 21st Nov 2007 01:30
0
0
Text

Rounds a real number to the nearest whole integer.

Version: 2
Created: 19th Nov 2007 22:06
0
0
Math / Physics

all CAD wants is a friend ;( please don't kill him. simple but funny text. beginners, try and copy from it.

Version: 1.0
Created: 17th Nov 2007 12:28
0
0
Text

A simple code of a 2D line pattern that plays a illusion on the eyez.

Version: 1.0
Created: 8th Nov 2007 05:27
0
0
Basic 2D

A simple matrix style screen loader

Version: 1.4
Created: 7th Nov 2007 15:35
0
0
Text

Generates and rotates a galaxy which is created from a random seed value.

Version: 1.0
Created: 1st Nov 2007 20:01
0
0
Math / Physics

Natural, realistic flight performance, yet easy and intuitive to use.

Version: 1.0
Created: 29th Oct 2007 20:30
0
0
Complete Applications

Working, mathematically based car simulation code for all to use.

Version: 1.0
Created: 29th Oct 2007 20:13
0
0
Complete Applications

Convert the Oddnumbered "Seam Sharing" HeightMap exported from Ted for use with Advanced Terrain - when you want to Tile them. This makes the Seams line up. Simple yet effective. (Note Attached MEdia needs to be converted back to Bitmap to do exactly what I know it will do. Bitmap was to big to upload here. IF you change the HeightMap.bmp to HeightMap.png it may work - I haven't tested that.

Version: 1.0
Created: 17th Oct 2007 12:43
0
0
Complete Applications

Creates a rounded rectangle with a lot of flexibility

Version: 1.0
Created: 16th Oct 2007 07:48
0
0
Basic 2D

My First Game . You need to destroy red cube by placing "mines"

Version: 1.0
Created: 14th Oct 2007 13:28
0
0
Games

move 50 cars and collision to wall

Version: 1.0
Created: 14th Oct 2007 03:35
0
0
Complete Applications

This function deletes everything that you have loaded into DBP. Recoded by JosephB.

Version: 1.0
Created: 8th Oct 2007 21:46
0
0
File

A program that produces a quasi-realistic galaxy, in just 20 lines of code.

Version: 1.0
Created: 6th Oct 2007 03:27
0
0
2D Effects

Travel through 5 Levels of Mazes. No Media!

Version: 1.0
Created: 30th Sep 2007 20:48
0
0
3D

Using this function you can set the FOV of any camera using two angles for x and y.

Version: 1.0
Created: 23rd Sep 2007 21:15
0
0
Camera

A program that calculates reaction time in seconds

Version: 1.0
Created: 23rd Sep 2007 15:43
0
0
Math / Physics

This code creates a text file with all the commands to recreate an image. You then just copy all the text in the file into your programme.

Version: 1.0
Created: 16th Sep 2007 05:59
0
0
Bitmap

rem Basic water tank simulation (REALLY basic!) set display mode 1024,768,32 sync on:sync rate 30 autocam off rem generate a plain texture cls rgb(32,192,255) get image 3,0,0,32,32 rem A few particles nbpart=192 dim partX#(nbpart):dim partY#(nbpart):dim partZ#(nbpart) dim partXd#(nbpart):dim partYd#(nbpart):dim partZd#(nbpart) dim partXTarget#(nbpart):dim partYTarget#(nbpart):dim partZTarget#(nbpart):dim partStatus#(nbpart) for i=0 to 8 load image "splash0"+str$(i+1)+".bmp",500+i next i rem Size of the water matrix matrixSizeX#=120:matrixSizeZ#=90 nsquarex=32:nsquarez=24 tileSizeX#=matrixSizeX#/nsquarex:tileSizeZ#=matrixSizeZ#/nsquarez rem A sine table, to speed up calculations dim sineTable#(360) for i=0 to 359 sineTable#(i)=sin(i) next i rem Create the tank, and texture it with a caustics texture make object box 2,matrixSizeX#,matrixSizeZ#/2,matrixSizeZ# scale object 2,-100,-100,-100 position object 2,0,(matrixSizeZ#/-4),0 load image "caustics.bmp",2:texture object 2,2 rem These variables are used for the movement of the caustics scru#=0.001:scrud#=-0.00001 scrv#=-0.0005:scrvd#=0.000005 rem Create the water matrix make matrix 1,matrixSizeX#,matrixSizeZ#,nsquarex,nsquarez position matrix 1,matrixSizeX#/-2,0,matrixSizeZ#/-2 dim waves(nsquarex,nsquarez) for i=0 to nsquarex for j=0 to nsquarez waves(i,j)=(rnd(72))*5 next j next i rem The wave height is set according to the size of the water matrix wave_height#=matrixSizeX#/60.00 rem Texture the water matrix load image "water.bmp",1 prepare matrix texture 1,1,nsquarex,nsquarez n=0 for j=nsquarez-1 to 0 step -1 for i=0 to nsquarex-1 step 1 inc n set matrix tile 1,i,j,n next i next j ghost matrix on 1 rem Camera initialization camdist#=matrixSizeZ#:bearing#=90:azimuth#=300:camchanged=1 rem Main loop do rem recalculate the height of each vertex of the matrix in a wavy way for i=0 to nsquarex for j=0 to nsquarez set matrix height 1,i,j,sineTable#(waves(i,j))*wave_height# waves(i,j)=waves(i,j)+5 if waves(i,j)>359 then waves(i,j)=0 next j next i rem Smooth matrix normals. Not very useful; just to see how to do it. SmoothMatrixNormals(1,nsquarex,nsquarez,tileSizeX#,tileSizeZ#) rem Change matrix aspect select scancode() case 2 prepare matrix texture 1,1,nsquarex,nsquarez n=0 for j=nsquarez-1 to 0 step -1 for i=0 to nsquarex-1 step 1 inc n set matrix tile 1,i,j,n next i next j ghost matrix on 1 endcase case 3 prepare matrix texture 1,3,nsquarex,nsquarez ghost matrix off 1 endcase case 4 prepare matrix texture 1,3,nsquarex,nsquarez set matrix wireframe on 1 endcase endselect rem Update matrix update matrix 1 rem Scroll the caustics texture scru#=scru#+scrud#:if (scru#<=-0.001 and scrud#<0) or (scru#>=0.001 and scrud#>0) then scrud#=scrud#*-1 scrv#=scrv#+scrvd#:if (scrv#<=-0.001 and scrvd#<0) or (scrv#>=0.001 and scrvd#>0) then scrvd#=scrvd#*-1 scroll object texture 2,scru#,scrv# rem Create some "splashes" here and there if ecla<2 and timer()-oldtimer>1000 x#=(matrixSizeX#/2.00)-rnd(matrixSizeX#):y#=0:z#=(matrixSizeZ#/2.00)-rnd(matrixSizeZ#) oldtimer=timer() for i=ecla*20 to (ecla*20)+19 if object exist(500+i) = 0 make object plain 500+i,2,2 texture object 500+i,500+rnd(8):ghost object on 500+i else show object 500+i endif partX#(i)=x#:partY#(i)=y#:partZ#(i)=z# partXd#(i)=((matrixSizeX#/10.00)-rnd(matrixSizeX#/5.00))/20.00 partZd#(i)=((matrixSizeZ#/10.00)-rnd(matrixSizeZ#/5.00))/20.00 partYd#(i)=(rnd(matrixSizeZ#/3.00)/15.00) partYtarget#(i)=partY#(i):partStatus#(i)=ecla+1 next i endif rem Animate those "splashes" ecla=0 for i=0 to 192 if partStatus#(i)>0 if partStatus#(i)>ecla then ecla=partStatus#(i) partX#(i)=partX#(i)+partXd#(i) partY#(i)=partY#(i)+partYd#(i) partZ#(i)=partZ#(i)+partZd#(i) partYd#(i)=partYd#(i)-(matrixSizeZ#/1000.00) position object 500+i,partX#(i),partY#(i),partZ#(i) set object to camera orientation 500+i if partY#(i) < partYtarget#(i) then hide object 500+i:partStatus#(i)=0 endif next i rem Move and zoom the camera with mouse movex=mousemovex():movey=mousemovey() if movex<>0 or movey<>0 azimuth# = azimuth# + movey bearing# = wrapvalue(bearing# + movex/2) if azimuth#<280 then azimuth#=280 if azimuth#>350 then azimuth#=350 camchanged = 1 endif click=mouseclick() if click>0 if click=1 and camdist#>matrixSizeZ#/2.00 then dec camdist#:camchanged = 1 if click=2 and camdist#<matrixSizeZ#*2.00 then inc camdist#:camchanged = 1 endif rem If the camera moved, recalculate its position if camchanged=1 camx# = camdist# * sin(azimuth#) * cos(bearing#) camz# = camdist# * sin(azimuth#) * sin(bearing#) camy# = camdist# * cos(azimuth#) position camera camx#,camy#,camz# point camera 0,0,0 camchanged = 0 endif rem And that's it ! text 10,10,str$( screen fps() )+" FPS; Hit 1,2,or 3 to switch modes" sync loop rem Use matrix normals to make it smooth (from the DarkBasic help: "help\examples\matrix3d\exam08.dba") function SmoothMatrixNormals(numMatrix,sizeX,sizeZ,tileSizeX#,tileSizeZ#) for z=1 to sizeZ-1 for x=1 to sizeX-1 rem Get matrix heights h8#=get matrix height(numMatrix,x,z-1) h4#=get matrix height(numMatrix,x-1,z) h#=get matrix height(numMatrix,x,z) h2#=get matrix height(numMatrix,x,z) rem Calculate projected angle X using heights x1#=(x-1)*tileSizeX# : y1#=h# x2#=(x+0)*tileSizeX# : y2#=h4# dx#=x2#-x1# dy#=y2#-y1# ax#=atanfull(dx#,dy#) ax#=wrapvalue(90-ax#) rem Calculate projected angle Z using heights z1#=(z-1)*tileSizeZ# : y1#=h2# z2#=(z+0)*tileSizeZ# : y2#=h8# dz#=z2#-z1# dy#=y2#-y1# az#=atanfull(dz#,dy#) az#=wrapvalue(90-az#) rem Make normal from projected angle nx#=sin(ax#) ny#=cos(ax#) nz#=sin(az#) rem Setting matrix normal for smoothness set matrix normal numMatrix,x,z,nx#,ny#,nz# next x next z endfunction

Version: 1.0
Created: 12th Sep 2007 14:03
0
0
Complete Applications

This is example how to use write code cleaned and howto write Fly type camera:

Version: 1.0
Created: 10th Sep 2007 18:11
0
0
Complete Applications

This function will take two images of any size (equal or not) and blend them together according to the values of a third greyscale alpha map image

Version: 1.0
Created: 10th Sep 2007 10:59
0
0
Memblocks

This program is for finding the square root of any number you type in.

Version:
Created: 7th Sep 2007 22:09
0
0
Math / Physics

calculates the second endpoint of a line from one endpoint and the midpoint

Version: 1.0
Created: 4th Sep 2007 19:30
0
0
Complete Applications

calculates the midpoint and distance of 2 points

Version: 1.0
Created: 4th Sep 2007 19:29
0
0
Complete Applications

This will simply make a box with a border around it. Useful for Heads Up Displays or pop-up messages.

Version: .1
Created: 1st Sep 2007 13:19
0
0
Basic 2D

Make double click with left mouse in Dark Basic. You can adjust funtion time values as you like to adapt your program.

Version: 1.0
Created: 31st Aug 2007 06:27
0
0
Functions

A free version of mine of game of life. I am not the first who write this game and I supose someone will do better than I.

Version: 1.0
Created: 30th Aug 2007 20:56
0
0
Complete Applications