Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / problem with program

Author
Message
angusrind
12
Years of Service
User Offline
Joined: 1st Apr 2010
Location:
Posted: 1st Apr 2010 21:49
sorry for my bad english, (its not my native language)

i have a big proglem with a game that i have programmed
It has worked without any proglems til i have included a weapen (bullets) for my plane.
Now i cant move to left and right till i've done a first shot and when the bullet is destroyed, the plane appears at his startpoint and i can´t move to left or right anymore
here is the code of the programm







#include "DarkGDK.h"




void DarkGDK ( void )
{ int y=280, x=350, a=0, b=0, z;

dbSyncOn ( );
dbSyncRate ( 60 );

dbDisableEscapeKey ();

dbRandomize ( dbTimer ( ) );

dbSetImageColorKey ( 255, 0, 255 );



dbLoadImage ("backdrop.bmp", 1);
dbSprite ( 1, 0, 0, 1);

dbLoadImage ("stern.bmp", 31);




for ( int i = 2; i < 22; i++ )
{
dbCreateAnimatedSprite ( i, "sprite1.bmp", 4, 4, i );



dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}



for ( int i = 2; i < 22; i++ )
{

dbMoveSprite ( i, -2 );
dbPlaySprite ( i, 1, 16, 60 );


if ( dbSpriteY ( i ) > 500 )
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}


for ( int i = 2; i < 22; i++ )
{
dbCreateAnimatedSprite ( i, "sprite1.bmp", 4, 4, i );


dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}

while ( LoopGDK ( ) )
{

for ( int i = 2; i < 22; i++ )
{

dbMoveSprite ( i, -2);
dbPlaySprite ( i, 1, 16, 60 );
if(dbSpriteHit(i, 31)==1)
{
for ( int i = 2; i < 22; i++ )
{
dbDeleteSprite ( i );
dbDeleteImage (31);
dbDeleteSprite (31);
dbLoadImage ("sprite.bmp", 32);
dbSprite(32,100,150,32);
}
}

if ( dbSpriteY ( i ) > 500 )
dbSprite ( i, dbRnd ( 640 ), -dbRnd ( 1500 ), i );
}


if(x<380){if(dbDownKey())x=x+5;}
if(x>0){if(dbUpKey())x=x-3;}
if(y>0){if(dbLeftKey())y=y-4;}
if(y<550){if(dbRightKey())y=y+4;}

dbSprite ( 31, y, x, 31);



if(dbSpaceKey())
{
z=25;
dbLoadImage ("geschoss.bmp", 25);
a=y+15;
b=x;
dbSprite(25,a,b,25);
}


dbMoveSprite(25, +5);








for ( int i = 2; i < 22; i++ )
{

if(dbSpriteHit(i,25))
{
dbDeleteSprite (i);
dbDeleteSprite (25);
}
}

if(b<=0)
{
dbDeleteSprite (25);
}












if ( dbEscapeKey ( ) )
break;

dbSync ( );
}


for ( int i = 1; i < 10; i++ )
dbDeleteSprite ( i );

return;
}


i would be very thankfull for any kind of help
(i´ve attached the complete programm data)

Attachments

Login to view attachments
xbandages
12
Years of Service
User Offline
Joined: 30th Mar 2010
Location: Michigan
Posted: 3rd Apr 2010 07:21
why do you have your up key corresponding with x and your right key corresponding with y?

Your limited movement is probably due to the fact of confusing code

Heres what you need to do...add this for your movements instead and use this also for incrementing/decrementing the players position:



I don't have the time to look through the rest of your code, but i just commented out the rest and figured out your movements. Also, if you were aiming to have boundaries on the outskirts of the level....they were off for the max y value and max x values.
angusrind
12
Years of Service
User Offline
Joined: 1st Apr 2010
Location:
Posted: 3rd Apr 2010 13:04
thank you for spending time with my programm, but the problemm is already there.
Now I cannot move up and down bevor shooting and after the first collision with an asteroit.
angusrind
12
Years of Service
User Offline
Joined: 1st Apr 2010
Location:
Posted: 11th Jun 2010 22:47
ah, i have done it.
The problem is not longer there

Login to post a reply

Server time is: 2023-01-27 00:39:49
Your offset time is: 2023-01-27 00:39:49