Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Allegro 4.2.2 Syntax*/
- // https://phoxis.org/2009/02/13/allegro-422/
- // Dostêp: 2017-10-29
- #include <stdio.h>
- #include <allegro.h>
- #define RED makecol(255,0,0)
- #define GREEN makecol(0,255,0)
- #define BLUE makecol(0,0,255)
- #define BLACK makecol(0,0,0)
- #define WHITE makecol(255,255,255)
- #define RADIUS 10
- #define MOVE_DISTANCE 20
- int main(void)
- {
- allegro_init();
- install_keyboard();
- install_mouse();
- install_timer();
- allegro_message("This is the first allegro program (Press OK)");
- set_color_depth(8);
- if(set_gfx_mode(GFX_AUTODETECT_WINDOWED,800,600,0,0))
- {
- allegro_message(allegro_error);
- exit(0);
- }
- int width = SCREEN_W/2;
- int heigth = SCREEN_H/2;
- textprintf(screen,font,10,10,WHITE,"Screen Resolution %dx%d",SCREEN_W,SCREEN_H);
- rect(screen,20,20,300,130,GREEN);
- putpixel(screen,SCREEN_W/2,SCREEN_H/2,RED);
- line(screen,300,300,200,200,GREEN);
- triangle(screen,500,500,500,550,300,550,BLUE);
- show_mouse(screen);
- while(!key[KEY_ESC])
- {
- textprintf(screen,font,30,30,RED,"Mouse Pos x:y=%3d:%3d",mouse_x,mouse_y);
- textprintf(screen,font,30,50,BLUE,"Mouse Scroll Pos: %3d",mouse_z);
- textprintf(screen,font,30,70,GREEN,"Mouse Left Button Pressed:%3s",((mouse_b&1)?"Yes":"No"));
- textprintf(screen,font,30,90,GREEN,"Mouse Right Button Pressed:%3s",((mouse_b&2)?"Yes":"No"));
- textprintf(screen,font,30,110,GREEN,"Mouse Middle Button Pressed:%3s",((mouse_b&4)?"Yes":"No"));
- textprintf(screen,font,30,200,GREEN,"Raw Mouse :%d",mouse_b);
- circle(screen,width,heigth,RADIUS,WHITE);
- if (mouse_x > width) {
- width += RADIUS;
- } else if (mouse_x < width) {
- width -= RADIUS;
- if (mouse_y > heigth) {
- heigth += RADIUS:
- } else if (mouse_y < heigth) {
- heigth -= RADIUS;
- }
- if (width < 0) {
- width = RADIUS;
- } else if (width > SCREEN_W) {
- width = SCREEN_W - RADIUS;
- }
- if (heigth < 0) {
- heigth = RADIUS:
- } else if (heigth > SCREEN_H) {
- heigth = SCREEN_H - RADIUS;
- }
- rest(5);
- }
- allegro_exit();
- return 0;
- }
- END_OF_MAIN();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement