1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
|
#include <allegro.h>
int makerect(int selectedcolor, int a, int b, int c, int d);
int main()
{
allegro_init();
install_mouse();
install_keyboard();
set_color_depth(32);
set_gfx_mode(GFX_AUTODETECT_WINDOWED, 900, 600, 0, 0);
clear_to_color( screen, makecol( 255, 255, 255));
show_mouse(screen);
int i;
int s;
int f = 16;
int l;
int cursor_x;
int cursor_y;
int selectedcolor;
int a, b, c, d;
while(! key [KEY_ESC]){
rest(5);
show_mouse(screen);
acquire_screen();
line( screen, 640, 600, 640, 0, makecol( 55, 55, 150));
release_screen();
while(f<=(16*40)){
for(s=16*3;s<=(16*37);s=s+16){
for(l=16*4;l<=(16*37);l=l+16){
acquire_screen();
rect(screen, 0, s, f, l, makecol( 0, 0, 255));
release_screen();
}
}
f=f+16;
}
acquire_screen();
rect( screen, 660, 64, (660+(64*3)), (64*4), makecol( 0, 0, 255));
rectfill(screen, (660), (64*5), (660+64), (64*6), makecol( 255, 0, 0)); // color 1
rectfill(screen, (660+64), (64*5), (660+64*2), (64*6), makecol( 0, 255, 0)); // color 2
rectfill(screen, (660+64*2), (64*5), (660+64*3), (64*6), makecol( 0, 0, 255)); // color 3
rectfill(screen, 660, (64*6), (660+64), (64*7), makecol( 255, 0, 255)); // color 4
rectfill(screen, (660+64), (64*6), (660+64*2), (64*7), makecol( 0, 255, 255)); // color 5
rectfill(screen, (660+64*2), (64*6), (660+64*3), (64*7), makecol( 255, 255, 0)); // color 6
rectfill(screen, 660, (64*7), (660+64), (64*8), makecol( 50, 255, 150)); // color 7
rectfill(screen, (660+64), (64*7), (660+64*2), (64*8), makecol( 0, 0, 0)); // color 8
rectfill(screen, (660+64*2), (64*7), (660+64*3), (64*8), makecol( 100, 50, 200)); // color 9
release_screen();
if(mouse_b & 1){
cursor_x = mouse_x;
cursor_y = mouse_y;
if(cursor_x >= 660 && cursor_x <= (660+64)){
if(cursor_y >= (64*5) && cursor_y <= (64*6)){
selectedcolor = 1;
acquire_screen();
rectfill(screen, 660, 64, (660+(64*3)), (64*4), makecol( 255, 0, 0));
release_screen();
}
}
if(cursor_x >= (660+64) && cursor_x <= (660+64*2)){
if(cursor_y >= (64*5) && cursor_y <= (64*6)){
selectedcolor = 2;
}
}
if(cursor_x >= (660+64*2) && cursor_x <= (660+64*3)){
if(cursor_y >= (64*5) && cursor_y <= (64*6)){
selectedcolor = 3;
}
}
if(cursor_x >= 660 && cursor_x <= (660+64)){
if(cursor_y >= (64*6) && cursor_y <= (64*7)){
selectedcolor = 4;
}
}
if(cursor_x >= (660+64) && cursor_x <= (660+64*2)){
if(cursor_y >= (64*6) && cursor_y <= (64*7)){
selectedcolor = 5;
}
}
if(cursor_x >= (660+64*2) && cursor_x <= (660+64*3)){
if(cursor_y >= (64*6) && cursor_y <= (64*7)){
selectedcolor = 6;
}
}
if(cursor_x >= 660 && cursor_x <= (660+64)){
if(cursor_y >= (64*7) && cursor_y <= (64*8)){
selectedcolor = 7;
}
}
if(cursor_x >= (660+64) && cursor_x <= (660+64*2)){
if(cursor_y >= (64*7) && cursor_y <= (64*8)){
selectedcolor = 8;
}
}
if(cursor_x >= (660+64*2) && cursor_x <= (660+64*3)){
if(cursor_y >= (64*7) && cursor_y <= (64*8)){
selectedcolor = 9;
}
}
if(cursor_x >= 0 && cursor_x <= 64 && selectedcolor != 0){
if(cursor_y >= 64 && cursor_y <= (64*2)){
a=0;
b=64;
c=64;
d=(64*2);
makerect(selectedcolor, a, b, c, d);
}
}
}
}
}
END_OF_MAIN ()
int makerect(int selectedcolor, int a, int b, int c, int d){
if(selectedcolor == 1){
acquire_screen();
rectfill(screen, a, b, c, d, makecol(255, 0, 0));
release_screen();
}
}
|