Introduction to Dark Basic

Last update on May 11, 2009 08:27 AM by jak58
Published by jad05

Introduction to Dark Basic








What is Dark Basic?


Dark Basic is an object oriented programming language that allows you to create and personalize games, slideshows or other applications. You don't need to be an expert in software programming to be able to understand and use Dark Basic as it is provided with a set of simple commands, suitable for any beginner.

DarkBASIC also allows you to create your own games, demos, slideshows or business application based upon the BASIC programming methodology and rest assured a lot of tutorials are available.


You can get a free trial version of the program from the following link: http://darkbasic.thegamecreators.com/

Step 1: How to start?


You will be prompted to enter all the commands in a window in order to create your own environment or whatever game you have in mind. Hence, the first thing required is to know what you want the screen to display. You can use the sample below in order to display a window entitled EDPLN 2 Freeware SE and that will enable your mouse use but disable the ESC key.


set window on
set window layout 1,1,1
set window title "System backup copy (1.1)"
show window
show mouse
disable escapekey
sync on
gosub start
end

Step 2: How to create a simple menu?


Creating a simple menu will allow the user to use and go through the program. Hence, you can use the codes below to create a basic menu with the command ‘A’ to Save, ‘B’ to define a filter, ‘C’ to choose a way out of the game or environment and ‘Q’ to quit the game.


start: 
rem Definition defaults 
$ access = 'E: \ " 
rem Start the main loop 
do 
cls 0 

To replace print text on the screen (and not to print) 
print "Utility Backups." 
print "" 
print "to save A, B to define a filter, C to change the output path, Q to exit." 

rem Request a value to the user and saves it as $ key 
input "Choose the action to do and press Enter>", $ key 

rem analysis of data received 
if key $ <> "A" and $ key <> "a" and key $ <> "B" and key $ <> "b" and key $ <> "C" and key $ <> "c" and key $ <> "Q" and key $ <> "q" then print "Please choose a valid choice." : Sleep 2000: GOSUB start 
rem The previous line displays an error message for 2 seconds and then back to the beginning if the election is invalid. 
rem I have not forgotten in the previous line to analyze the upper and lower case. 
rem Another solution would have been $ key turning in capitalization to shorten the code. 

rem Now that the analysis is done, use the data. 
It will replace begin to see if the first choice was made: 

if $ key = "a" or $ key = "A" then save GOSUB 
rem If the choice was A or A, then we will save. 

if $ key = "b" or $ key = "B" then GOSUB option1 
Similarly to replace B, you arrive at the sub-menu option1 

if $ key = "c" or $ key = "C" then GOSUB option2 
Similarly rem for C to reach the submenu option2 

if $ key = "q" or $ key = "Q" then end 
rem Here, we saw that if the choice was to leave, leave the program without warning. 

rem Now that diversions were made, it closes the loop for security (which will save us, you should see it if you run this code when we have finished). 
loop 
return

How to create sub functions


Sub functions cannot be placed anywhere. There will be 3 examples of sub functions given and they must each be placed in a specific place.

Subfunction 1


This subfunction should be used where the filters are located.


option1: 
do 
cls 0 
print "menu Filtering Files" 
print "" 
input "Please enter a file name to exclude or '/' to exit", next $ 
rem Now we will create an array called $ exclude data may contain 255x1, 255: p 
Sunday exclude $ (255.1) 

It replaced the data ... 
if next = $ "/ \" or next $ $ = chr (34) + "/ \" + $ chr (34) then exit 
When replacing the analysis of data, it was back to the main menu on the user's request 
replaced by leaving the loop exit. 
rem Now, fill the table with a loop: for the, to, next 

    for nb = 1 to # 255 

       rem is analyzed if the space is free 
       if exclude $ (# nb, 1) = "" then exclude $ (# nb, 1) = next $: exit 
       rem fill up only if it is free then we go out of the loop. 

    next nb # 
But rem ... and if the table was full!? 
rem Well you know how to analyze the data now, good luck ^ ^ 

rem So now we close the loop 
loop 
And we replaced the compiler that the sub-function stops there, to return to the main menu. 
return

Subfunction 2


This one should be placed in the way out. Then you should ask the user if he is willing to modify the access for this type of filter.

option2: 
do 
cls 0 

print "Change copy output." 
print "" 
print "current output path:" $ + access 
input "Do you really want to change the path (o: yes / n: no)>", $ choice 

choice if $ <> "o" and choice $ <> "O" and choice $ <> "yes" and choice $ <> "Yes" and choice $ <> "YES" and choice $ <> "n" and choice $ <> "N" and choice $ <> "no" and choice $ <> "No" choice and $ <> "NO" 
    print "Invalid Choice." 
    sleep 2000 
    GOSUB option2 
endif 

if $ choice = "o" or choice $ = "O" or choice $ = "yes" or choice $ = "Yes" or choice $ = "YES" 
    input "Please enter a new path>", $ access 
else 
    exit 
endif 
loop 
return


===Subfunction 3:The Batch file

You can also use DarkBasic to make a batch file simply by pasting the following codes:

save: 
cls 0 

print "System backup copy" 
print "" 
print "Source:" + get $ dir () 
print "Destination:" $ + access 
print "Do you really want to copy the file" 
input current to "access + $ +" (o: yes / n: no)> ", $ choice 

choice if $ <> "o" and choice $ <> "O" and choice $ <> "yes" and choice $ <> "Yes" and choice $ <> "YES" and choice $ <> "n" and choice $ <> "N" and choice $ <> "no" and choice $ <> "No" choice and $ <> "NO" 
    print "Invalid Choice." 
    sleep 2000 
    GOSUB save 
endif 

rem closing of any open file. 
if file open (1) = 1 then close file 1 

rem Delete any file with the same name already exists. 
if file exist ( "code.bat") = 1 then delete file "code.bat" 

rem Creating and opening a batch file (. bat) 
open to write 1, "code.bat" 

rem Writing code. 
write string 1, "@ echo off" 
write string 1, "cd" $ dir + get () 
write string 1, "xcopy" + $ chr (34) + get $ dir () + $ chr (34) + "" + $ chr (34) + $ access + $ chr (34) + "/ s / c / q / g / h / x / y " 
write string 1, "exit" 
close file 1 

rem Now that the code is created, it runs ... 

executable file get $()+" dir \ code.bat "," ", get $ dir (), 0 

rem is not 100% sure that this works: s 
rem Our application will wait for the copy is complete before continuing. 
will not be replaced copied the files and subfolders in the current directory of DarkBASIC code. 

print "When the copy is complete, you can continue. Use CTRL + C in the window" 
print "MS-BATCH (black) to stop his execution." 
sync 

rem The next block will wait for a response from the user. 
while Scancode 0 = 
endwhile 

rem And so is the end of the code ... 
return

Key Features of Dark Basic

  • Automated Double Buffering
  • Full-Screen Display Modes
  • Gamma Control
  • Mouse, Keyboard and Gaming controller input.
  • Force-Feedback Control
  • System Handling
  • File Handling
  • Video Animation Control
  • Audio Control
  • Super-Fast 2D blitting
  • Mirror, Stretch, Blur and Fade
  • Screen-Sized and animated sprites
  • Transparency
  • Fast pixel perfect Collision
  • 2D Drawing Functions
  • Landscape Terraforming
  • Built-in 3D Primitives
  • Polygon Collision Detection
  • Full Model Manipulation
  • Model Animation
  • Ambient lighting
  • Directional Lighting
  • Texture filtering
  • Alpha blending
  • Fogging
Best answers for « Introduction to Dark Basic » in :
Base64 encoding Show Base64 encoding The concept of Base64 encoding entails using US-ASCII (non-accented) characters to encode any sort of data in 8-bit form. Email protocols were originally designed to send messages in plain text only. But as email systems vary...
Basic MS-Dos commands ShowBasic MS-Dos commands Intro The command prompts: Intro Here is a list of basic commands that you can use in a DOS prompt (e.g. a using a boot disk). To have additional information about these commands, type /? after entering the...
Basic Excel Formulas ShowBasic Excel Formulas Below are some basic formulas for Microsoft excel: Basic formula : ADDITION cell A1 to A10 = sum (A1: A10) AVERAGE cell A1 to A10 = average (A1: A10) MAXIMUM cell A1 to A10 = max (A1: A10) MINIMUM...
[Bash]Parameters Show[Bash]Parameters Intro Example 1 Example 2 Initialize parameters Examples Example 3 Intro You can provide a script on the command line and arguments also known as parameters for its implementation. There are two categories of...
Download Today Greek Calendar ShowIt is a fact, the calendar Greek differs from the one that everybody uses, that is the gregorian. The Greek calendar is based on the easter day of the orthodox Christians. Today Greek Calendar or "Today" is a calendar based on the vacation of the...
Download MBSA ShowMBSA stands for Microsoft Baseline Security Analyzer. This software allows you to analyze your operating system: Windows NT/2000/XP/Server 2003. Once MBSA is launched thrown, you will see: - The red cross indicates that critical updates are...
Spreadsheet - Formulas ShowIntroduction to Formulas The main use of a spreadsheet is to automate calculations, which means using cells to perform operations based on values in other cells. The spreadsheet recalculates all the values each time a change is made to the value of...
Ethernet ShowIntroduction to Ethernet Ethernet (also known as IEEE 802.3 standard) is a data transmission standard for local area networks based on the following principle: All machines on an Ethernet network are connected to the same communication line, made...
Flashing the BIOS ShowWhat does it mean "to flash"? The BIOS (Basic Input/Output System) is a small memory chip located on the motherboard containing data that defines the system parameters. The data may, however, contain errors (bugs). Furthermore, when new hardware...