Coucou à tous,
Actuellement, je fais un peu de programmation en 3D, enfin, je viens tout juste de commencer, et comme ça fait quelques temps que j'ai pas touché à VSC++, j'ai du oublier quelque chose.
Voici donc mon code source :
Citation#include "DarkGDK.h"
void DarkGDK ( void )
{
int rotation;
dbSyncOn ( );
dbSyncRate ( 60 );
dbRandomize ( dbTimer ( ) );
for ( int i = 1; i < 50; i++ )
{
dbMakeObjectSphere ( i, 1 );
dbPositionObject ( i, dbRnd ( 20 ), dbRnd ( 20 ), dbRnd ( 20 ) );
dbScaleObject ( i, 100 + dbRnd ( 400 ), 100 + dbRnd ( 400 ), 100 + dbRnd ( 400 ) );
dbColorObject ( i, dbRgb ( dbRnd ( 1 ) * 255, dbRnd ( 1 ) * 255, dbRnd ( 1 ) * 255 ) );
dbSetObjectSpecularPower ( i, 255 );
dbSetObjectAmbient ( i, 0 );
}
dbPositionCamera ( 10, 10, -20 );
while ( LoopGDK ( ) )
{
dbText ( 0, 0, "Utilisez Haut et Bas pour deplacer la camera..." );
if ( dbUpKey ( ) )
dbMoveCamera ( 1 );
if ( dbDownKey ( ) )
dbMoveCamera ( -1 );
if ( dbLeftKey () )
rotation-=1;
if ( dbRightKey () )
rotation+=1;
if rotation < 0
rotation += 360;
if rotation > 359
rotation -= 360;
dbYRotateCamera (rotation);
for ( int i = 1; i < 50; i++ )
dbRotateObject ( i, dbObjectAngleX ( i ) + 0.1, dbObjectAngleY ( i ) + 0.2, dbObjectAngleZ ( i ) + 0.3 );
dbSync ( );
}
for ( int i = 1; i < 50; i++ )
dbDeleteObject ( i );
return;
}
Et lorsque je compile ce bout de code, je reçois un joli message me disant ceci :
CitationCommand Lines
Creating temporary file "c:\Users\Larabi\Documents\Visual Studio 2008\Projects\Cube Adventure\Cube Adventure\Debug\RSP00003353683296.rsp" with contents
[
/FD /EHsc /MTd /Fo"Debug\\" /Fd"Debug\vc90.pdb" /c /ZI /TP ".\Main.cpp"
]
Creating command line "cl.exe @"c:\Users\Larabi\Documents\Visual Studio 2008\Projects\Cube Adventure\Cube Adventure\Debug\RSP00003353683296.rsp" /nologo /errorReport:prompt"
Output Window
Compiling...
Main.cpp
c:\users\larabi\documents\visual studio 2008\projects\cube adventure\cube adventure\main.cpp(30) : error C2061: syntax error : identifier 'rotation'
c:\users\larabi\documents\visual studio 2008\projects\cube adventure\cube adventure\main.cpp(32) : error C2061: syntax error : identifier 'rotation'
Results
Build log was saved at "file://c:\Users\Larabi\Documents\Visual Studio 2008\Projects\Cube Adventure\Cube Adventure\Debug\BuildLog.htm"
Cube Adventure - 2 error(s), 0 warning(s)
Help me please !
Edit : C'est bon, j'ai résolu le problème, j'avais oublié de mettre des parenthèses aux conditions. Un modo pourrait-il fermer ce topic s'il lui plaît :) ?
Essaye à la place de
Citationif ( dbLeftKey () )
rotation-=1;
if ( dbRightKey () )
rotation+=1;
mettre
Citationif ( dbLeftKey () )
rotation--;
if ( dbRightKey () )
rotation++;
EDIT: OK, je me suis gourré de ligne, je crois.
STOP! J'ai compris!
Mets toujours les condtions à vérifier entre parenthèses! Pas:
if rotation < 0
mais
if (rotation < 0)
Les deux cas marchent, mais là n'était pas le problème, il fallait mettre (r<0) au lieu de r < 0 .
Merci comme même.
Tu peux fermer le topic si tu veux maintenant :) .
OK, on avait compris au même moment :D.
A ta demande... [TOPIC CLOSED]