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:

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

Example:
  1. 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:

  1. dbColorObject(object id, color);  

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

  1. 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:

  1. // Dark GDK - The Game Creators - www.thegamecreators.com  
  2.   
  3. // the wizard has created a very simple project that uses Dark GDK  
  4. // it contains the basic code for a GDK application  
  5.   
  6. // whenever using Dark GDK you must ensure you include the header file  
  7. #include "DarkGDK.h"  
  8.   
  9. // the main entry point for the application is this function  
  10. void DarkGDK ( void )  
  11. {  
  12. // turn on sync rate and set maximum rate to 60 fps  
  13. dbSyncOn   ( );  
  14. dbSyncRate ( 60 );  
  15. //Creates a 400 X 200 plain object with an object id of 1 and   
  16. dbMakeObjectPlain(1,400,200);  
  17. //Applies a red color to our plain  
  18. dbColorObject(1,dbRGB(255,0,0));  
  19. //Positions the camera on the side of our object  
  20. dbPositionCamera(-1,-600,-100);  
  21. // our main loop  
  22. while ( LoopGDK ( ) )  
  23. {  
  24. // update the screen  
  25. dbSync ( );  
  26. }  
  27. //deletes all objects  
  28. for ( int i = 1; i < 50; i++ )  
  29. dbDeleteObject ( i );  
  30. // return back to windows  
  31. return;  
  32. }