Yeah, well, i didn't know how to title this
Anyways, its a wierd little thing, i try to compile the texture tutorial (with some changes) and when i press ctrl+F5 to start the program without debugging, it runs all fine. But when i try to run the .exe from explorer, a messagebox pops out, saying : "6", when i click ok, another one comes up saying that Instruction 0x005c2d1e referred to address 0x0000008. Memory could not be read. Click ok to terminate the program, cancel to debug (rough translation from norwegian).
Any ideas? (I've tried compiling both as debug and release, none works)
Heres the code, i guess you want it
// Dark GDK - The Game Creators - www.thegamecreators.com
// include the Dark GDK header
#include "DarkGDK.h"
/*int person()
{
}*/
void gravity()
{
float x = dbObjectAngleX(1000);
float y = dbObjectAngleY(1000);
dbRotateObject(1000,0,0,dbObjectAngleZ(1000));
dbMoveObjectDown(1000,0.5);
dbRotateObject(1000,x,y,dbObjectAngleZ(1000));
}
void DarkGDK ( void )
{
// entry point for the application
float fCameraAngleX = 0.0f;
float fCameraAngleY = 0.0f;
// switch on sync rate and set to a maximum of 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
dbMakeObjectBox (1000,10,10,1);
//Posistion it on the screen
dbPositionObject (1000,385,23,100);
dbRotateObject(1000,90,0,0);
//scale it
dbScaleObject ( 1000,100,100,100);
//color it
dbColorObject ( 1000, dbRgb ( 255 , 0, 0 ));
//i dunno...
dbSetObjectSpecularPower ( 1000,255);
// we are going to use a skybox in this demo and it will
// be scaled up to quite a large size, this will initially
// result in it being outside of the cameras default range
// therefore it will not be drawn, to adjust this we simply
// increase the cameras range
dbSetCameraRange ( 1.0f, 30000.0f );
// two textures are going to be used for the terrain, the first
// will be the diffuse part and the second will be used to
// create extra detail on the terrain
dbLoadImage ( "texture.jpg", 1 );
dbLoadImage ( "detail.jpg", 2 );
// the first step in creating a terrain is to call the
// function dbSetupTerrain, this will perform some internal
// work that allows us to get started
dbSetupTerrain ( );
// now we can get started on making the terrain object
dbMakeObjectTerrain ( 1 );
// here we pass in a heightmap that will be used to create the terrain
dbSetTerrainHeightMap ( 1, "map.bmp" );
// now we set the scale, this will have the effect of making
// the terrain large on the X and Z axis but quite small on the Y
dbSetTerrainScale ( 1, 30.0f, 6.0f, 30.0f );
// adjust the lighting for the terrain, this function takes the ID
// number, then a direction for the light, then 3 colours for the light
// and finally the scale, by using this function we can adjust the
// overall colour of the terrain
dbSetTerrainLight ( 1, 1.0f, -0.25f, 0.0f, 1.0f, 1.0f, 0.78f, 0.5f );
// in this call we're telling the terrain that its diffuse texture
// will come from image 1 and its detail texture will come from
// image 2
dbSetTerrainTexture ( 1, 1, 2 );
// once we have set all properties of the terrain we can build it,
// at this point it gets created and added into your world
dbBuildTerrain ( 1 );
// with the terrain in place we can now load a skybox
dbLoadObject ( "skybox2.x", 2 );
// we dont need it to respond to light so switch light off
dbSetObjectLight ( 2, 0 );
// make the skybox much larger
dbScaleObject ( 2, 30000, 30000, 30000 );
// position the camera
dbPositionCamera ( 385, 23, 100 );
// adjust texture properties of sky box
dbSetObjectTexture ( 2, 3, 1 );
// now onto our main loop
while ( LoopGDK ( ) )
{
if (!dbKeyState(35))
{
gravity ();
};
if (dbKeyState(35)& dbSpaceKey())
{
if (dbKeyState(42)||dbKeyState(54))
{
gravity();
};
gravity();
}
// let the user move the camera around with the arrow keys
//dbControlCameraUsingArrowKeys ( 0, 2.0f, 2.0f );
// find the ground height of the terrain
float fHeight = dbGetTerrainGroundHeight ( 1, dbObjectPositionX (1000 ), dbObjectPositionZ (1000 ) );
// reposition the camera so it is directly above the ground
//dbPositionCamera ( dbCameraPositionX ( ), fHeight + 10.0f, dbCameraPositionZ ( ) );
//Check if 'Up' is pressed w=(17)
if (dbUpKey())
dbRotateObject(1000,dbObjectAngleX(1000)+1,dbObjectAngleY(1000),dbObjectAngleZ(1000));
//Check if 'Down' is pressed s=(31)
if (dbDownKey())
dbRotateObject(1000,dbObjectAngleX(1000)-1,dbObjectAngleY(1000),dbObjectAngleZ(1000));
//Check if 'Left' is pressed a=(30)
if (dbLeftKey())
dbRotateObject(1000,dbObjectAngleX(1000),dbObjectAngleY(1000)-1,dbObjectAngleZ(1000));
//Check if 'Right' is pressed d=(32)
if (dbRightKey())
dbRotateObject(1000,dbObjectAngleX(1000),dbObjectAngleY(1000)+1,dbObjectAngleZ(1000));
//Check if the Space key is pressed
if (dbKeyState(49))
{
float x = dbObjectAngleX(1000);
float y = dbObjectAngleY(1000);
dbRotateObject(1000,0,0,dbObjectAngleZ(1000));
dbMoveObjectDown(1000,2);
dbRotateObject(1000,x,y,dbObjectAngleZ(1000));
}
if (dbSpaceKey())
{
dbMoveObjectUp(1000,10);
if (dbKeyState(54)||dbKeyState(42))
{
dbMoveObjectUp(1000,50);
};
}
//fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) );
//fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) );
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
float x= dbObjectPositionX(1000);
float y= dbObjectPositionY(1000);
float z= dbObjectPositionZ(1000);
dbPositionCamera(x,y,z);
dbRotateCamera(dbObjectAngleX(1000)+290,dbObjectAngleY(1000),dbObjectAngleZ(1000));
if (dbObjectPositionY(1000)<fHeight+5)
{
dbPositionObject(1000,dbObjectPositionX(1000),fHeight+5,dbObjectPositionZ(1000));
};
// update the terrain
dbUpdateTerrain ( );
// update the screen
dbSync ( );
}
}