some one can help me with my game?
the game i developed it in C, theres a problem because the ball is just sloping on the first time than it stay right, i attached the binary for you see it, the GGL.h is a small lib just with sprite system that i developed
#include <GGL.h>
#include <stdio.h>
#include <dos.h>
#include <sys/nearptr.h>
T_Sprite table;
T_Sprite ball;
T_Sprite column[10];
byte table_bmp [8*16] = {
8, 8, 8, 8, 8, 8, 8, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 7, 7, 7, 7, 7, 7, 8,
8, 8, 8, 8, 8, 8, 8, 8
};
byte ball_bmp [8*8] = {
0, 1, 1, 1, 1, 1, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
1, 1, 1, 1, 1, 1, 1, 1,
0, 1, 1, 1, 1, 1, 1, 0
};
byte column_bmp [8*16] = {
6, 6, 6, 6, 6, 6, 6, 6,
6, 8, 8, 8, 8, 8, 8, 8,
8, 8, 6, 6, 6, 6, 6, 6,
8, 6, 6, 6, 6, 6, 6, 6,
8, 8, 6, 6, 6, 6, 6, 6,
6, 8, 6, 6, 6, 6, 6, 6,
6, 8, 8, 8, 8, 8, 8, 6,
6, 6, 6, 6, 6, 6, 8, 8,
6, 6, 6, 6, 6, 6, 6, 8,
8, 8, 8, 8, 8, 8, 8, 8,
8, 6, 6, 6, 6, 6, 6, 6,
8, 8, 8, 6, 6, 6, 6, 6,
6, 6, 8, 6, 6, 6, 6, 6,
8, 8, 8, 6, 6, 6, 6, 6,
8, 6, 6, 6, 6, 6, 6, 6,
8, 6, 6, 6, 6, 6, 6, 6
};
int main ()
{
unsigned char ch;
int i;
int table_x, table_y, ball_x, ball_y, column_x, column_y;
int slope, slope_counter, hit, direction, score;
Init_GGL();
set_video_mode(VGA_MODE_256_COLOR);
set_sprite(8, 16, 1, table_bmp, &table);
set_sprite(8, 8, 1, ball_bmp, &ball);
for(i = 0; i < 11; i++) set_sprite(8, 16, 1, column_bmp, &column[i]);
ball_x = SCREEN_WIDTH/2;
ball_y = SCREEN_HEIGHT/2;
table_x = ball_x+8;
table_y = ball_y-4;
column_x = 20;
column_y = 0;
put_sprite(table_x, table_y, 0, &table);
put_sprite(ball_x, ball_y, 0, &ball);
for(i = 0; i < 11; i++) {
column_y +=16;
put_sprite(column_x, column_y, 0, &column[i]);
}
hit = 0;
slope = 20;
while(1) {
if(kbhit()) {
ch = getch();
if(ch == 'w')
move_sprite(table_x, table_y-=3, &table);
else if(ch == 's')
move_sprite(table_x, table_y+=3, &table);
else if(ch == 'p')
break;
}
for(i = 0; i < 11; i++)
if(colision_detect(&ball, &column[i]))
hit = 1;
if(colision_detect(&ball, &table)) {
hit = 0;
score++;
slope = (table_y+8) - (ball_y+4);
if(slope >= 0)
direction = 1;
else
direction = 0;
slope = abs(slope);
slope -= 100;
}
if(ball_x > SCREEN_WIDTH || ball_x < 0 || ball_y > SCREEN_HEIGHT || ball_y < 0)
break;
if(hit == 0)
move_sprite(--ball_x, ball_y, &ball);
else
move_sprite(++ball_x, ball_y, &ball);
if(slope_counter == slope) {
if(direction)
ball_y++;
else
ball_y--;
slope_counter = 0;
}
else
slope_counter++;
gdelay(50);
}
set_video_mode(TEXT_MODE);
printf("Score: %d", score);
printf("Programa teste da Lib Grafica GGL.\n");
End_GGL();
}