Example #1
0
UIPanel* CreatePanel(char* img, char *panelfont , char* text,int x, int y, int width, int height){
    UIPanel* aux;





    aux = (UIPanel*)malloc(sizeof(UIPanel));

     aux->panelfontaux = al_load_ttf_font(panelfont,16,0);

    aux->spr = al_load_bitmap(img);
    al_convert_mask_to_alpha(aux->spr, al_map_rgb(255,0,255));

    strcpy(aux->pantext, text);
    aux->x = x;
    aux->y = y;
    aux->width = width;
    aux->height = height;

    aux->border_upperleft = al_create_sub_bitmap(aux->spr, 0,0,32,32);
    aux->border_upperright = al_create_sub_bitmap(aux->spr, 32,0,32,32);

    aux->border_lowerright = al_create_sub_bitmap(aux->spr, 0,32,32,32);
    aux->border_lowerleft = al_create_sub_bitmap(aux->spr, 32,32,32,32);

    return aux;
}
int atualizaCachorro(){
    int flags = 0;
    if(direcao_atual == 0){
        flags = 0;
        pos_y_cachorro = pos_y_cachorro - 8;
        sprite = al_create_sub_bitmap(cachorro_cima, frame_cachorro * SPRITE_SIZE, 0, SPRITE_SIZE, SPRITE_SIZE);
        al_draw_bitmap(sprite, pos_x_cachorro + margem_x, pos_y_cachorro + margem_y, flags);

    }
    else if(direcao_atual == 1){
        flags = ALLEGRO_FLIP_HORIZONTAL;
        pos_x_cachorro = pos_x_cachorro + 8;
        sprite = al_create_sub_bitmap(cachorro_lado, frame_cachorro * SPRITE_SIZE, 0, SPRITE_SIZE, SPRITE_SIZE);
        al_draw_bitmap(sprite, pos_x_cachorro + margem_x, pos_y_cachorro + margem_y, flags);

    }
    else if(direcao_atual == 2){
        flags = 0;
        pos_y_cachorro = pos_y_cachorro + 8;
        sprite = al_create_sub_bitmap(cachorro_baixo, frame_cachorro * SPRITE_SIZE, 0, SPRITE_SIZE, SPRITE_SIZE);
        al_draw_bitmap(sprite, pos_x_cachorro + margem_x, pos_y_cachorro + margem_y, flags);

    }
    else if(direcao_atual == 3){
        flags = 0;
        pos_x_cachorro = pos_x_cachorro - 8;
        sprite = al_create_sub_bitmap(cachorro_lado, frame_cachorro * SPRITE_SIZE, 0, SPRITE_SIZE, SPRITE_SIZE);
        al_draw_bitmap(sprite, pos_x_cachorro + margem_x, pos_y_cachorro + margem_y, flags);

    }
}
Example #3
0
void Entity::updateAnimation(){
    if(this->animationValue != this->animationValueHelper){
        this->animationCountHelper = this->animationCount;
        this->animationValueHelper = this->animationValue;
    }

    if(this->animationValue <= 0){
        this->frameX = 0;
        this->frameY = 0;
        this->animationCountHelper = animationCount;
        this->frameImage = al_create_sub_bitmap(this->sheetImage, this->frameX, this->frameY, this->frameWidth, this->frameHeight);
        return;
    }

    if(this->animationCountHelper >= this->animationCount){
        this->frameY = (this->animationValue-1)*this->frameHeight;
        if(this->frameX+1 < (this->sheetColums-1)*this->frameWidth)
            this->frameX = this->frameX+this->frameWidth;
        else
            this->frameX = 0;

        this->frameImage = al_create_sub_bitmap(this->sheetImage, this->frameX, this->frameY, this->frameWidth, this->frameHeight);
        this->animationCountHelper = 0;
    }

    this->animationCountHelper++;
}
Example #4
0
Enemy::Enemy(int x, int y, int type, ALLEGRO_BITMAP* enemies, ALLEGRO_BITMAP* shots, Bunny* bunny)
{
    posx_ = x;
    posy_ = y;
    posz_ = 30;
    fstream enemyFile;
    enemyFile.open("files/enemies.txt", ios::in);
    for (int i = 0; i < type; i++)
    {
        string s;
        getline(enemyFile, s);
    }
    enemyFile >> x;
    enemyFile >> y;
    int bitmapWidth, bitmapHeight;
    enemyFile >> bitmapWidth;
    enemyFile >> bitmapHeight;
    picture_ = al_create_sub_bitmap(enemies, x, y, bitmapWidth, bitmapHeight);
    enemyFile >> width_;
    enemyFile >> height_;
    enemyFile >> pic_width_;
    enemyFile >> pic_height_;
    animationState_ = rand()%8;
    enemyFile >> animationTime_;
    lastAnimation_ = al_get_time() - animationTime_;
    enemyFile >> step_;
    enemyFile >> hp_;
    lastHurt_ = al_get_time() - 0.5;
    int range;
    enemyFile >> range;
    enemyFile >> stateCount_;
    double shotTime;
    enemyFile >> shotTime;
    int shotPicNumber;
    enemyFile >> shotPicNumber;
    ALLEGRO_BITMAP* shotPicture = al_create_sub_bitmap(shots, shotPicNumber*20, 0, 20, 20);
    int shootingstyle, movingstyle;
    enemyFile >> movingstyle;
    enemyFile >> shootingstyle;
    enemyFile.close();
    switch (movingstyle)
    {
        case 0: movingStyle_ = new RandomMove(this); break;
        case 1: movingStyle_ = new ChasingMove(this, bunny); break;
        case 2: movingStyle_ = new PikachuMove(this, bunny); break;
    }
    switch (shootingstyle)
    {
        case 0: shootingStyle_ = new FourShots(this, range, shotTime, shotPicture); break;
        case 1: shootingStyle_ = new DirectedShots(this, range, shotTime, shotPicture, bunny); break;
        case 2: shootingStyle_ = new FiveRandomShots(this, range, shotTime, shotPicture); break;
        case 3: shootingStyle_ = new FiveShots(this, range, shotTime, shotPicture); break;
    }
}
Example #5
0
  // TODO: negative value in numberOfFrames "borrows" frames from another state, to avoid having to duplicate bitmaps for custom states
  Sprite::Sprite(const std::string &name, const std::string &file, int width, int height, int numberOfStates, const char *numberOfFrames, const char *framesPerSecond, int framesPerRow)
  {
    m_name = name;
    m_file = file;
    m_width = width;
    m_height = height;
    m_numberOfStates = numberOfStates;

    m_numberOfFrames = new char[numberOfStates];
    memcpy(m_numberOfFrames, numberOfFrames, numberOfStates);
    m_framesPerSecond = new char[numberOfStates];
    memcpy(m_framesPerSecond, framesPerSecond, numberOfStates);

    // load bitmap from file
    m_bitmap = al_load_bitmap(file.c_str());
    // FIXME: check for null bitmaps

    // break bitmap up into sub bitmaps
    int frameIndex = 0;
    m_frames = new ALLEGRO_BITMAP**[numberOfStates];
    m_bitmasks = new Bitmask**[numberOfStates];
    for(int i = 0; i < numberOfStates; i++)
    {
      m_frames[i] = new ALLEGRO_BITMAP*[numberOfFrames[i]];
      m_bitmasks[i] = new Bitmask*[numberOfFrames[i]];
      for(int j = 0; j < numberOfFrames[i]; j++)
      {
        m_frames[i][j] = al_create_sub_bitmap(m_bitmap, (frameIndex % framesPerRow) * width, (frameIndex / framesPerRow) * height, width, height);
        m_bitmasks[i][j] = new Bitmask(m_frames[i][j]);
        frameIndex++;
      }
    }
  }
Example #6
0
std::string gphandle::generate_back() {

	int grass_sprites_size = 9;

	std::string grass_loc = search_for("grass", "dirs.txt");

	ALLEGRO_BITMAP *grass_img = al_load_bitmap(grass_loc.c_str());

	std::vector<ALLEGRO_BITMAP *> grasses(grass_sprites_size);

	for(int i=0; i<grass_sprites_size; i++) {
		grasses[i] = al_create_sub_bitmap(grass_img, i*32, 0, (i+1)*32, 32);
	}

	ALLEGRO_BITMAP *new_back = al_create_bitmap(1024, 768);
	al_set_target_bitmap(new_back);

	srand(time(NULL));

	for(int i=0; i<24; i++){
		for(int j=0; j<32; j++) {
			int random = rand()%grass_sprites_size;
			al_draw_bitmap(grasses[random], 32.0 * j, 32.0 * i,0);
		}
	}

	std::string location = "tmps/background.png";

	al_save_bitmap(location.c_str(), new_back);

	return location;
}
AnimatedComp::AnimatedComp(ALLEGRO_BITMAP* myBitmap,Vector2 myDimensions,PositionComp* myPosComp)
	:Component("Animated"),bitmap(myBitmap),dimensions(myDimensions)
{
	initialize();

	positionComp = myPosComp;

	offset = Vector2 (dimensions.x/2,dimensions.y/2);

	current_frame = Vector2(0,0);
	number_frames = Vector2 (al_get_bitmap_width(bitmap)/dimensions.x, al_get_bitmap_height(bitmap)/dimensions.y);


	for (int x = 0; x < number_frames.x; ++x)
	{
		std::vector<ALLEGRO_BITMAP*> one_dim;
		bitmap_2Dvector.push_back(one_dim);
	}

	for (int y = 0; y < number_frames.y; ++y)
	{
		for (int x = 0; x < number_frames.x; ++x)
		{
			//int index = x *(int)number_frames.y + y;
			bitmap_2Dvector[x].push_back(al_create_sub_bitmap(	bitmap, x * dimensions.x, y * dimensions.y,		dimensions.x,dimensions.y));
		}
	}


	frame_interval=0.25;

	current_time =0;
}
Example #8
0
// Funcao que adiciona a sprites a partir de uma imagem "pai".
void add_sprites(ALLEGRO_BITMAP *parent)
{
	// a partir de y=40, pega de 128 em 128, 3 em cima e 2 em baixo
	int xAux = 0;
	int yAux = 40;
    for (int i = 0; i < 5; i++)
	{
		if (i==3) {
			xAux = 0;
			yAux += 128;
		}

		// Cria um "sub-bitmap" do pai, nas coordenadas especificadas com o tamanho especificado.
		// Um "sub-bitmap" é um bitmap que compartilha a memória de desenho com um bitmap
		// pré-existente (pai), mas possivelmente com tamanho diferente.
		ALLEGRO_BITMAP *spr = al_create_sub_bitmap(parent,xAux, yAux, 128, 128);
		xAux += 128;
		Sprite s;
		if (contSprites < MAX_SPRITES) {
			s.sprite = spr;
			s.x = 0;
			s.y = height - 128;
			spriteAnimada[contSprites] = s;
			contSprites++;
		}
	}
}
Example #9
0
bninja* InitNinja(bninja** NinjaAux){



    (*(NinjaAux)) = (bninja* )malloc(sizeof(bninja));

    (*(NinjaAux))->life = 100.0;
    (*(NinjaAux))->lives = 0;
    (*(NinjaAux))->x = 10;
    (*(NinjaAux))->y = 10;
    (*(NinjaAux))->lastframe = 0;
    (*(NinjaAux))->direction = 0;
    (*(NinjaAux))->action = 0;
    (*(NinjaAux))->animation = M_STOP;
    (*(NinjaAux))->speed = 3.0;
    (*(NinjaAux))->frames = 0;





      ((*NinjaAux))->sprsheet = al_load_bitmap("proto/mario.bmp");

     //(*(NinjaAux))->lastSprite =  al_load_bitmap("proto/perso.bmp");



     al_convert_mask_to_alpha(((*NinjaAux))->sprsheet, al_map_rgb(255,0,255));


     int maxwidth = al_get_bitmap_width(((*NinjaAux))->sprsheet );

     (*(NinjaAux))->spr[M_STOP][0] = al_create_sub_bitmap(((*NinjaAux))->sprsheet,  maxwidth - 150,0,  27  ,27);
     (*(NinjaAux))->spr[M_STOP][1] = al_create_sub_bitmap(((*NinjaAux))->sprsheet,  maxwidth - 170,0,  27  ,27);
     (*(NinjaAux))->spr[M_STOP][2] = al_create_sub_bitmap(((*NinjaAux))->sprsheet,  maxwidth -  200,0,  27  ,27);


    al_destroy_bitmap((*(NinjaAux))->lastSprite);

    printf("Numero %d", SpriteQty( (*(NinjaAux)) ,M_STOP ));



    return *NinjaAux;

}
void init(ALLEGRO_BITMAP *sprites, struct Movil *nave) {
    nave->a.x = 0.;
    nave->a.y = 0.;
    nave->v.x = 0.;
    nave->v.y = 0.;
    nave->r.x = 0.;
    nave->r.y = 0.;
    nave->img = al_create_sub_bitmap( sprites, 0, 98, 33, 29 );
}
Example #11
0
void AnimationFilm::DisplayFrame(const Point& at, byte frameNo) const {
	Rect box = boxes.at(frameNo);
	ALLEGRO_BITMAP* tmp = al_create_sub_bitmap(bitmap,
		box.left, box.top, box.w, box.h);
	al_draw_scaled_bitmap(tmp,
		0, 0, box.w, box.h,
		at.x, at.y, box.w * ScaleFactor, box.h * ScaleFactor, 0);
	al_destroy_bitmap(tmp);
}
int main(int argc, char **argv)
{
	const char *if_name = argv[1];
	const char *of_name = argv[2];

	al_init();
	al_init_image_addon();

	al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ANY_32_WITH_ALPHA);
	al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP);

	ALLEGRO_BITMAP *i_bmp = al_load_bitmap(if_name);
	int w, h;
	w = al_get_bitmap_width(i_bmp);
	h = al_get_bitmap_height(i_bmp);
	ALLEGRO_BITMAP *o_bmp = al_create_bitmap(w, h);
	al_set_target_bitmap(o_bmp);
	al_clear_to_color(al_map_rgb(255, 0, 255));

	int nanims = h/SUBH;
	int nframes = w/SUBW;

	for (int anim = 0; anim < nanims; anim++) {
		int f = SUBW-1;
		for (int i = 0; i < 4; i++) {
			ALLEGRO_BITMAP *sub = al_create_sub_bitmap(i_bmp,
				i*SUBW, anim*SUBH, SUBW, SUBH);
			int thisf = furthest_left(sub);
			if (thisf < SUBW-1 && thisf < f)
				f = thisf;
			al_destroy_bitmap(sub);
		}
		for (int i = 0; i < 4; i++) {
			ALLEGRO_BITMAP *sub = al_create_sub_bitmap(i_bmp,
				i*SUBW, anim*SUBH, SUBW, SUBH);
			al_draw_bitmap(sub,
				i*SUBW-(f/2),
				anim*SUBH, 0);
			al_destroy_bitmap(sub);
		}
	}

	al_save_bitmap(of_name, o_bmp);
}
 bool SubBitmap::create()
 {
     destroy();
     if(_V_parent_bitmap)
     {
         _V_bitmap=al_create_sub_bitmap(_V_parent_bitmap,_V_sub_x,_V_sub_y,_V_size_x,_V_size_y);
         return _V_bitmap;
     }
     return false;
 }
Example #14
0
bool
set_multi_room (int w, int h)
{
  if (w == mr.w && h == mr.h) return true;

  int sw = ORIGINAL_WIDTH * w;
  int sh = ROOM_HEIGHT * h + 11;

  ALLEGRO_BITMAP *b = create_bitmap (sw, sh);
  if (! b) return false;
  destroy_bitmap (b);

  destroy_multi_room ();

  mr.h = h;
  mr.w = w;

  set_target_backbuffer (display);
  al_set_new_bitmap_flags (ALLEGRO_VIDEO_BITMAP);

  screen = create_bitmap (sw, sh);
  effect_buffer = create_bitmap (sw, sh);
  black_screen = create_bitmap (sw, sh);
  cache = create_bitmap (sw, sh);

  int x, y;
  mr.cell = xcalloc (w, sizeof (* mr.cell));
  mr.last.cell = xcalloc (w, sizeof (* mr.last.cell));
  for (x = 0; x < w; x++) {
    mr.cell[x] = xcalloc (h, sizeof (** mr.cell));
    mr.last.cell[x] = xcalloc (h, sizeof (** mr.last.cell));
    for (y = 0; y < h; y++) {
      int x0 = ORIGINAL_WIDTH * x;
      int y0 = ROOM_HEIGHT * y;
      int sw = ORIGINAL_WIDTH;
      int sh = ORIGINAL_HEIGHT - (y < h - 1 ? 8 : 0);
      mr.cell[x][y].screen = al_create_sub_bitmap (screen, x0, y0, sw, sh);
      mr.cell[x][y].cache = al_create_sub_bitmap (cache, x0, y0, sw, sh);
    }
  }

  return true;
}
Example #15
0
player::player(){
    bmp = al_load_bitmap("player.png");
    animationwidth = al_get_bitmap_width(bmp)/5;
    animationheight = al_get_bitmap_height(bmp)/8;
    al_convert_mask_to_alpha(bmp, al_map_rgb(255, 0, 255));
    for (int x=0; x<8; x++) {
        for (int y=0; y<5; y++) {
            bmp_array[x][y] = al_create_sub_bitmap(bmp, 32*x, 32*y, 32, 32);
        }
    }
}
Example #16
0
Terminal::Terminal(std::string const& fontPath, int charWidth, int charHeight, int width, int height)
{
    this->width = width;
    this->height = height;
    this->charWidth = charWidth;
    this->charHeight = charHeight;
    
    // init addons
    if (!al_init_image_addon())
        THROW() << "Failed to init image addon";
    if (!al_init_primitives_addon())
        THROW() << "Failed to init primitives addon";
    
    // load the font
    glyphSheet = al_load_bitmap(fontPath.c_str());
    if (!glyphSheet)
        THROW() << "Failed to load font: " << fontPath;
    
    // create the glyphs
    for (int y = 0; y < GLYPH_ROWS; ++y) {
        for (int x = 0; x < GLYPH_COLUMNS; ++x) {
            ALLEGRO_BITMAP* glyph = al_create_sub_bitmap(glyphSheet, x * charWidth, y * charHeight, charWidth, charHeight);
            if (!glyph)
                THROW() << "Failed to create glyphs";
            al_convert_mask_to_alpha(glyph, al_map_rgb(0, 0, 0));
            glyphs.push_back(glyph);
        }
    }
    
    // create the window
    al_set_new_display_flags(ALLEGRO_WINDOWED);
    al_set_new_display_option(ALLEGRO_SAMPLE_BUFFERS, 1, ALLEGRO_SUGGEST);
    al_set_new_display_option(ALLEGRO_SAMPLES, 8, ALLEGRO_SUGGEST);
    display = al_create_display(width * charWidth, height * charHeight);
    if (!display)
        THROW() << "Failed to create display";
    al_clear_to_color(al_map_rgb(0, 0, 0));
    
    // create the character arrays
    for (int i = 0; i < width * height; i++) {
        chars.push_back(CharData(' ', white, black));
        oldChars.push_back(CharData('?', white, black));
        // we make oldChars different to force a refresh
    }
    
    foregroundColor = white;
    backgroundColor = black;
    cursorX = cursorY = 0;
}
Example #17
0
static int allua_Bitmap_create_sub(lua_State * L)
{
   ALLUA_bitmap parent = allua_check_bitmap(L, 1);
   int x = luaL_checkint(L, 2);
   int y = luaL_checkint(L, 3);
   int w = luaL_checkint(L, 4);
   int h = luaL_checkint(L, 5);
   ALLUA_bitmap child = al_create_sub_bitmap(parent, x, y, w, h);
   if (child)
      allua_pushBitmap(L, child, true);
   else
      lua_pushnil(L);

   return 1;
}
Example #18
0
void posicionar(ALLEGRO_BITMAP *sprites, struct Nave *jugador){
    jugador->x = PANTALLA_X/2;
    jugador->y = PANTALLA_Y/2;
    jugador->width = 20;
    jugador->height = 20;
    jugador->img = al_create_sub_bitmap(
            sprites,
            0, 20, jugador->width, jugador->height);
    /*al_set_target_bitmap(jugador->img);
      al_clear_to_color(al_map_rgb(150, 0, 255));*/
    //for(int i = 0; i<3; i++){
    /*jugador->img = al_create_sub_bitmap(
      sprites, 20, 20, 40, 40
      );*/
}
Example #19
0
Player::Player(Input* i, int w, int h, char* filename)
	: input(i), angleDirection(0), width(w), height(h),speed(2), weapon(NULL)
{
	spriteSheet = al_load_bitmap(filename);
	if(!spriteSheet)
	{
		std::cout<<"Erro no bitmap de player"<<std::endl;
		return;
	}
	al_convert_mask_to_alpha(spriteSheet,al_map_rgb(255,0,255));

	currentSprite = al_create_sub_bitmap(spriteSheet,width,height,width,height);

    weapon = new Ak47();
}
Example #20
0
void Bullet::Render()
{
	if( ForRemoval )
	{
		return;
	}

	ALLEGRO_BITMAP* tileset = Game->GetGameScaledImage();
	int tileX = (64 + (Animation_CurrentFrame * 16)) * Game->graphicsMultiplier;
	int tileY = 16 * Game->graphicsMultiplier;

	ALLEGRO_BITMAP* tmp = al_create_sub_bitmap( tileset, tileX, tileY, 16 * Game->graphicsMultiplier, 16 * Game->graphicsMultiplier );
	al_draw_rotated_bitmap( tmp, 8 * Game->graphicsMultiplier, 8 * Game->graphicsMultiplier, Position->X * Game->graphicsMultiplier, Position->Y * Game->graphicsMultiplier, Angle * (M_PI / 180), 0 );
	al_destroy_bitmap( tmp );
	
}
void MultipleControllerSelectStage::Render()
{
	GameStage* g = (GameStage*)Framework::SystemFramework->ProgramStages->Previous( this );
	g->Render();
	al_draw_filled_rectangle( 0, 0, Framework::SystemFramework->GetDisplayWidth(), Framework::SystemFramework->GetDisplayHeight(), al_map_rgba( 0, 0, 0, 128 ) );

	int boxW = Framework::SystemFramework->GetDisplayWidth() / 5;
	int boxH = Framework::SystemFramework->GetDisplayHeight() / 4;
	std::list<Plane*>* players = g->GetPlaneObjects();
	ALLEGRO_BITMAP* tileset = g->GetGameScaledImage();

	int i = 0;
	for( std::list<Plane*>::const_iterator p = players->begin(); p != players->end(); p++ )
	{
		al_draw_filled_rounded_rectangle( (boxW * (i % 5)) + 2, (boxH * (i / 5)) + 2, (boxW * (i % 5)) + boxW - 2, (boxH * ((i + 5) / 5)) - 2, 6, 6, al_map_rgba( 255, 255, 255, 128 ) );

		Plane* ply = (Plane*)*p;
		int tileX = 144 * g->graphicsMultiplier;
		int tileY = (ply->Team * 48) * g->graphicsMultiplier;
		ALLEGRO_BITMAP* tmp = al_create_sub_bitmap( tileset, tileX, tileY, 48 * g->graphicsMultiplier, 48 * g->graphicsMultiplier );
		al_draw_scaled_bitmap( tmp, 0, 0, 48 * g->graphicsMultiplier, 48 * g->graphicsMultiplier, (boxW * (i % 5)) + 4, (boxH * (i / 5)) + 4, boxW - 4, boxH - 4, 0 );
		al_destroy_bitmap( tmp );
		i++;
	}


	ALLEGRO_FONT* survivalFont = Framework::SystemFramework->GetFontManager()->GetFont( "resource/falsepos.ttf", Framework::SystemFramework->GetDisplayHeight() / 18, 0 );
	ALLEGRO_COLOR survivalBorder = al_map_rgb( 0, 0, 0 );
	ALLEGRO_COLOR survivalNormal = al_map_rgb( 255, 255, 255 );

	int Xpos = (Framework::SystemFramework->GetDisplayWidth() / 2) - (al_get_text_width( survivalFont, "Press Enter To Start" ) / 2);
	int Lsiz = al_get_font_line_height( survivalFont );

	for( int yBrd = -1; yBrd < 2; yBrd++ )
	{
		for( int xBrd = -1; xBrd < 2; xBrd++ )
		{
			al_draw_text( survivalFont, survivalBorder, Xpos + xBrd, Framework::SystemFramework->GetDisplayHeight() - Lsiz - 6 + yBrd, 0, "Press Enter To Start" );
		}
	}

	al_draw_text( survivalFont, survivalNormal, Xpos, Framework::SystemFramework->GetDisplayHeight() - Lsiz - 6, 0, "Press Enter To Start" );


}
Example #22
0
File: map.cpp Project: faod/ld33
std::shared_ptr<ALLEGRO_BITMAP> Tile::getFlameFrame(size_t num)
{
    if(flames == NULL)
    {
        ALLEGRO_PATH *path;

        path = al_get_standard_path(ALLEGRO_RESOURCES_PATH);
        al_append_path_component(path, RESOURCES_DIR);
        al_set_path_filename(path, "flames.png");
        flames = al_load_bitmap(al_path_cstr(path, ALLEGRO_NATIVE_PATH_SEP));

        al_destroy_path(path);
    }
    if(num < 3)
    {
        return std::shared_ptr<ALLEGRO_BITMAP>(al_create_sub_bitmap(flames, num * 32, 0, 32, 32), al_destroy_bitmap);
    }
    return NULL;
}
Example #23
0
tile::tile(){
    tiles = al_load_bitmap("fd.png");
    al_convert_mask_to_alpha(tiles, al_map_rgb(255, 0, 255));
    map_h = al_get_bitmap_height(tiles);
    map_w = al_get_bitmap_width(tiles);
    offset_w=0; 
    offset_h=0;
    int i1=0;
    for (int i=0; i<16; i++) {
        offset_w = 0;
        for (int j=0; j<16; j++) {
                printf("%d,%d   %d\n", offset_w,offset_h, i1);
                tiles_array[i1]=al_create_sub_bitmap(tiles, offset_w, offset_h, 64, 64);
                i1++;
            offset_w+=64;

        }
        offset_h+=64;
    }
}
Example #24
0
/* import_bitmap_font_color:
 *  Helper for import_bitmap_font, below.
 */
static int import_bitmap_font_color(uint32_t *data, int pitch,
   int bmp_w, int bmp_h,
   ALLEGRO_BITMAP **bits, ALLEGRO_BITMAP *glyphs, int num,
   int *import_x, int *import_y)
{
   int w, h, i;

   for (i = 0; i < num; i++) {
      font_find_character(data, pitch, bmp_w, bmp_h,
         import_x, import_y, &w, &h);
      if (w <= 0 || h <= 0) {
         return -1;
      }
      else {
         bits[i] = al_create_sub_bitmap(glyphs,
            *import_x + 1, *import_y + 1, w, h);
         *import_x += w;
      }
   }
   return 0;
}
Example #25
0
void Sprite::draw() {
    // Retrieves the Bitmap from the View's ResourceManager
    Bitmap* b = view.getBitmap(bitmap);
    Rect<float>* texCoords = nullptr;
    if (anims.size() == 0 || !currAnimation) {
        texCoords = &texCoord;
    } else {
        texCoords = &(currAnimation->getCurrentTexCoords());
    }
    // Size of this frame
    if (b) {
        if (rotAngle == 0.0f && !isTinted) {
            al_draw_scaled_bitmap(b->bitmap(),
            texCoords->position().x(), texCoords->position().y(),
            texCoords->width(), texCoords->height(),
            pos.x(), pos.y(),
            s.x(), s.y(),
            0);
        } else {
            // To rotate the bitmap, we should do it in a temporary bitmap
            if (animHasChangedSinceLastRotation) {
                if (bmp) {
                    al_destroy_bitmap(bmp);
                    bmp = nullptr;
                }
                bmp = al_create_sub_bitmap(b->bitmap(),texCoords->position().x(),texCoords->position().y(),texCoords->width(),texCoords->height());
                animHasChangedSinceLastRotation = false;
            }
            al_draw_tinted_scaled_rotated_bitmap(bmp,
                tColor.color(),
                rotCenter.x()/(s.x()/texCoords->width()),rotCenter.y()/(s.y()/texCoords->height()),
                pos.x(),pos.y(),
                s.x()/texCoords->width(),s.y()/texCoords->height(),
                rotAngle,
                0);
        }
    } else {
        printf("ERR: Sprite::draw() -> unknown Bitmap uniqueId : %s\n",bitmap.c_str());
    }
}
int main() {
  bool menu = true;
  char pontuacao[100];
  char vida[100];
  ALLEGRO_COLOR  font_color;
  ALLEGRO_FONT *font,*font2;
  ALLEGRO_AUDIO_STREAM *musica = NULL;
  
  camera *cam = camera_inicializa(0);
  if(!cam)
    erro("erro na inicializacao da camera\n");
  int x = 0, y =  0;
  int largura = cam->largura;
  int altura = cam->altura;
  int fps = 0,tempo = 5;
  int ndisco = 9;
 
  if(!al_init())
    erro("erro na inicializacao do allegro\n");

  if(!al_init_image_addon())
    erro("erro na inicializacao do adicional de imagem\n");

  al_init_font_addon();
  al_init_ttf_addon();

    font_color = al_map_rgb(0, 0, 0);
    
    font = al_load_ttf_font("Fontes/Blokletters-Viltstift.ttf", 20, 0);
    font2 = al_load_ttf_font("Fontes/Blokletters-Viltstift.ttf", 50, 0);
    


  if(!al_init_primitives_addon())
    erro("erro na inicializacao do adicional de primitivas\n");

  ALLEGRO_TIMER *timer = al_create_timer(1.0 / FPS);
  if(!timer)
    erro("erro na criacao do relogio\n");

  ALLEGRO_DISPLAY *display = al_create_display(2 * largura,altura);
  if(!display)
    erro("erro na criacao da janela\n");

  ALLEGRO_EVENT_QUEUE *queue = al_create_event_queue();
  if(!queue)
    erro("erro na criacao da fila\n");

   if (!al_install_audio())
    {
        fprintf(stderr, "Falha ao inicializar áudio.\n");
        return false;
    }
 
    if (!al_init_acodec_addon())
    {
        fprintf(stderr, "Falha ao inicializar codecs de áudio.\n");
        return false;
    }
    if (!al_reserve_samples(1))
    {
        fprintf(stderr, "Falha ao alocar canais de áudio.\n");
        return false;
    }

  musica = al_load_audio_stream("Audio/elementary.ogg", 4, 1024);
  if(!musica)
        erro("Erro na alocação da musica de fundo\n");

  al_attach_audio_stream_to_mixer(musica, al_get_default_mixer());
  al_set_audio_stream_playing(musica, true);

  al_register_event_source(queue, al_get_timer_event_source(timer));
  al_register_event_source(queue, al_get_display_event_source(display));

  al_start_timer(timer);
  
  unsigned char ***matriz = camera_aloca_matriz(cam);
  ALLEGRO_BITMAP *buffer = al_get_backbuffer(display);
  ALLEGRO_BITMAP *fundo = al_load_bitmap("Imagens/Elementary2.png");

  if(!fundo)
    erro("erro ao carregar Elementary.png");

  ALLEGRO_BITMAP *esquerda = al_create_sub_bitmap(buffer, 0, 0, largura, altura);
  ALLEGRO_BITMAP *direita = al_create_sub_bitmap(buffer, largura, 0, largura, altura);

  /**********/
  Disco *discos[9];
  bool perdeu = false;
  carregarDiscos(discos);
  int pontos=0,velo = 1;
  int aux1 = 1;
  int vidas = 10;
  int ultimoDisco = 0;
  int distance = 0;
  int desenhar = 0;
  int terminar = 0;
  al_set_target_bitmap(esquerda);
  al_draw_bitmap(fundo,0,0,0);
  while(1) {

    ALLEGRO_EVENT event;

    al_wait_for_event(queue, &event);

    switch(event.type) {
    case ALLEGRO_EVENT_TIMER:
      desenhar = 1;
      break;
    case ALLEGRO_EVENT_DISPLAY_CLOSE:
      terminar = 1;
      break;
   
    }

    if(terminar)
      break;

    if(desenhar && al_is_event_queue_empty(queue)) {
      desenhar = 0;
      camera_atualiza(cam);
      mediana(cam);
      /**********/
      al_set_target_bitmap(esquerda);
      al_draw_bitmap(fundo,0,0,0);
      
      if(!menu){
        while(aux1 <= ndisco){
          if(discos[aux1]->status == false){
            if(distance > 50 || ultimoDisco==0  ){
              printf("%d\n",aux1 );
              al_draw_bitmap(discos[aux1]->elemento,discos[aux1]->pos_x,discos[aux1]->pos_y,0);
              discos[aux1]->status = true;
              distance = 0;
              ultimoDisco = aux1;
              break;
            }else
             aux1++;
          }else{
              discos[aux1]->pos_y+=(10+velo);
              al_draw_bitmap(discos[aux1]->elemento,discos[aux1]->pos_x,discos[aux1]->pos_y,0);
            aux1++;
              
            }
        }
        distance = discos[ultimoDisco]->pos_y;
        for(aux1 = 1;aux1<ndisco;aux1++){
          if(discos[aux1]->pos_x >= x-30 && discos[aux1]->pos_x <= x+30 && discos[aux1]->pos_y >= y-30 &&  discos[aux1]->pos_y <= y+30){
            if(discos[aux1]->tipo == 2){ // Tipo do fogo(Necessario para vencer o jogo)
            pontos +=10;
            velo += 1;
            discos[aux1]->pos_x = rand()%9 * 55;
            discos[aux1]->pos_y = 0;
            discos[aux1]->status = false;
          }else if(discos[aux1]->tipo == 1){ //Tipo da agua(Perde o jogo se destruir esse disco)
            discos[aux1]->pos_x = rand()%9 * 55;
            discos[aux1]->pos_y = 0;
            discos[aux1]->status = false;
            al_flip_display();
            vidas--;
          }else if(discos[aux1]->tipo == 3){//Tipo planta(Aumenta velocidade de queda das peças)
            velo *= 2;
            discos[aux1]->pos_x = rand()%9 * 55;
            discos[aux1]->pos_y = 0;
            discos[aux1]->status = false;
          }

        }else if( discos[aux1]->pos_y > 480){
          if(discos[aux1]->tipo == 2){ //Tipo da agua e Planta(Não perde se deixar cair)
               discos[aux1]->pos_x = rand()%9 * 55;
            discos[aux1]->pos_y = 0;
            discos[aux1]->status = false;
            al_flip_display();
            vidas--;
          }else{
            discos[aux1]->pos_x = rand()%9 * 55;
            discos[aux1]->pos_y = 0;
            discos[aux1]->status = false;
          }
        }
      }

        aux1 = 1;
      sprintf(pontuacao,"PONTUAÇÃO: %d",pontos);
      al_draw_text(font, al_map_rgb(255, 255, 255), 50, 5, 0,pontuacao);
       sprintf(vida,"VIDAS: %d",vidas);
      al_draw_text(font, al_map_rgb(255, 255, 255), 300, 5, 0,vida);
      al_flip_display();

      }
       if(perdeu){
        al_draw_text(font2, al_map_rgb(255, 0, 0), 50, 100, 0,"PONTUAÇÃO FINAL");
        sprintf(pontuacao,"%d",pontos);
        al_draw_text(font2, al_map_rgb(255, 0, 0), 250, 170, 0,pontuacao);
        al_flip_display();
        al_rest(3);
        break;
      }
       
      if(vidas == 0){
        perdeu = true;
      }

      if(menu){
        if(abrirJogo(x,y,&fps,&tempo,font,font2, font_color)){
          fundo = al_load_bitmap("Imagens/galaxia.png");
          menu = false;
        }
      }
      cameraRastreia(cam,&x,&y);
   

      al_set_target_bitmap(direita);
      camera_copia(cam, cam->quadro, direita);
      al_flip_display();
    }
  }
  al_destroy_bitmap(direita);
  al_destroy_bitmap(fundo);
  al_destroy_bitmap(esquerda);
  camera_libera_matriz(cam, matriz);
int fri = 9;
while(fri != 0){
  free(discos[fri]);
  fri--;

}


  al_stop_timer(timer);

  al_unregister_event_source(queue, al_get_display_event_source(display));
  al_unregister_event_source(queue, al_get_timer_event_source(timer));

  al_destroy_event_queue(queue);
  al_destroy_display(display);
  al_destroy_timer(timer);
  al_destroy_audio_stream(musica);
  al_shutdown_primitives_addon();
  al_shutdown_image_addon();
  al_uninstall_system();

  camera_finaliza(cam);

  return EXIT_SUCCESS;
}
int main(void)
{


    int vMapa = 0;
    int vMatriz_Mapa[21][27],i=0,j=0;
    FILE *fMapa = fopen("dormitorio_masculino.txt", "r"); // Carrega o arquivo de texto da fase em questão;

    char vLe_Char;

    while((vLe_Char = getc(fMapa) ) != EOF )    // Grava Caracter enquanto não chegar ao final do arquivo;
    {
        if ( i < 27 ) // Enquanto estivar na linha;
        {
            vMatriz_Mapa[j][i] = atoi(&vLe_Char); // Carrega a matriz com os caracteres que representam as imagens;
            i++;
        }
        else // senao passa para a proxima linha;
        {
            j++;
            i=0;
        }

    }
    fclose(fMapa);
    for (j=0;j<19;j++){
    for (i=0;i<27;i++){

   // if(vMatriz_Mapa[j/32][i/32]==2){
        printf("%d",vMatriz_Mapa[j][i]);


    }
    printf("\n");
    }
    bool sair = false;
    int tecla = 0,top = 0, left = 0, right = 0, down=0;
    int x=192,y=64;

    if (!al_init())
    {
        fprintf(stderr, "Falha ao inicializar a Allegro.\n");
        return false;
    }

    al_init_font_addon();

    if (!al_init_ttf_addon())
    {
        fprintf(stderr, "Falha ao inicializar add-on allegro_ttf.\n");
        return false;
    }

    if (!al_init_image_addon())
    {
        fprintf(stderr, "Falha ao inicializar add-on allegro_image.\n");
        return false;
    }

    if (!al_install_keyboard())
    {
        fprintf(stderr, "Falha ao inicializar o teclado.\n");
        return false;
    }

    janela = al_create_display(LARGURA_TELA, ALTURA_TELA);
    if (!janela)
    {
        fprintf(stderr, "Falha ao criar janela.\n");
        return false;
    }

    al_set_window_title(janela, "Utilizando o Teclado");


    fila_eventos = al_create_event_queue();
    if (!fila_eventos)
    {
        fprintf(stderr, "Falha ao criar fila de eventos.\n");
        al_destroy_display(janela);
        return false;
    }

    fundo = al_load_bitmap("dormitorio_masculino.bmp");
    if (!fundo)
    {
        fprintf(stderr, "Falha ao carregar imagem de fundo.\n");
        al_destroy_display(janela);
        al_destroy_event_queue(fila_eventos);
        return false;
    }

    timer = al_create_timer(6/60.0);
    al_register_event_source(fila_eventos, al_get_timer_event_source(timer));
    al_register_event_source(fila_eventos, al_get_keyboard_event_source());
    al_register_event_source(fila_eventos, al_get_display_event_source(janela));
    al_draw_bitmap(fundo, 0, 0, 0);
    ALLEGRO_BITMAP *peterSET = al_load_bitmap("sabrina3.bmp");
    al_convert_mask_to_alpha(peterSET,al_map_rgb(255,0,255));
    ALLEGRO_BITMAP *peterCHAR[12];

peterCHAR[0] = al_create_bitmap(32,32);
peterCHAR[0] = al_create_sub_bitmap(peterSET,  0, 0, 32, 32);
peterCHAR[1] = al_create_bitmap(32,32);
peterCHAR[1] = al_create_sub_bitmap(peterSET,  32, 0, 32, 32);
peterCHAR[2] = al_create_bitmap(32,32);
peterCHAR[2] = al_create_sub_bitmap(peterSET,  64, 0, 32, 32);
peterCHAR[3] = al_create_bitmap(32,32);
peterCHAR[3] = al_create_sub_bitmap(peterSET,  0, 32, 32, 32);
peterCHAR[4] = al_create_bitmap(32,32);
peterCHAR[4] = al_create_sub_bitmap(peterSET,  32, 32, 32, 32);
peterCHAR[5] = al_create_bitmap(32,32);
peterCHAR[5] = al_create_sub_bitmap(peterSET,  64, 32, 32, 32);
peterCHAR[6] = al_create_bitmap(32,32);
peterCHAR[6] = al_create_sub_bitmap(peterSET,  0, 64, 32, 32);
peterCHAR[7] = al_create_bitmap(32,32);
peterCHAR[7] = al_create_sub_bitmap(peterSET,  32, 64, 32, 32);
peterCHAR[8] = al_create_bitmap(32,32);
peterCHAR[8] = al_create_sub_bitmap(peterSET,  64, 64, 32, 32);
peterCHAR[9] = al_create_bitmap(32,32);
peterCHAR[9] = al_create_sub_bitmap(peterSET,  0, 96, 32, 32);
peterCHAR[10] = al_create_bitmap(32,32);
peterCHAR[10] = al_create_sub_bitmap(peterSET,  32, 96, 32, 32);
peterCHAR[11] = al_create_bitmap(32,32);
peterCHAR[11] = al_create_sub_bitmap(peterSET,  64, 96, 32, 32);
al_draw_bitmap(fundo, 0, 0, 0);
al_draw_bitmap(peterCHAR[10],x,y,0);
al_flip_display();
    al_start_timer(timer);
    while (!sair)
    {
        while(!al_is_event_queue_empty(fila_eventos))
        {
            ALLEGRO_EVENT evento;
            al_wait_for_event(fila_eventos, &evento);

            if (evento.type == ALLEGRO_EVENT_KEY_DOWN)
            {
                switch(evento.keyboard.keycode)
                {
                case ALLEGRO_KEY_ESCAPE:
                    sair = true;
                    break;
                case ALLEGRO_KEY_UP:
                    keys[UP] = true;
                    break;
                case ALLEGRO_KEY_DOWN:
                   keys[DOWN] = true;
                    break;
                case ALLEGRO_KEY_LEFT:
                    keys[LEFT] = true;
                    break;
                case ALLEGRO_KEY_RIGHT:
                    keys[RIGHT] = true;
                    break;
                case ALLEGRO_KEY_SPACE:
                    keys[SELECT]=true;
                    break;
                }
            }else if (evento.type == ALLEGRO_EVENT_KEY_UP)
            {
                switch(evento.keyboard.keycode)
                {
                case ALLEGRO_KEY_UP:
                    keys[UP] = false;
                    break;
                case ALLEGRO_KEY_DOWN:
                   keys[DOWN] = false;
                    break;
                case ALLEGRO_KEY_LEFT:
                    keys[LEFT] = false;
                    break;
                case ALLEGRO_KEY_RIGHT:
                    keys[RIGHT] = false;
                    break;
                case ALLEGRO_KEY_SPACE:
                    keys[SELECT]=false;
                    break;
                }
            }
            else if (evento.type == ALLEGRO_EVENT_DISPLAY_CLOSE)
            {
                sair = true;
            }
            else if (evento.type == ALLEGRO_EVENT_TIMER){

  if(keys[SELECT]){
    if(vMatriz_Mapa[y/32][(x+32)/32]==4){
            return 0;
    }
  }
  if (keys[UP]){

if(vMatriz_Mapa[(y-32)/32][x/32]==0){
                al_draw_bitmap(fundo, 0, 0, 0);
                if(top == 0)
                {   y=y-32;
                    al_draw_bitmap(peterCHAR[10],x,y,0);
                    top = 1;
                }
                else if(top == 1)
                {
                    y=y-32;
                    al_draw_bitmap(peterCHAR[9],x,y,0);
                    top=2;
                }
                else if (top == 2)
                {
                    y=y-32;
                    al_draw_bitmap(peterCHAR[11],x,y,0);
                    top =0;
                }

printf("x = %d e y = %d\n",x,y);
                al_flip_display();
  }
  }


  if (keys[DOWN]){
if(vMatriz_Mapa[(y+32)/32][x/32]==0){
                al_draw_bitmap(fundo, 0, 0, 0);
                if(down == 0)
                {   y=y+32;
                    al_draw_bitmap(peterCHAR[1],x,y,0);
                    down = 1;
                }
                else if(down == 1)
                {
                    y=y+32;
                    al_draw_bitmap(peterCHAR[0],x,y,0);
                    down = 2;
                }
                else if (down == 2)
                {
                    y=y+32;
                    al_draw_bitmap(peterCHAR[2],x,y,0);
                    down = 0;
                }
  }
  }

printf("x = %d e y = %d\n",x,y);
                al_flip_display();

                }


            if (keys[LEFT]){

if(vMatriz_Mapa[y/32][(x-32)/32]==0){
                al_draw_bitmap(fundo, 0, 0, 0);
                if(left == 0)
                {   x=x-32;
                    al_draw_bitmap(peterCHAR[4],x,y,0);
                    left = 1;
                }
                else if(left == 1)
                {
                    x=x-32;
                    al_draw_bitmap(peterCHAR[3],x,y,0);
                    left=2;
                }
                else if (left == 2)
                {
                    x=x-32;
                    al_draw_bitmap(peterCHAR[5],x,y,0);
                    left =0;
                }
                al_flip_display();
printf("x = %d e y = %d\n",x,y);
                }
            }


        if (keys[RIGHT]){

if(vMatriz_Mapa[y/32][(x+32)/32]==0){
al_draw_bitmap(fundo, 0, 0, 0);
                if(right == 0)
                {   x=x+32;
                    al_draw_bitmap(peterCHAR[7],x,y,0);
                    right = 1;
                }
                else if(right == 1)
                {
                    x=x+32;
                    al_draw_bitmap(peterCHAR[6],x,y,0);
                    right=2;
                }
                else if (right == 2)
                {
                    x=x+32;
                    al_draw_bitmap(peterCHAR[8],x,y,0);
                    right =0;
                }

printf("x = %d e y = %d\n",x,y);
                al_flip_display();
                }

        }

        }
    }

    al_destroy_display(janela);
    al_destroy_event_queue(fila_eventos);

    return 0;
}
Example #28
0
static void render(void)
{
   double t = al_get_time();
   if (regenerate) {
      al_destroy_bitmap(logo);
      al_destroy_bitmap(logo_flash);
      logo = NULL;
      regenerate = false;
   }
   if (!logo) {
      /* Generate a new logo. */
      ALLEGRO_BITMAP *fullflash;
      ALLEGRO_BITMAP *fulllogo = generate_logo(param_values[0],
         param_values[1],
         strtol(param_values[2], NULL, 10),
         strtod(param_values[3], NULL),
         strtod(param_values[4], NULL),
         strtod(param_values[5], NULL),
         strtod(param_values[6], NULL),
         strtod(param_values[7], NULL),
         strtod(param_values[8], NULL),
         &fullflash);
      ALLEGRO_BITMAP *crop;
      int x, y, left = 640, top = 480, right = -1, bottom = -1;
      /* Crop out the non-transparent part. */
      al_lock_bitmap(fulllogo, ALLEGRO_PIXEL_FORMAT_ANY, ALLEGRO_LOCK_READONLY);
      for (y = 0; y < 480; y++) {
         for (x = 0; x < 640; x++) {
            ALLEGRO_COLOR c = al_get_pixel(fulllogo, x, y);
            float r, g, b, a;
            al_unmap_rgba_f(c, &r, &g, &b, &a);
            if (a > 0) {
               if (x < left)
                  left = x;
               if (y < top)
                  top = y;
               if (x > right)
                  right = x;
               if (y > bottom)
                  bottom = y;
            }
         }
      }
      al_unlock_bitmap(fulllogo);

      if (right < left)
         right = left;
      if (bottom < top)
         bottom = top;

      crop = al_create_sub_bitmap(fulllogo, left, top,
                                  1 + right - left, 1 + bottom - top);
      logo = al_clone_bitmap(crop);
      al_destroy_bitmap(crop);
      al_destroy_bitmap(fulllogo);

      crop = al_create_sub_bitmap(fullflash, left, top,
                                  1 + right - left, 1 + bottom - top);
      logo_flash = al_clone_bitmap(crop);
      al_destroy_bitmap(crop);
      al_destroy_bitmap(fullflash);

      logo_x = left;
      logo_y = top;

      anim = t;
   }
   draw_background();

   /* For half a second, display our flash animation. */
   if (t - anim < 0.5) {
      ALLEGRO_STATE state;
      int w, h, i, j;
      float f = sin(ALLEGRO_PI * ((t - anim) / 0.5));
      ALLEGRO_COLOR c = al_map_rgb_f(f * 0.3, f * 0.3, f * 0.3);
      w = al_get_bitmap_width(logo);
      h = al_get_bitmap_height(logo);
      al_store_state(&state, ALLEGRO_STATE_BLENDER);
      al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA);
      al_draw_tinted_bitmap(logo, al_map_rgba_f(1, 1, 1, 1 - f), logo_x, logo_y, 0);
      al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE);
      for (j = -2; j <= 2; j += 2) {
         for (i = -2; i <= 2; i += 2) {
            al_draw_tinted_bitmap(logo_flash, c, logo_x + i, logo_y + j, 0);
         }
      }
      al_restore_state(&state);
   }
   else
      al_draw_bitmap(logo, logo_x, logo_y, 0);


   print_parameters();
}
Example #29
0
File: map.cpp Project: faod/ld33
std::shared_ptr<ALLEGRO_BITMAP> Tileset::operator<<(size_t tile)
{
    ALLEGRO_BITMAP *bm = al_create_sub_bitmap(spritesheet_, (tile % 4) * 16, (tile / 4) * 16, 16, 16);
    return std::shared_ptr<ALLEGRO_BITMAP>(bm, al_destroy_bitmap);
}
Example #30
0
void MonopolyPlayer::draw() {
	// Create an allegro bitmap reprenting our player's image on the animation index.
	ALLEGRO_BITMAP *subBitmap = al_create_sub_bitmap( m_image, m_sourceX, m_sourceY * 32, 32, 32 );
	al_draw_bitmap( subBitmap, m_x, m_y, 0 );
}