Creating a plain object in DarkGDK

A plain is a mesh object that can be used as ground in your game scene. To create a plain object, use the dbMakeObjectPlain function.

Syntax:

dbMakeObjectPlain(object id,plain width,plain height);

Example:
dbMakeObjectPlain(1,100,100);

By default an object is drawn in gray. You can add colors to your plain object by Using the dbColorObject function which has the following syntax:

dbColorObject(object id, color);

Colors can be defined by using the dbRGB function which has the following syntax:

dbRGB(red,green,blue);

Wherein red, green, and blue are numbers that ranges from 0-255.

The following codes demonstrates dbMakeObjectPlain and dbColorObject at work:

// Dark GDK - The Game Creators - www.thegamecreators.com

// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application

// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"

// the main entry point for the application is this function
void DarkGDK ( void )
{
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn   ( );
dbSyncRate ( 60 );
//Creates a 400 X 200 plain object with an object id of 1 and 
dbMakeObjectPlain(1,400,200);
//Applies a red color to our plain
dbColorObject(1,dbRGB(255,0,0));
//Positions the camera on the side of our object
dbPositionCamera(-1,-600,-100);
// our main loop
while ( LoopGDK ( ) )
{
// update the screen
dbSync ( );
}
//deletes all objects
for ( int i = 1; i < 50; i++ )
dbDeleteObject ( i );
// return back to windows
return;
}

Accepting Decimal or Floating Point Inputs(Windows Forms Applications-Microsoft Visual C++ 2008 Express Edition)

In general, every data inputted in a textbox are treated as string. For instance if you enter 5, Visual C++ 2008 will treat it as “5” which is a problem if you intend to use the input in calculations. If you have read my post about Accepting Numeric Data, we have used int::Parse function to treat the input as a numeric data. Unfortunately int::Parse works only on whole number inputs and returns a build errors on floating point input. To prepare your variable or control in accepting floating point input use the float::Parse function.

Syntax:
Destination=float::Parse(Source);

Wherein;
1. Source can be a control or variable that where you will be getting your floating point data.
2. Destination is a control or variable will you will be displaying or storing your floating point data.

The following steps demonstrate float::Parse at work:

1. Start MSVC++ Express 2008 by clicking on the Start button, All Programs then clicking on the Microsoft Visual C++ Express Edition Start menu option.

2. Click File>New>Project. The new project dialog box will then come into view.

3. Select Windows Forms Application from the Visual Studio Installed templates, type the project name>Click Ok.
After clicking the Ok button, an IDE suited for windows forms application will then appear containing a form, a toolbox window, and a properties window.

4. Create a user interface similar to the one below:



Note: Those texts that appear beside each control are the suggested names for our form controls in this example. If you noticed I am using .Net naming convention in naming controls because it is simpler to use than Leszynski naming convention. To change the value of the name property of each control, just click each individual control then locate the name property in the properties window then assign those descriptive names in our illustration correspondingly.

5. Double-click your form then locate the following line:

#pragma endregion

6. Declare the following variables below it:

float fltcurrpricex,fltcurrpricey, fltdiscountx,fltdiscounty, fltnewpricex,fltnewpricey;

Declaring these variables below the #pragma endregion line allows our variables to be available publicly and to be used by other procedures.

Your code should now appear just like this:

#pragma endregion  
float fltcurrpricex,fltcurrpricey, fltdiscountx,fltdiscounty, fltnewpricex,fltnewpricey;  

7. Double-click the control named ComputeButton,type the following:

fltcurrpricex=float::Parse(this->XPricetextBox->Text);
fltcurrpricey=float::Parse(this->YPricetextBox->Text);
fltdiscountx=float::Parse(this->DiscountXtextBox->Text);
fltdiscounty=float::Parse(this->DiscountYtextBox->Text);
fltnewpricex= fltcurrpricex - (fltcurrpricex*fltdiscountx);
fltnewpricey= fltcurrpricey - (fltcurrpricey*fltdiscounty);
this->XPricelabel->Text=Convert::ToString(fltnewpricex);
this->YPricelabel->Text=Convert::ToString(fltnewpricey);

8. Your could willnow look like this:

private: System::Void ComputeButton_Click(System::Object^  sender, System::EventArgs^  e) 
{
fltcurrpricex=float::Parse(this->XPricetextBox->Text);
fltcurrpricey=float::Parse(this->YPricetextBox->Text);
fltdiscountx=float::Parse(this->DiscountXtextBox->Text);
fltdiscounty=float::Parse(this->DiscountYtextBox->Text);
fltnewpricex= fltcurrpricex - (fltcurrpricex*fltdiscountx);
fltnewpricey= fltcurrpricey - (fltcurrpricey*fltdiscounty);
this->XPricelabel->Text=Convert::ToString(fltnewpricex);
this->YPricelabel->Text=Convert::ToString(fltnewpricey);
}

9.Press F5 to test your appliaction.