Can someone give me some code?? This is my first game and I really hardly know anything. I am making a space scrolling shooter. What I want it to do is if my ship collides with a wall then my ship stops. Can you maybe give some code???
Here's All My Code:
// Dark GDK - The Game Creators - www.thegamecreators.com
// the wizard has created a very simple project that uses Dark GDK
// it contains the basic code for a GDK application
// whenever using Dark GDK you must ensure you include the header file
#include "DarkGDK.h"
// the main entry point for the application is this function
void DarkGDK ( void )
{
dbSetWindowTitle ( "The Night Everything Went Black" );
// turn on sync rate and set maximum rate to 60 fps
dbSyncOn ( );
dbSyncRate ( 60 );
int ShipX, ShipY, Wall1X, Wall1Y, Wall2X, Wall2Y, EnemyX, EnemyY, ShipSpeed;
ShipX = 400;
ShipY = 500;
Wall1X = 0;
Wall1Y = 0;
Wall2X = 790;
Wall2Y = 0;
dbSetDisplayMode ( 800, 600, 32 ); // Setting Display Mode
dbLoadImage ( "ship.png", 1 ); // Loading Media
dbLoadImage ( "wall1.png", 2 );
dbLoadImage ( "wall2.png", 3 );
dbLoadImage ( "backround.jpg", 4 );
dbLoadImage ( "bullet.png", 5 );
dbBackdropTexture ( 4 );
dbSprite ( 1, ShipX, ShipY, 1 ); // Pasting Ship onto screen
dbSprite ( 2, Wall1X, Wall1Y, 2 );
dbSprite ( 3, Wall2X, Wall2Y, 3 );
// our main loop
while ( LoopGDK ( ) )
{
dbSpriteCollision ( 1, 2 );
// Controls
//___________________________________________________________________________
if ( dbRightKey ())
ShipX += 5;
if ( dbLeftKey ())
ShipX -= 5;
//___________________________________________________________________________
dbSprite ( 1, ShipX, ShipY, 1 );
dbSync ( );
}
// return back to windows
return;
}