0

Hello, I have a somewhat basic question about Dark GDK. I am taking Dark Basic courses, and converting the code to Dark GDK (not a difficult task), because I am unwilling to spend $60 on an inferior compiler.

I am taking a complete FPS tutorial. It went fine for a while, until I had to convert an integer to a string. The code, with my knowledge, I knew would not be accepted in Dark GDK. However, I could not figure out the equivalent in Dark GDK. I know you can do it in C++, but I have never been able to get C++ and Dark GDK to work well together. I have already asked the Dark GDK forum, but I have had no replies.

Here is the code in Dark Basic

IF OBJECT EXIST(2)=1

CENTER TEXT OBJECT SCREEN X(2),OBJECT SCREEN Y(2)-70,"Enemy Health: "+str$(EnemyHP#)

ENDIF

Here is the complete code a little farther along in Dark Basic:

`Created by <your name>

`Date Started: <current date>

SYNC ON:SYNC RATE 0:HIDE MOUSE

MAKE OBJECT SPHERE 1,50:COLOR OBJECT 1,RGB(000,255,000)

MAKE OBJECT SPHERE 2,50:COLOR OBJECT 2,RGB(255,000,000):POSITION OBJECT 2,130,0,0

MAKE OBJECT BOX 3 ,100,100,5:POSITION OBJECT 3,0,0,150

MAKE OBJECT SPHERE 9999,30

MAKE MESH FROM OBJECT 1,9999

DELETE OBJECT 9999

ADD LIMB 1,1,1

OFFSET LIMB 1,1,0,0,500

DELETE MESH 1

POSITION CAMERA 0,500,-500:POINT CAMERA 0,0,0

EnemyHP#=5000

Ammo#=1000

MaxAmmo#=1000

DO

IF UPKEY()=1 THEN MOVE OBJECT 1,.5

IF DOWNKEY()=1 THEN MOVE OBJECT 1,-.5

IF LEFTKEY()=1 THEN TURN OBJECT LEFT 1,.7

IF RIGHTKEY()=1 THEN TURN OBJECT RIGHT 1,.7

IF MOUSECLICK()=1

IF Ammo#>0

DEC Ammo#,1

ENDIF

IF OBJECT EXIST(2)=1

IF Ammo#>0

IF INTERSECT OBJECT (2, LIMB POSITION X(1,1), LIMB POSITION Y(1,1), LIMB POSITION Z(1,1), OBJECT POSITION X(1),OBJECT POSITION Y(1), OBJECT POSITION Z(1))>0

DEC EnemyHP#,1

ENDIF

ENDIF

ENDIF

ENDIF

IF EnemyHP#=0

IF OBJECT EXIST(2)=1

DELETE OBJECT 2

ENDIF

ENDIF

IF KEYSTATE(19)=1 AND Ammo#=0 THEN Ammo#=MaxAmmo#

IF OBJECT EXIST(2)=1

CENTER TEXT OBJECT SCREEN X(2),OBJECT SCREEN Y(2)-70,"Enemy Health: "+str$(EnemyHP#)

ENDIF

TEXT 0,SCREEN HEIGHT()-50,"Ammo: "+str$(Ammo#)

SYNC

LOOP

Here is what I have so far in Dark GDK:

/*My first FPS
Created by arithehun
Date Started:4/24/10
*/

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

using namespace std;

// 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 ( 0 );
	dbHideMouse();
	dbPrint("Hi");
	
	//Object Sphere. Decimals in oder
	dbMakeObjectSphere(1,50);
	dbColorObject(1,RGB(000,225,000));

	dbMakeObjectSphere(2,50);
	dbColorObject(2,RGB(000,000,225));
	dbPositionObject(2,130,0,0);

	//Object wall. Decimals in order
	dbMakeObjectBox(3,100,100,5);
	dbColorObject(3,RGB(225,000,000));
	dbPositionObject(3,0,0,150);

	//Shooting Limb
	dbMakeObjectSphere(9999,30);
	dbMakeMeshFromObject(1,9999);
	dbDeleteObject(9999);
	dbAddLimb(1,1,1);
	dbOffsetLimb(1,1,0,0,500);
	dbDeleteMesh(1);

	//Position Camera
	dbPositionCamera(0,500,-500);
	dbPointCamera(0,0,0);

	int enemyhp=5000;
	int ammo=1000;
	int maxammo=1000;




	// our main loop
	while ( LoopGDK ( ) )
	{
		if(dbUpKey()==1){
			dbMoveObject(1,0.5f);
		}
		if(dbDownKey()==1){
			dbMoveObject(1,-0.5f);
		}
		if(dbRightKey()==1){
			dbMoveObjectRight(1,0.7f);
		}
		if(dbLeftKey()==1){
			dbMoveObjectLeft(1,0.7f);
		}

		//Shooting
		if(dbMouseClick()==1){
			if(ammo>0){
				int ammo();-1;
		}
			if(dbObjectExist(2)){
				if(ammo>0){
					if(dbIntersectObject(2, dbLimbPositionX(1,1), dbLimbPositionY(1,1), dbLimbPositionZ(1,1), dbObjectPositionX(1),dbObjectPositionY(1), dbObjectPositionZ(1))>0){
						int enemyhp();-1;
					}
				}
			}
		}
		if(enemyhp=0){
			if(dbObjectExist(2)==1){
				dbDeleteObject(2);
			}
		}


		dbSync ( );
	}

	// return back to windows
	return;
}

I hope this can help you solve this problem. I really appreciate the help a lot!

Thanks again!
arithehun

Edited by arithehun: The title was wrong.

1
Contributor
1
Reply
4
Views
7 Years
Discussion Span
Last Post by arithehun
0

Actually, I posted this in a Dark GDK forum too, and I have now replied! I have noticed there were many views, so a lot of people want to know, but do not know how.

Now you can!
Go here to see my other post answered:
Dark GDK Forum: Question Solved

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.