Already solved one thing, now I can move character, but still I've got error when finishing game ( pressing ESC )
Code:
#include "DarkGDK.h"
#include "DarkPhysics.h"
//#include "Console.h"
#pragma comment ( lib, "DarkPhysics.lib" )
float camera_fx = 0,
camera_fy = 0,
camera_speed = 0.5,
camera_rotate_speed = 2;
float fCameraAngleX=0,
fCameraAngleY =0;
void simple_camera_move();
void other_camera_move();
int box_buf = 0,
startin = 21;
void add_boxes ( int iValuen )
{
for( int i = 0 ; i < iValuen ; i++ )
{
dbLoadObject ( "models//crate.x" , startin+box_buf ) ;
dbPositionObject( startin+box_buf, -2, 5+i*3, 0 );
dbPhyMakeRigidBodyDynamicBox ( startin+box_buf );
box_buf ++;
}
}
void control_player();
void DarkGDK ( void )
{
// Settings
OpenConsole();
dbSetDisplayMode ( 800 , 600 , 32 ) ;
dbSetWindowPosition ( 0 , 0 ) ;
dbSetWindowTitle ( "3D game by Neomex" ) ;
dbSyncOn ( ) ;
dbSyncRate ( 60 ) ;
dbRandomize ( dbTimer ( ) ) ;
dbSetImageColorKey ( 255 , 0 , 255 ) ;
dbPhyStart ( 1 , 0 , 1 ) ;
// ---
//dbPhyMakeMaterial ( 2, "testMaterial" );
//dbPhyMakeRigidBodyStaticBox ( 1 , 2 );
dbColorBackdrop( 0 );
dbMakeLight( 1 );
//dbColorLight( 1 , dbRGB( 255 , 0 , 0 ) );
dbSetDirectionalLight( 1, -1, -1, -1 );
dbSetDirectionalLight( 10, -1, -1, -1 );
dbSetDirectionalLight( 12, -1, -1, -1 );
dbLoadImage ( "models//grass.jpg" , 1 );
add_boxes ( 10 );
//scene
dbMakeObjectBox( 1, 400, 1, 400 );
dbPositionObject( 1, 0, 0, 0 );
dbTextureObject( 1, 1 );
dbPhyMakeRigidBodyStaticBox ( 1 );
dbScaleObjectTexture ( 1, 15, 15 );
//sky sphere
dbLoadObject ( "models//sky.x" , 20 ) ;
dbPositionObject( 20, 0, 350, 0 );
dbXRotateObject ( 20, 90 ) ;
dbScaleObject ( 20 , 2000 , 2000 , 2000 );
dbSetObjectSmoothing ( 20, 100 );
dbSetObjectLight ( 20, 0 ) ;
//dbTextureObject( 1, 1 );
//dbPhyMakeRigidBodyDynamicBox ( 10 );
//crate
dbLoadObject ( "models//crate.x" , 10 ) ;
dbPositionObject( 10, 0, 5, 0 );
//dbTextureObject( 1, 1 );
dbPhyMakeRigidBodyDynamicBox ( 10 );
// second
dbLoadObject ( "models//crate.x" , 11 ) ;
dbPositionObject( 11, 1, 10, 0 );
dbPhyMakeRigidBodyDynamicBox ( 11 );
//tree
dbLoadObject ( "models//dr2.x" , 12 ) ;
dbScaleObject ( 12 , 50 , 50 , 50 );
dbPositionObject( 12, 50, 0, -20 );
dbSetAlphaMappingOn( 12, 100 );
dbPhyMakeRigidBodyStaticBox ( 12 );
dbSetObjectLight ( 12, 0 ) ;
//grass
dbLoadObject ( "models//grss.x" , 13 ) ;
dbScaleObject ( 13 , 10 , 10 , 10 );
dbPositionObject( 13, 0, 0, 0 );
dbSetAlphaMappingOn( 13, 50 );
dbSetObjectLight ( 12, 0 ) ;
//dbMakeCamera ( 1000 ) ;
//dbSetCameraView (
dbPositionCamera ( 0, 10, -50 );
dbXRotateCamera ( camera_fx ) ;
dbYRotateCamera ( camera_fy ) ;
//player
dbMakeObjectBox ( 1000, 5, 5, 5 ) ;
//dbPositionObject ( 1000 , 10 , 5 , 0 );
//dbPhyMakeRigidBodyDynamicBox ( 1000 );
dbPhyMakeBoxCharacterController (1000, 10, 5, 0, 2.5, 2.5, 2.5, 1, 1.5, 45.0 );
//debug
//dbPhyEnableDebug ( );
//foggy
//dbFogColor ( 0, 0, 0 ) ;
//dbFogDistance ( 200 ) ;
//dbFogOn ( ) ;
//more objects
float azs=0;
while ( LoopGDK ( ) )
{
dbText ( 10, 10, "FPS: " ) ;
//movesky :-)
dbYRotateObject ( 20, azs ) ;
azs+=0.1;
control_player();
//simple_camera_move();
other_camera_move();
dbPhyUpdate();
dbSync ( );
}
// Clear and Exit
dbPhyEnd();
for ( int i = 1; i < 200; i++ )
dbDeleteObject ( i );
return;
}
void simple_camera_move()
{
//dbPositionMouse ( 10, 10 );
if( dbShiftKey() == 1 )
{
dbMoveCamera( camera_speed );
}
if( dbControlKey() == 1 )
{
dbMoveCamera( -camera_speed );
}
if( dbUpKey() == 1 )
{
camera_fx-=camera_rotate_speed;
dbXRotateCamera ( camera_fx ) ;
}
if( dbDownKey() == 1 )
{
camera_fx+=camera_rotate_speed;
dbXRotateCamera ( camera_fx ) ;
}
if( dbLeftKey() == 1 )
{
camera_fy-=camera_rotate_speed;
dbYRotateCamera ( camera_fy ) ;
}
if( dbRightKey() == 1 )
{
camera_fy+=camera_rotate_speed;
dbYRotateCamera ( camera_fy ) ;
}
if( dbMouseClick() == 1 )
{
//add_boxes ( 1 );
}
}
void other_camera_move()
{
dbControlCameraUsingArrowKeys ( 0, 5.0f, 0.3f );
fCameraAngleX = dbWrapValue ( fCameraAngleX + dbMouseMoveY ( ) * 0.4f );
fCameraAngleY = dbWrapValue ( fCameraAngleY + dbMouseMoveX ( ) * 0.4f );
// rotate camera
dbXRotateCamera ( fCameraAngleX );
dbYRotateCamera ( fCameraAngleY );
}
void control_player()
{
if( dbLeftKey() == 1 )
{
dbTurnObjectLeft ( 1000 , 1.0 );
}
if( dbRightKey() == 1 )
{
dbTurnObjectRight ( 1000 , 1.0 );
}
if( dbSpaceKey() == 1 )
{
dbPhyMoveCharacterController ( 1000, 10 );
}else
{
dbPhyMoveCharacterController ( 1000, 0 );
}
}
Dissasembly:
00088634 test ah,44h
00088637 jnp 0008864A
00088639 mov eax,1
0008863E mov byte ptr [esi+168h],al
00088644 mov eax,esi
00088646 pop esi
00088647 ret 8
0008864A xor eax,eax
0008864C mov byte ptr [esi+168h],al
00088652 mov eax,esi
00088654 pop esi
00088655 ret 8
00088658 begin_of_the_skype_highlighting 8 00088658 end_of_the_skype_highlighting int 3
00088659 int 3
0008865A int 3
0008865B int 3
0008865C int 3
0008865D int 3
0008865E int 3
0008865F int 3
00088660 push esi
00088661 mov esi,ecx
00088663 mov ecx,dword ptr [esi+160h]
00088669 test ecx,ecx
0008866B mov dword ptr [esi],944B4h
00088671 je 00088685
00088673 mov eax,dword ptr [esi+108h]
00088679 test eax,eax
0008867B je 00088685
0008867D mov edx,dword ptr [ecx]
0008867F push eax
00088680 mov eax,dword ptr [edx+20h] // it's pointing this part
00088683 call eax
00088685 lea ecx,[esi+28h]
00088688 pop esi
00088689 jmp 00084210
0008868E int 3
0008868F int 3
00088690 mov eax,ecx
00088692 mov ecx,dword ptr [esp+4]
00088696 mov edx,dword ptr [ecx]
00088698 mov dword ptr [eax+140h],edx
0008869E mov edx,dword ptr [ecx+4]
000886A1 mov dword ptr [eax+144h],edx
000886A7 mov edx,dword ptr [ecx+8]
000886AA mov dword ptr [eax+148h],edx
000886B0 mov edx,dword ptr [ecx+0Ch]
000886B3 mov dword ptr [eax+14Ch],edx
000886B9 mov edx,dword ptr [ecx+10h]
000886BC mov dword ptr [eax+150h],edx
000886C2 mov edx,dword ptr [ecx+14h]
000886C5 mov dword ptr [eax+154h],edx
000886CB mov edx,dword ptr [ecx]
000886CD mov dword ptr [eax+128h],edx
000886D3 mov edx,dword ptr [ecx+4]
000886D6 mov dword ptr [eax+12Ch],edx
000886DC mov edx,dword ptr [ecx+8]
000886DF mov dword ptr [eax+130h],edx
000886E5 mov edx,dword ptr [ecx+0Ch]
000886E8 mov dword ptr [eax+134h],edx
000886EE mov edx,dword ptr [ecx+10h]
000886F1 mov dword ptr [eax+138h],edx
000886F7 mov edx,dword ptr [ecx+14h]
000886FA mov dword ptr [eax+13Ch],edx
00088700 mov edx,dword ptr [ecx]
00088702 mov dword ptr [eax+110h],edx
---
PS.
Oh, it isn't also moving other dynamic boxes, just stops near them, what looks like they're static.
Living for C++ programming!