Hey,
Can anyone help me?? I don't know if I should use my other post or not cause this isn't exactly the same subject. What happens is I want to say that if 2 sprites collide then it resets there integers so that it goes to the beginning again.
Here's my code:
// Main Header Files
#include "DarkGDK.h"
// Define Player integers
int px = 350;
int py = 550;
int left = 0;
int right = 0;
int w1x = 50;
int w2x = 750;
// Define Enemy integers
int ex = 750;
int ey = 550;
// Defining all Sub areas of game
void game ( void );
void loadmedia ( void );
void inkey ( void );
void collision ( void );
void aiR ( void );
void aiL (void );
void DarkGDK ( void )
{
// Turning Sync On and Setting it to 0
dbSyncOn ( );
dbSyncRate ( 0 );
// Setting the display mode to 800 x 600
dbSetDisplayMode ( 800, 600, 32 );
// Telling it to load all of the media
loadmedia ();
// Telling The Computer to paste you to the screen
dbSprite ( 1, px, py, 1 );
// Telling Computer to paste enemy to the screen
dbSprite ( 2, ex, ey, 2 );
// Our Main Loop
while ( LoopGDK ( ) )
{
game();
dbSync ( );
}
// return back to windows
return;
}
void game ( void )
{
// Calling the Subdivisions of the game
inkey();
collision();
// Pasting Sprites
dbSprite ( 1, px, py, 1 );
dbSprite ( 2, ex, ey, 2 );
// Telling Screen To Re Sync
dbSync ();
}
void loadmedia ( void )
{
// Loading Media
dbLoadImage ( "you.png", 1 );
dbLoadImage ( "bad.png", 2 );
}
void inkey ( void )
{
if ( dbRightKey ())
{
px += 3;
right = 1;
left = 0;
aiR ();
}
if ( dbLeftKey ())
{
px -= 3;
left = 1;
right = 0;
aiL ();
}
}
void collision ( void )
{
if ( px < w1x )
{
if ( left = 1 )
{
px += 3;
}
}
if ( px > w2x )
{
if ( right = 1 )
{
px -= 3;
}
}
}
if ( dbSpriteCollision ( 1, 2 ) )
{
px = 350;
ex = 750;
}
void aiR ( void )
{
ex -= 4;
}
void aiL (void )
{
ex -= 4;
}
Here is my error:
------ Build started: Project: Dark GDK - Game1, Configuration: Debug Win32 ------
Compiling...
Main.cpp
c:\documents and settings\parent\my documents\visual studio 2008\projects\dark gdk - game1\dark gdk - game1\main.cpp(121) : error C2059: syntax error : 'if'
c:\documents and settings\parent\my documents\visual studio 2008\projects\dark gdk - game1\dark gdk - game1\main.cpp(122) : error C2143: syntax error : missing ';' before '{'
c:\documents and settings\parent\my documents\visual studio 2008\projects\dark gdk - game1\dark gdk - game1\main.cpp(122) : error C2447: '{' : missing function header (old-style formal list?)
Build log was saved at "file://c:\Documents and Settings\Parent\My Documents\Visual Studio 2008\Projects\Dark GDK - Game1\Dark GDK - Game1\Debug\BuildLog.htm"
Dark GDK - Game1 - 3 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========