Well no matter what I do I just can't get the example programs to work. And I haven't been able to find any other examples by searching. So I decided to try to learn how to use the plugin just from the help file. I am trying to implement it in my game, but I am getting a run time error.
The relevant section of code:
//-------------------------------------------------------------------------
// Loading functions
//-------------------------------------------------------------------------
// Function to load 3D objects
int Load_3D (char Local_Filepath[])
{
int Local_ID;
// Generate an ID number for the mesh
Local_ID = ObjID;
++ObjID;
// Load the mesh
dbLoadObject (Local_Filepath, Local_ID);
// Setup collision
SC_SetupObject (Local_ID, 1, 0);
return Local_ID;
}
The entire code incase the section I think is relevant actually isn't the real problem:
#include "DarkGDK.h"
#include "SC_Collision.h"
//-------------------------------------------------------------------------
// Global variables
//-------------------------------------------------------------------------
int ObjID;
int TexID;
int SndID;
int Game_Mode; // 0 = main menu, 1 = loading, 2 = gameplay, 3 = cutscene, 4 = pause menu
//-------------------------------------------------------------------------
// Structures
//-------------------------------------------------------------------------
// Structure for human characters
struct Char_Struct
{
int Mesh; // .X mesh file for the character
int Type; // 0 = Player, 1 = Ally, 2 = Enemy, 3 = Neutral
float Position[3]; // XYZ coordinate of the character's initial position in the level
float Rotation; // The character's initial rotation in the level
float Health_Max; // If max <= 0 the character is dead right from the start and therefore
float Health_Current; // only exists as a corpse, otherwise he/she will die when current <= 0
int Alert_Mode; // 0 = undetected, 1 = alert, 2 = searching, 3 = detected
};
// Structure for cover objects
struct Cover_Struct
{
int Mesh; // .X mesh file for the cover object
float Position[3]; // XYZ coordinate for the cover object's position
float Rotation; // Rotation of the cover object
float Heath_Max; // If max < 0 the cover object is indestructible,
float Health_Current; // otherwise it will be destroyed when current <= 0
};
// Structure for levels
struct Level
{
int Mesh; // .X mesh file for the level
float End_Position[3]; // A cube that ends the level when
float End_Scale[3]; // entered by the player
struct Cover_Struct Cover[1000]; // Array of all the cover objects in the level
struct Char_Struct Character[1000]; // Array of all the human characters in the level
};
//-------------------------------------------------------------------------
// Loading functions
//-------------------------------------------------------------------------
// Function to load 3D objects
int Load_3D (char Local_Filepath[])
{
int Local_ID;
// Generate an ID number for the mesh
Local_ID = ObjID;
++ObjID;
// Load the mesh
dbLoadObject (Local_Filepath, Local_ID);
// Setup collision
SC_SetupObject (Local_ID, 1, 0);
return Local_ID;
}
//-------------------------------------------------------------------------
// Structure Functions
//-------------------------------------------------------------------------
struct Char_Struct Create_Character (char Local_Mesh[], int Local_Type, float Local_X, float Local_Y, float Local_Z, float Local_Rot, float Local_HP)
{
struct Char_Struct Local_Character;
// Load character mesh
Local_Character.Mesh = Load_3D (Local_Mesh);
// Set starting position and rotation
Local_Character.Position[0] = Local_X;
Local_Character.Position[1] = Local_Y;
Local_Character.Position[2] = Local_Z;
Local_Character.Rotation = Local_Rot;
// Set health
Local_Character.Health_Max = Local_HP;
Local_Character.Health_Current = Local_Character.Health_Max;
// Position and rotate character
dbPositionObject (Local_Character.Mesh, Local_Character.Position[0], Local_Character.Position[1], Local_Character.Position[2]);
dbRotateObject (Local_Character.Mesh, 0, Local_Character.Rotation, 0);
return Local_Character;
}
// Create_Cover
// Function to load the current level
struct Level Load_Level (char Local_Mesh[], char Local_Player_Mesh[], float Local_X, float Local_Y, float Local_Z, float Local_Rot)
{
struct Level Local_Level;
struct Char_Struct Local_Character;
// Load world mesh
Local_Level.Mesh = Load_3D (Local_Mesh);
// Create the player character
Local_Level.Character[0] = Create_Character (Local_Player_Mesh, 0, Local_X, Local_Z, Local_Y, Local_Rot, 10);
return Local_Level;
}
// End_Level
//-------------------------------------------------------------------------
// Main function
//-------------------------------------------------------------------------
void DarkGDK (void)
{
//-------------------------------------------------------------------------
// Initialization
//-------------------------------------------------------------------------
dbSyncOn ();
dbSetDisplayMode (dbDesktopWidth (), dbDesktopHeight(), 32);
dbSetWindowOff ();
dbAutoCamOff ();
dbHideMouse ();
dbColorBackdrop (dbRGB(0, 0, 0));
SC_Start();
struct Level Current_Level;
// Main Loop
for (int Main_Loop = 1; Main_Loop > 0;)
{
switch (Game_Mode)
{
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Main Menu
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
case 0:
Game_Mode = 1; // TEMPORARY
break;
//-------------------------------------------------------------------------
// Load Level
//-------------------------------------------------------------------------
case 1:
// Determine which level to load
// Create the level
Current_Level = Load_Level ("Data/3D/World/TestLevel/mesh.x", "Data/3D/Characters/TestPlayer/mesh.x", -45.00, -32.00, 0.00, 90.00);
// Proceed to gameplay
Game_Mode = 2;
break;
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Gameplay
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
case 2:
// If escape is pressed, go to pause menu
if (dbKeyState(1) == 1)
{
Game_Mode = 4;
}
//-------------------------------------------------------------------------
// Player Controls
dbRotateObject (Current_Level.Character[0].Mesh, 0, dbObjectAngleY(Current_Level.Character[0].Mesh) + (dbMouseMoveX() * .25), 0);
if (dbKeyState(17) == 1) // Forward
{
dbMoveObject (Current_Level.Character[0].Mesh, .07);
}
if (dbKeyState(31) == 1) // Backward
{
dbMoveObject (Current_Level.Character[0].Mesh, -.07);
}
if (dbKeyState(30) == 1) // Left
{
dbRotateObject (Current_Level.Character[0].Mesh, 0, dbObjectAngleY(Current_Level.Character[0].Mesh) - 90, 0);
dbMoveObject (Current_Level.Character[0].Mesh, .07);
dbRotateObject (Current_Level.Character[0].Mesh, 0, dbObjectAngleY(Current_Level.Character[0].Mesh) + 90, 0);
}
if (dbKeyState(32) == 1) // Right
{
dbRotateObject (Current_Level.Character[0].Mesh, 0, dbObjectAngleY(Current_Level.Character[0].Mesh) + 90, 0);
dbMoveObject (Current_Level.Character[0].Mesh, .07);
dbRotateObject (Current_Level.Character[0].Mesh, 0, dbObjectAngleY(Current_Level.Character[0].Mesh) - 90, 0);
}
//-------------------------------------------------------------------------
// Camera
dbPositionCamera ( dbObjectPositionX(Current_Level.Character[0].Mesh),
dbObjectPositionY(Current_Level.Character[0].Mesh) + 1.4,
dbObjectPositionZ(Current_Level.Character[0].Mesh));
dbRotateCamera (dbCameraAngleX() + (dbMouseMoveY() * .25), dbObjectAngleY(Current_Level.Character[0].Mesh), 0);
dbMoveCamera (-2.35);
dbRotateCamera (dbCameraAngleX(), dbCameraAngleY() + 90, 0);
dbMoveCamera (.65);
dbRotateCamera (dbCameraAngleX(), dbObjectAngleY(Current_Level.Character[0].Mesh), 0);
break;
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
// Pause Menu
//------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
case 4:
Main_Loop = 0; // TEMPORARY
}
//-------------------------------------------------------------------------
// Update Screen
//-------------------------------------------------------------------------
dbSync ();
}
return;
}
The error is in the attached image.
Hail to the king baby
I love Evil Dead.