here is my code, it is for a block breaker type game. (using sprites)
whats wrong with it? cos the top left block with work but the other 2 don't anyone smart enugh to figure this out?
#include "DarkGDK.h"
#include <darkgdk.h>
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <time.h>
#include <ctype.h>
#include <dos.h>
#include <windows.h>
int ball_x;
int ball_y;
int paddle_x;
int paddle_y;
int ball_left_speed = 0;
int ball_right_speed = 0;
int ball_up_speed = 0;
int ball_down_speed = 1;
void DarkGDK ( void )
{
dbSyncOn ( );
dbSyncRate ( 60 );
dbLoadImage("bat.bmp",1);
dbLoadImage("ball.bmp",2);
dbLoadImage("blockg.bmp",3);
dbLoadImage("blockg2.bmp",4);
dbLoadImage("blocko.bmp",5);
dbLoadImage("blockp.bmp",6);
dbLoadImage("blockr.bmp",7);
dbLoadImage("backround1.bmp",8);
dbSprite(2,300,250,2);
dbSprite(10,10,10,3);
dbSprite(12,120,10,6);
dbSprite(13,220,10,7);
dbSprite(14,320,10,5);
dbSprite(15,420,10,3);
dbSprite(16,520,10,3);
dbSprite(17,10,35,3);
dbSprite(18,120,35,3);
dbSprite(19,220,35,3);
dbSprite(20,320,35,4);
dbSprite(21,420,35,5);
dbSprite(22,520,35,3);
dbSprite(23,10,60,3);
dbSprite(24,120,60,3);
dbSprite(25,220,60,4);
dbSprite(26,320,60,4);
dbSprite(27,420,60,5);
dbSprite(28,520,60,5);
dbSprite(29,10,85,3);
dbSprite(30,120,85,4);
dbSprite(31,220,85,4);
dbSprite(32,320,85,4);
dbSprite(33,420,85,5);
dbSprite(34,520,85,6);
dbSync ( );
dbWaitMouse();
bool ballactive = false;
bool brick1 = false;
bool brick2 = false;
bool brick3 = false;
bool brick4 = false;
bool brick5 = false;
bool brick6 = false;
bool brick7 = false;
bool brick8 = false;
bool brick9 = false;
bool brick10 = false;
bool brick11 = false;
bool brick12 = false;
bool brick13 = false;
bool brick14 = false;
bool brick15 = false;
bool brick16 = false;
bool brick17 = false;
bool brick18 = false;
dbSync ( );
ball_x += 300;
ball_y += 150;
while ( LoopGDK ( ) )
{
dbRandomize ( dbTimer( ) );
dbRandomize ( dbTimer( ) );
dbHideMouse();
if(dbUpKey()==1)
{
ball_y -= 1;
}
if(dbLeftKey()==1)
{
ball_x -= 1;
}
if(dbSpriteCollision(2,29))
{
if(brick1 == false)
{
dbMoveSprite(29,1000);
ball_down_speed = ball_up_speed;
ball_up_speed = 0;
brick1 = true;
}
if(brick1 == true)
{
ball_up_speed = ball_up_speed;
}
}
if(dbSpriteCollision(2,30))
{
if(brick2 == false)
{
dbMoveSprite(30,1000);
ball_down_speed = ball_up_speed;
ball_up_speed = 0;
brick2 = true;
}
if(brick2 == true)
{
ball_up_speed = ball_up_speed;
}
}
if(dbSpriteCollision(2,31))
{
if(brick3 == false)
{
dbMoveSprite(31,1000);
ball_down_speed = ball_up_speed;
ball_up_speed = 0;
brick3 = true;
}
if(brick3 == true)
{
ball_up_speed = ball_up_speed;
}
}
if(ballactive == true)
{
ball_x -= ball_left_speed;
ball_x += ball_right_speed;
ball_y += ball_down_speed;
ball_y -= ball_up_speed;
}
if(dbSpriteCollision(1,2))
{
if(ball_x <= dbMouseX())
{
ball_up_speed += 1;
ball_left_speed +=1;
ball_right_speed = 0;
if(ball_down_speed >= ball_up_speed)
{
ball_up_speed = ball_down_speed;
ball_up_speed += 1;
}
}
if(ball_x >= dbMouseX())
{
ball_up_speed += 1;
ball_left_speed =0;
ball_right_speed +=1;
if(ball_down_speed >= ball_up_speed)
{
ball_up_speed = ball_down_speed;
ball_up_speed += 1;
}
}
if(ball_x == dbMouseX())
{
ball_up_speed += 1;
if(ball_down_speed >= ball_up_speed)
{
ball_up_speed = ball_down_speed;
ball_up_speed += 1;
}
}
}
if(dbSpriteY(2) <= 1)
{
ball_down_speed += 1;
if(ball_up_speed >= ball_down_speed)
{
ball_down_speed += 1;
}
}
if(dbSpriteX(2) <= 1)
{
ball_right_speed += 1;
ball_left_speed = 0;
}
if(dbSpriteX(2) >= 610)
{
ball_left_speed += 1;
ball_right_speed = 0;
}
if(ball_down_speed >= ball_up_speed)
{
ball_left_speed += 0.1;
ball_left_speed += 0.1;
if(ball_right_speed >= ball_left_speed)
{
ball_left_speed += 0.1;
}
}
if(dbSpaceKey()==1)
{
ballactive = true;
}
dbSprite(2,ball_x,ball_y,2);
dbSprite(1,dbMouseX(),450,1);
dbSprite(8,5,5,8);
dbSizeSprite(8,650,400);
dbSync ( );
}
return;
}
c++ = easy GDK = IMPOSSIBLE lol