Hi everyone. We have a project which is given by our lecturer and we don't move on this project. Firstly our game : www.miniclip.com/games/fat-slice/tr/
Our primary programming language is C. We codified ball function but there is a some mistakes. We don't fix it and carry out the idea to cutting function. We use alleg.lib and work on Visual C++ 2010
Express.We don't have an idea about ball's moving after cutting the image. Balls move as - no vertical no horizontal - cross. They move on different places
and different way. They pass through each other and they are flicker.Double buffering doesn't work that there is two ball on the screen. Can you help us?
#include <allegro.h>
void Baslat();
void Bitir();
void moveBall()
int main() {
Baslat();
while (!key[KEY_ESC]) {
int width = 220;int height = 440;int radius = 5;
int x = 110;int y = 220;
int tempX;
int tempY;
int dir;
moveBall();
}
Bitir();
return 0;
}
END_OF_MAIN()
void Baslat() {
int depth, res;
allegro_init();
depth = desktop_color_depth();
if (depth == 0) depth = 32;
set_color_depth(depth);
res = set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
if (res != 0) {
allegro_message(allegro_error);
exit(-1);
}
install_timer();
install_keyboard();
install_mouse();
}
void Bitir() {
clear_keybuf();
}
void moveBall(){
tempX = x;
tempY = y;
switch(dir){
case 0:
if((x <= radius) || (y <= radius)){
dir = rand() % 4;
}else{
--x;
--y;
} break;
case 1:
if(((x <= radius) || (y >= (height - radius)))){
dir = rand() % 4;
}else{
--x;
++y;
} break;
case 2:
if(((x >= (width - radius)) || (y <= radius))){
dir = rand() % 4;
}else{
++x;
--y;
} break;
case 3:
if((((x >= (width - radius)) ||
(y >= (height - radius))))){
dir = rand() % 4;
}else{
++x;
++y;
}
}
This is not working exactly. We have some problems that cutting shape and bouncing ball. We make bouncing ball but the ball is flicker. Double buffering is not work on it. Our another problem is that two balls ,which are in the shape, through pass each other. How can we fix that?
So our another problem - i think it is a big problem - that we don't cut the shape. What can we do to make it?
We don't have an idea about slicing the shape. Can you help us? And you send the function better than that
We hurry up because we should finish this project in 6 days.
Note : We are using Allegro v4.2.3.
Is there someone who help us with a simple codes?
[edit]Code block added - OriginalGriff[/edit]