poldek Temat założony przez niniejszego użytkownika |
[Allegro, C++] Co umieścić we własnej bibliotece? » 2011-08-01 00:42:54 Na wstepie przeprosze nie mam polskisch znakow pzez winde angielska. Teraz do rzeczy ... Pisze sobie taka biblioteke do allegro tak dla cwiczen i zeby mi ulatwiala pisanie w allegro ,ale stanolem w miejscu nie mam pojecia co moglbym nowego do niej dodac, co dalej mam zrobic ? Mile widzane propozycje i uwagi. Teraz kod pallegro.cpp #include <allegro.h>
#include "pallegro.h" using namespace pallegro;
PBITMAP::~PBITMAP( void ) { x = y = 0; w = h = 0; Surface = NULL; }
PBITMAP::PBITMAP( const char * file, int xx, int yy ) { int spr = 0; x = xx; y = yy; Surface = load_bmp( file, default_palette ); if( !Surface ) spr = 1; if( spr == 1 ) { if( !Surface ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "error: graphic" ); allegro_exit(); } } }
void I_W( int x, int y, int dep, const char * str ) { allegro_init(); install_keyboard(); install_mouse(); set_color_depth( dep ); set_gfx_mode( GFX_AUTODETECT_WINDOWED, x, y, 0, 0 ); set_window_title( str ); clear_to_color( screen, makecol( 128, 128, 128 ) ); }
void I_F( int x, int y, int dep, const char * str ) { allegro_init(); install_keyboard(); install_mouse(); set_color_depth( dep ); set_gfx_mode( GFX_AUTODETECT, x, y, 0, 0 ); set_window_title( str ); clear_to_color( screen, makecol( 128, 128, 128 ) ); }
void Draw( BITMAP * Surface, BITMAP * Surface2, int x, int y ) { masked_blit( Surface, Surface2, 0, 0, x, y, Surface->w, Surface->h ); }
void BackDraw( BITMAP * Surface ) { blit( Surface, screen, 0, 0, 0, 0, Surface->w, Surface->h ); }
void Spr( BITMAP * Surface, BITMAP * Surface2 ) { int xx = 0; if( !Surface ) { xx++; } else if( !Surface2 ) { xx++; } if( xx == 1 ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "nie moge zaladowac ktoregos obrazka !(1)" ); allegro_exit(); } else if( xx == 2 ) { set_gfx_mode( GFX_TEXT, 0, 0, 0, 0 ); allegro_message( "nie moge zaladowac ktoregos obrazka !(1)(2)" ); allegro_exit(); } }
void DestroyBitmap( BITMAP * Surface, BITMAP * Surface2 ) { destroy_bitmap( Surface ); destroy_bitmap( Surface2 ); }
void DestroyBitmap( BITMAP * Surface, BITMAP * Surface2, BITMAP * Surface3 ) { destroy_bitmap( Surface ); destroy_bitmap( Surface2 ); destroy_bitmap( Surface3 ); }
void Pgame( void ) { if( key[ KEY_P ] ) { while( !key[ KEY_O ] ) { rest( 20 ); } } }
void CBitmap( BITMAP * Surface, int r, int g, int b ) { clear_to_color( Surface, makecol( r, g, b ) ); }
int Kolizja( int x1, int y1, int s1, int w1, int x2, int y2, int s2, int w2 ) { if( x2 <= x1 + s1 && x2 > x1 && y2 >= y1 && y2 <= y1 + w1 ) return 1; else if( x2 <= x1 + s1 && x2 > x1 && y2 + w2 >= y1 && y2 + w2 <= y1 + w1 ) return 2; else if( x2 + s2 <= x1 + s1 && x2 + s2 > x1 && y2 >= y1 && y2 <= y1 + w1 ) return 3; else if( x2 + s2 <= x1 + s1 && x2 + s2 > x1 && y2 + w2 >= y1 && y2 + w2 <= y1 + w1 ) return 4; else return 0; }; pallegro.h #ifndef PALLEGRO_H #define PALLEGRO_H
namespace pallegro { class PBITMAP { public: int x, y; int w, h; BITMAP * Surface; ~PBITMAP( void ); PBITMAP( const char * file, int xx = 0, int yy = 0 ); }; };
void I_W( int x, int y, int dep = 16, const char * str = "Czesio" ); void I_F( int x, int y, int dep = 16, const char * str = "Czesio" );
void Draw( BITMAP * Surface, BITMAP * Surface2, int x, int y ); void BackDraw( BITMAP * Surface );
void Spr( BITMAP * Surface ); void Spr( BITMAP * Surface, BITMAP * Surface2 );
void DestroyBitmap( BITMAP * Surface, BITMAP * Surface2 ); void DestroyBitmap( BITMAP * Surface, BITMAP * Surface2, BITMAP * Surface3 );
void Pgame( void );
void CBitmap( BITMAP * Surface, int r, int g, int b );
int Kolizja( int x1, int y1, int s1, int w1, int x2, int y2, int s2, int w2 ); #endif
Z gory dzieki Pozdrawiam, poldek |