Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
My second program
#4
(12-22-2010, 10:25 PM)algorithm Wrote: Yeah I will, what is it like some kind of gaming app?

It's a 2d Graphics library. Here's an example i've just started.
Code:
#include <allegro.h>


BITMAP * ship;
BITMAP * background;
BITMAP * buffer;
SAMPLE * music;

int x = 300;
int y = 400;



int main(){
    allegro_init();
    install_keyboard();
    install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, "A");
    music = load_sample("music.wav");
    play_sample(music,255,128,1000,-1);
    
    set_color_depth(16);
    set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0);

    ship = load_bitmap("ship.bmp", NULL);
    background = load_bitmap("background.bmp", NULL);  
    
    buffer = create_bitmap(640, 480);

    while(!key[KEY_ESC])
    {
    
     clear_keybuf();
     acquire_screen();
    
     draw_sprite( buffer, background, 0, 0);
     draw_sprite( buffer, ship, x, y);              
     blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
     textout_ex(screen, font, "Game by Scorch", 50, 10, makecol(0, 0, 255), makecol(0, 0, 0));
     textout_ex(screen, font, "Stratovarius - Fight", 50, 30, makecol(255, 0, 0), makecol(0, 0, 0));
     if(key[KEY_LEFT])
     {
       x--;
     }
     if(key[KEY_RIGHT])
     {
       x++;
     }
     if(key[KEY_UP])
     {
       y--;
     }
     if(key[KEY_DOWN])
     {
       y++;
     }
     else if(key[KEY_Z])
     {
     clear(screen);
     draw_sprite( buffer, background, 0, 0);
     draw_sprite( buffer, ship, x, y);              
     blit(buffer, screen, 0, 0, 0, 0, SCREEN_W, SCREEN_H);
     }    
     release_screen();
     readkey();
     rest(2);
    
    }
  clear(screen);
  destroy_bitmap(ship);
  destroy_bitmap(background);
  destroy_bitmap(buffer);
   destroy_sample(music);
  return 0;
    
}  
END_OF_MAIN();
Reply


Messages In This Thread
My second program - by Digital-Punk - 12-22-2010, 01:46 PM
RE: My second program - by Scorch - 12-22-2010, 10:21 PM
RE: My second program - by Digital-Punk - 12-22-2010, 10:25 PM
RE: My second program - by Scorch - 12-23-2010, 01:33 AM
RE: My second program - by w00pz - 02-11-2011, 03:42 PM
RE: My second program - by aggouras - 03-09-2011, 09:55 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)