Bom estava sem nada para fazer e resolvi fazer um cursor line e um programa que gera linhas apartir do mouse vamos para o codigo // Feito por ce1o2e
#include <allegro.h>
void init();
void contador_fps();
void velocidade_fps();
int fps;
int fps_antigo;
int fps_speedy;
int main()
{
init();
BITMAP *buffer = NULL;
buffer = create_bitmap(800, 800);
int linhas = 20;
int aux = 0;
int x_inicio[linhas];
int y_inicio[linhas];
int x_final[linhas];
int y_final[linhas];
int R[linhas];
int B[linhas];
int G[linhas];
for(aux = 0; aux <= linhas; aux++)
{
x_inicio[aux] = 0;
y_inicio[aux] = 0;
x_final[aux] = 0;
y_final[aux] = 0;
R[aux] = 254;
B[aux] = 254;
G[aux] = 254;
}
int x = 10;
int y = 150;
int tamanho = 30;
int mouse_press = 1;
int contador = 0;
while(!key[KEY_ESC])
{
if(::fps_speedy > 0)
{
clear(buffer);
show_mouse(buffer);
if(mouse_b & 1 && mouse_press != 0)
{
contador++;
if(contador > linhas)
{
contador = 0;
}
x_inicio[contador] = mouse_x;
y_inicio[contador] = mouse_y;
x_final[contador] = mouse_x;
y_final[contador] = mouse_y;
mouse_press = 0;
}
if(mouse_b & 1 && mouse_press == 0)
{
x_final[contador] = mouse_x;
y_final[contador] = mouse_y;
}
else
{
mouse_press = 1;
}
if(key[KEY_R] && R[contador] < 255)
{
R[contador]++;
}
else if(R[contador] > 254)
{
R[contador] = 0;
}
if(key[KEY_G] && G[contador] < 255)
{
G[contador]++;
}
else if(G[contador] > 254)
{
G[contador] = 0;
}
if(key[KEY_B] && B[contador] < 255)
{
B[contador]++;
}
else if(B[contador] > 254)
{
B[contador] = 0;
}
for(int z = 0; z <= linhas; z++)
{
line(buffer, x_inicio[z], y_inicio[z], x_final[z], y_final[z], makecol(R[z], G[z], B[z]));
rectfill(buffer, x, y, x+tamanho, y+tamanho, makecol(R[x], G[x], B[x]));
}
rect(buffer, x, y, x+tamanho, y+tamanho, makecol(255, 255, 255));
textprintf_ex(buffer, font, 10, 10, makecol(255, 0, 0), -1, "FPS: %d", ::fps_antigo);
textprintf_ex(buffer, font, 10, 20, makecol(255, 0, 0), -1, "MOUSE_X: %d", mouse_x);
textprintf_ex(buffer, font, 10, 30, makecol(255, 0, 0), -1, "MOUSE_Y: %d", mouse_y);
textprintf_ex(buffer, font, 10, 50, makecol(255, 0, 0), -1, "X_INICIO[%d]: %d", contador, x_inicio[contador]);
textprintf_ex(buffer, font, 10, 60, makecol(255, 0, 0), -1, "Y_INICIO[%d]: %d", contador, y_inicio[contador]);
textprintf_ex(buffer, font, 10, 80, makecol(255, 0, 0), -1, "X_FINAL[%d]: %d", contador, x_final[contador]);
textprintf_ex(buffer, font, 10, 90, makecol(255, 0, 0), -1, "Y_FINAL[%d]: %d", contador, y_final[contador]);
textprintf_ex(buffer, font, 10, 110, makecol(255, 0, 0), -1, "R[%d]: %d", contador, R[contador]);
textprintf_ex(buffer, font, 10, 120, makecol(255, 0, 0), -1, "G[%d]: %d", contador ,G[contador]);
textprintf_ex(buffer, font, 10, 130, makecol(255, 0, 0), -1, "B[%d]: %d", contador, B[contador]);
::fps_speedy--;
::fps++;
}
show_mouse(buffer);
blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
}
remove_mouse();
destroy_bitmap(buffer);
allegro_exit();
return 0;
}
END_OF_MAIN();
void init()
{
allegro_init();
install_keyboard();
install_timer();
install_mouse();
set_color_depth(16);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0);
install_int(contador_fps, 1000);
install_int_ex(velocidade_fps, BPS_TO_TIMER(30));
}
void contador_fps()
{
::fps_antigo = ::fps;
::fps = 0;
}
void velocidade_fps()
{
::fps_speedy++;
} Imagem: bom o codigo esta configurado para desenhar 50 linhas se você quiser colocar + linhas somente mude o valor da int linhas no começo do codigo inicio_x e inicio_y indica o inicio da linha e o final_x e final_y o final claro ^^ Apos clicar com o direito a linha sera criada ate você soltar o clique direito para criar uma nova linha basta clicar denovo o direito uma nova linha sera criada. Você pode mudar as cores RGB com as teclas R, G, B lembrando sempre que criar sua linha com direito a cor começara com 255, 255, 255 cabe a você mudar Ferramentas Dev C++ C\C++ - Allegro 100% feito por ce1o2e