initializeSettings(MenuItem *settings){ settings->selected = al_load_bitmap("imgs/menu-itens/settings_selected.bmp"); al_convert_mask_to_alpha(settings->selected, al_map_rgb(0, 255, 38)); settings->not_selected = al_load_bitmap("imgs/menu-itens/settings.bmp"); al_convert_mask_to_alpha(settings->not_selected, al_map_rgb(0, 255, 38)); settings->current = settings->not_selected; }
initializeStart(MenuItem *start){ start->selected = al_load_bitmap("imgs/menu-itens/start_selected.bmp"); al_convert_mask_to_alpha(start->selected, al_map_rgb(0, 255, 38)); start->not_selected = al_load_bitmap("imgs/menu-itens/start.bmp"); al_convert_mask_to_alpha(start->not_selected, al_map_rgb(0, 255, 38)); start->current = start->not_selected; }
initializeExit(MenuItem *ex1t){ ex1t->selected = al_load_bitmap("imgs/menu-itens/exit_selected.bmp"); al_convert_mask_to_alpha(ex1t->selected, al_map_rgb(0, 255, 38)); ex1t->not_selected = al_load_bitmap("imgs/menu-itens/exit.bmp"); al_convert_mask_to_alpha(ex1t->not_selected, al_map_rgb(0, 255, 38)); ex1t->current = ex1t->not_selected; }
initializeScores(MenuItem *scores){ scores->selected = al_load_bitmap("imgs/menu-itens/scores_selected.bmp"); al_convert_mask_to_alpha(scores->selected, al_map_rgb(0, 255, 38)); scores->not_selected = al_load_bitmap("imgs/menu-itens/scores.bmp"); al_convert_mask_to_alpha(scores->not_selected, al_map_rgb(0, 255, 38)); scores->current = scores->not_selected; }
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; }
animation::animation(ALLEGRO_BITMAP * spriteSheet,int xOffset,int yOffset,int width, int height,bool oneThrough,int speedTemp) :speed_(speedTemp),xOffset_(xOffset),yOffset_(yOffset),oneThrough_(oneThrough),split_(false) { int bitmapWidth = al_get_bitmap_width(spriteSheet); int bitmapHeight = al_get_bitmap_height(spriteSheet); if(bitmapHeight % height != 0 or bitmapWidth % width != 0) { //Malformed settings.ini or malformed sprite sheet fprintf(stderr, "NIGGER? %i %i\n",width,height); }else { for(int i = 0; i < bitmapWidth / width; ++i) { for(int j = 0; j < bitmapHeight / height; ++j) { ALLEGRO_BITMAP * tempBitmap = al_create_bitmap(width,height); al_set_target_bitmap(tempBitmap); al_clear_to_color(al_map_rgb(100,100,99)); al_draw_bitmap_region(spriteSheet,i*width, j*height, width, height, 0, 0, 0); al_convert_mask_to_alpha(tempBitmap,al_map_rgb(0,0,0)); frames_.push_back(tempBitmap); } } } }
Player::Player() { std::string tmplocation("/tmp/player.png"); this->dimensions = rectangle( { 0.0f, 0.0f, 0.0f, 0.0f }); this->forces = point( { 0.0f, 0.0f }); if (downloadResourceFromInternet(tmplocation, "http://force.mjay.me/spritesheetmegaman1.png") == 200) { this->sprite = al_load_bitmap(tmplocation.c_str()); // Next, we make small bitmap. this->pImage = al_create_bitmap(60, 64); this->dimensions.width = al_get_bitmap_width(this->pImage); this->dimensions.height = al_get_bitmap_height(this->pImage); al_set_target_bitmap(this->pImage); // Make sure, its actually transparent, by creating an alpha channel // in the background. al_clear_to_color(al_map_rgb(255, 255, 255)); al_convert_mask_to_alpha(this->pImage, al_map_rgb(255, 255, 255)); al_draw_bitmap_region(this->sprite, this->dimensions.x, this->dimensions.y, this->dimensions.width, this->dimensions.height, 0, 0, 0); } }
static int allua_Bitmap_convert_mask_to_alpha(lua_State * L) { ALLUA_bitmap bitmap = allua_check_bitmap(L, 1); ALLUA_color color = allua_check_color(L, 2); al_convert_mask_to_alpha(bitmap, color); return 0; }
void init_ship_sprite(struct ship_sprite *sprite) { sprite->image = al_load_bitmap("spaceship_spritesheet.png"); al_convert_mask_to_alpha(sprite->image, al_map_rgb(255, 0, 255)); sprite->frame_width = 41; sprite->frame_height = 43; sprite->dir_horizontal = CENTER; sprite->dir_vertical = NEUTRAL; }
void animation::add_frame(ALLEGRO_BITMAP *frame) { if (frame == NULL) return; //take a pixel from background color and use it as transparency pixel al_convert_mask_to_alpha(frame, al_get_pixel(frame, 0, 0)); //add frame to collection frames.push_back(frame); }
static mrb_value convert_mask_to_alpha(mrb_state *mrb, mrb_value self) { ALLEGRO_BITMAP *b; ALLEGRO_COLOR *c; Check_Destroyed(mrb, self, bitmap, b); mrb_get_args(mrb, "d", &c, &mrbal_color_data_type); al_convert_mask_to_alpha(b, *c); return mrb_nil_value(); }
Item::Item(const char* imageToSet, const char* nameToSet, const char* examineToSet, const char* typeToSet, int offenceModifierToSet, int healingPotentialToSet) { image = al_load_bitmap(imageToSet); al_convert_mask_to_alpha(image, al_map_rgb(255, 0, 255)); name = nameToSet; examine = examineToSet; type = typeToSet; offenceModifier = offenceModifierToSet; healingPotential = healingPotentialToSet; }
// Method To Initialize The GameObject void InitObject(ALLEGRO_BITMAP *image, float X, float Y, int type) { this->image = image; this->X = X; this->Y = Y; this->type = type; al_convert_mask_to_alpha(this->image, al_map_rgb(255, 0, 255)); BoxWidth = al_get_bitmap_width(image); BoxHeight = al_get_bitmap_height(image); }
ALLEGRO_BITMAP* load_bitmap_withWarning(const char* path){ ALLEGRO_BITMAP* img = 0; img = al_load_bitmap(path); if(!img){ DisplayErr("Cannot load image: %s", path); exit(0); } al_convert_mask_to_alpha(img, al_map_rgb(255, 0, 255)); return img; }
void animation::add_frame(frame* f) { if (f == NULL) return; if (f->bb == NULL) return; if (f->image == NULL) return; //take a pixel from background color and use it as transparency pixel al_convert_mask_to_alpha(f->image, al_get_pixel(f->image, 0, 0)); //add frame to collection frames.push_back(f); }
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); } } }
ALLEGRO_BITMAP* Image :: open (char *path, float r, float g, float b) { image = al_load_bitmap (path); if (image == NULL) { std::cout << "Erro ao abrir imagem: " << path; exit (-1); } al_convert_mask_to_alpha (image, al_map_rgb (r, g, b)); return (image); }
ALLEGRO_BITMAP* Image::open(char *path, ALLEGRO_COLOR ignoreColor) { image = al_load_bitmap(path); al_convert_mask_to_alpha(image, ignoreColor); if (image == NULL) { std::cout << "Erro ao abrir imagem: " << path; exit (-1); } return (image); }
int init_bitmaps_classic(Board *b){ ALLEGRO_BITMAP *test_bmp; int i,j; ALLEGRO_BITMAP *dispbuf = al_get_target_bitmap(); al_set_target_bitmap(NULL); // tile_file.bmp should be a bmp with 80x80 tiles, 10 rows of 8 tiles // the first row of tiles is ignored. Rows 2 to 9 are the game tiles // the last row should contain the extra symbols // b->clue_unit_space must be 0 if( !(test_bmp = al_load_bitmap("tile_file.bmp")) ){ fprintf(stderr, "Error loading tile_file.bmp.\n"); return -1; } ALLEGRO_COLOR trans = al_get_pixel (test_bmp, 2*80, 9*80 + 40); al_convert_mask_to_alpha(test_bmp, trans); for(i=0;i<8;i++){ for(j=0;j<8;j++){ // create basic bitmaps from big file basic_bmp[i][j] = al_create_bitmap(80, 80); al_set_target_bitmap(basic_bmp[i][j]); al_clear_to_color(NULL_COLOR); al_draw_bitmap_region(test_bmp, j*80, (i+1)*80, 80, 80, 0,0,0); } } // create symbols symbol_bmp[SYM_FORBIDDEN] = al_create_bitmap(80,80); al_set_target_bitmap(symbol_bmp[SYM_FORBIDDEN]); al_clear_to_color(NULL_COLOR); al_draw_bitmap_region(test_bmp, 80, 9*80, 80, 80, 0, 0, 0); symbol_bmp[SYM_SWAPPABLE] = al_create_bitmap(3*80, 80); al_set_target_bitmap(symbol_bmp[SYM_SWAPPABLE]); al_clear_to_color(NULL_COLOR); al_draw_bitmap_region(test_bmp, 2*80, 9*80, 3*80, 80, 0, 0,0); symbol_bmp[SYM_ONE_SIDE] = al_create_bitmap(80,80); al_set_target_bitmap(symbol_bmp[SYM_ONE_SIDE]); al_clear_to_color(NULL_COLOR); al_draw_bitmap_region(test_bmp, 5*80, 9*80, 80, 80, 0, 0, 0); symbol_bmp[SYM_ONLY_ONE] = al_create_bitmap(80, 3*80); al_set_target_bitmap(symbol_bmp[SYM_ONLY_ONE]); al_clear_to_color(NULL_COLOR); al_draw_bitmap_region(test_bmp, 6*80, 9*80, 80, 80, 0, 120, 0); al_set_target_bitmap(dispbuf); return 0; };
// Method To Initialize The CharacterObject void InitObject() { // Returns the width of the sprite sheet SpriteWidth = al_get_bitmap_width(image); // Returns the height of the sprite sheet SpriteHeight = al_get_bitmap_height(image); // Calculation to find out individual frame width F_W = SpriteWidth / NumbOfFrames; // Calculation to find out individual frame height F_H = SpriteHeight; // Makes the background of the sprite sheet transparent al_convert_mask_to_alpha(image, al_map_rgb(255, 0, 255)); }
void shal_convert_mask_to_alpha(ALLEGRO_BITMAP * bitmap, float mask_color_r, float mask_color_g, float mask_color_b, float mask_color_a) { ALLEGRO_COLOR mask_color; mask_color.r = mask_color_r; mask_color.g = mask_color_g; mask_color.b = mask_color_b; mask_color.a = mask_color_a; return al_convert_mask_to_alpha(bitmap, mask_color); }
void DrawShip(SpaceShip &ship, ALLEGRO_BITMAP * &image) { if (ship.lives <= 0) { ship.y = -100; } // Drawing the ship. else { al_convert_mask_to_alpha(image, al_map_rgb(255,255,255)); al_draw_bitmap(image, ship.x - al_get_bitmap_width(image)/2, ship.y - al_get_bitmap_height(image)/2, 0); } }
void KinectPlayer::Render() { // if (!mPlayerPresent) { // return; // } std::vector<UserData> users; mUserTracking.GetUsers(users); if (users.empty()) { return; } al_set_target_bitmap(mBitmap); al_clear_to_color(al_map_rgb(0x00, 0x00, 0x00)); al_convert_mask_to_alpha(mBitmap, al_map_rgb(0x00, 0x00, 0x00)); xn::SceneMetaData scene_meta; mUserTracking.GetUserPixels(users[0], scene_meta); const XnRGB24Pixel* pRgbBuf = mKinect.GetImageData(); const XnLabel* pLabelBuf = scene_meta.Data(); ALLEGRO_LOCKED_REGION* lock = al_lock_bitmap(mBitmap, al_get_bitmap_format(mBitmap), ALLEGRO_LOCK_WRITEONLY); al_set_target_bitmap(mBitmap); for (int y = 0; y < mBitmapHeight; y++) { for (int x = 0; x < mBitmapWidth; x++, pLabelBuf++, pRgbBuf++) { if (*pLabelBuf == users[0].GetId()) { al_put_pixel(x, y, al_map_rgb(pRgbBuf->nRed, pRgbBuf->nGreen, pRgbBuf->nBlue)); } } } al_unlock_bitmap(mBitmap); const int screen_x_res = al_get_display_width(al_get_current_display()); const int screen_y_res = al_get_display_height(al_get_current_display()); al_set_target_bitmap(al_get_backbuffer(al_get_current_display())); al_draw_scaled_bitmap(mBitmap, 0, 0, mBitmapWidth, mBitmapHeight, GetXPos(), GetYPos(), GetWidth(), GetHeight(), 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; }
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(); }
SpriteSeq SpriteUtil::process(const char * filename, ALLEGRO_COLOR delimiterColor) { #ifndef _AL_INIT_IMAGE_ADDON #define _AL_INIT_IMAGE_ADDON al_init_image_addon(); #endif ALLEGRO_BITMAP *bitmap = al_load_bitmap(filename); SpriteSeq spriteSeq(bitmap, 0, 0); ALLEGRO_COLOR pixel, lastPixel; int lastSource = 0; for(int i = 0; i <al_get_bitmap_width(bitmap); i++) { pixel = al_get_pixel(bitmap, i, 0); if (memcmp(&pixel, &lastPixel, sizeof(ALLEGRO_COLOR))) { if (!memcmp(&pixel, &delimiterColor, sizeof(ALLEGRO_COLOR))) { i++; // current pixel is the red one, so, advance to next pixel if (spriteSeq.empty()) { spriteSeq.add(Sprite(bitmap, 0, 0, i, al_get_bitmap_height(bitmap))); } else { spriteSeq.add(Sprite(bitmap, lastSource, 0, i - lastSource, al_get_bitmap_height(bitmap))); } lastSource = i; } } else if(i == al_get_bitmap_width(bitmap) - 1) { spriteSeq.add(Sprite(bitmap, lastSource, 0, i - lastSource, al_get_bitmap_height(bitmap))); } lastPixel = pixel; } al_convert_mask_to_alpha(bitmap, al_map_rgba(255, 0, 0, 255)); return spriteSeq; }
void Bullet::initBullet(Bullet bullets[], int size) { shot = al_load_bitmap("assets\\Shot.bmp"); shotW = al_get_bitmap_width(shot); shotH = al_get_bitmap_height(shot); al_convert_mask_to_alpha(shot, al_map_rgb(255,255,255)); int i; for(i = 0; i < size; i++) { bullets[i].speed = 15; bullets[i].ID = BULLET; bullets[i].live = false; bullets[i].boundX = 7; bullets[i].boundY = 5; } }
// TODO: If you wrap the image objs in a class, they can take care of bad loads on their own! ImageManager::ImageManager() { characterAyne = al_load_bitmap( "../_gfx/AyneMagenta.bmp" ); if ( characterAyne == NULL ) { std::cout << "Error loading image AyneMagenta.bmp" << std::endl; } environmentTileset = al_load_bitmap( "../_gfx/TilesetMagenta.bmp" ); if ( environmentTileset == NULL ) { std::cout << "Error loading image TilesetMagenta.bmp" << std::endl; } al_convert_mask_to_alpha( characterAyne, al_map_rgb( 255, 0, 255 ) ); // Turn magetna transparent }
BolsaDinero * BolsaDinero::crear_bolsa_dinero(ActorManager *actmgr,int mov_to_dead) { ALLEGRO_BITMAP *bmp; MapaDeBits *bitm; BolsaDinero *bolsa_dinero_tmp; ALLEGRO_PATH *path; /* * para crear path relativos y poder distribuir el programa y ejecutarlo * fuera del IDE */ path = al_get_standard_path(ALLEGRO_RESOURCES_PATH); al_remove_path_component(path,-1); al_append_path_component(path, "resources"); al_set_path_filename(path, "bolsa-dinero.png"); bolsa_dinero_tmp = new BolsaDinero(actmgr,mov_to_dead); bmp = al_load_bitmap(al_path_cstr(path, '/')); if(bmp == NULL) { al_show_native_message_box(al_get_current_display(), "Ventana de error", "error fatal", "Error al cargar resource bitmap", NULL, ALLEGRO_MESSAGEBOX_ERROR); exit(-1); } // Hacemos que no se vea el color negro en el bitmap de rana al_convert_mask_to_alpha(bmp, al_map_rgb(0,0,0)); bitm=new MapaDeBits(bolsa_dinero_tmp, bmp); bolsa_dinero_tmp->set_actor_graphic(bitm); bolsa_dinero_tmp->set_x(Game::rnd(0,Game::gfx_w-bolsa_dinero_tmp->get_w())); bolsa_dinero_tmp->set_y(Game::rnd(50,Game::gfx_h-bolsa_dinero_tmp->get_h())); bolsa_dinero_tmp->set_is_detected(true); bolsa_dinero_tmp->set_team(TEAM_BOLSA_DINERO); bolsa_dinero_tmp->set_collision_method(CollisionManager::PP_COLLISION); actmgr->add(bolsa_dinero_tmp); al_destroy_path(path); return bolsa_dinero_tmp; }
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; }