int draw_classic_symbols(Game *g, Board *b) { // create symbols b->symbol_bmp[SYM_FORBIDDEN] = al_create_bitmap(b->clue_unit_size, b->clue_unit_size); b->symbol_bmp[SYM_SWAPPABLE] = al_create_bitmap(3*b->clue_unit_size + 2*b->clue_unit_space, b->clue_unit_size); b->symbol_bmp[SYM_ONE_SIDE] = al_create_bitmap(b->clue_unit_size, b->clue_unit_size); b->symbol_bmp[SYM_ONLY_ONE] = al_create_bitmap(b->clue_unit_size, 3*b->clue_unit_size + 2*b->clue_unit_space); if( (!b->symbol_bmp[SYM_FORBIDDEN]) || (!b->symbol_bmp[SYM_SWAPPABLE]) || (!b->symbol_bmp[SYM_ONE_SIDE]) || (!b->symbol_bmp[SYM_ONLY_ONE])){ fprintf(stderr, "Error creating bitmap.\n"); return -1; } al_set_target_bitmap(b->symbol_bmp[SYM_FORBIDDEN]); al_clear_to_color(NULL_COLOR); al_draw_scaled_bitmap(symbol_bmp[SYM_FORBIDDEN], 0, 0, 80, 80, 0,0,b->clue_unit_size, b->clue_unit_size, 0); al_set_target_bitmap(b->symbol_bmp[SYM_SWAPPABLE]); al_clear_to_color(NULL_COLOR); al_draw_scaled_bitmap(symbol_bmp[SYM_SWAPPABLE], 0, 0, 3*80, 80, 0,0,3*b->clue_unit_size, b->clue_unit_size, 0); al_set_target_bitmap(b->symbol_bmp[SYM_ONE_SIDE]); al_clear_to_color(NULL_COLOR); al_draw_scaled_bitmap(symbol_bmp[SYM_ONE_SIDE], 0, 0, 80, 80, 0,0,b->clue_unit_size, b->clue_unit_size, 0); al_set_target_bitmap(b->symbol_bmp[SYM_ONLY_ONE]); al_clear_to_color(NULL_COLOR); al_draw_scaled_bitmap(symbol_bmp[SYM_ONLY_ONE], 0, 0, 80, 3*80, 0,0,b->clue_unit_size, 3*b->clue_unit_size, 0); return 0; }
void ChooseMap<al_b,al_f>::showSection(InputManager<ALLEGRO_EVENT,ALLEGRO_KEYBOARD_STATE> &input,Maps<al_b> &m,Player<al_b> &p,bool st){ m.showBackground(); al_draw_text(this->_font30, al_map_rgb(0,0,0), 335, 130, 0, "Escoge un mapa"); for(int i = 0;i < 3;i++){ m.loadMap(3,i); for(int y = 0; y<m.getHeight();y++){ for(int x = 0;x<m.getWidth();x++){ //al_draw_filled_rectangle(80+(250*i)+(12*x), 200+(12*y), 80+(250*i)+((12*x) +12), 200+((12*y )+12), al_map_rgb(255,255,255)); switch(m.getPositionMap(x,y)){ case 'p': al_draw_scaled_bitmap(this->_block, 145, 171, 58, 58, 80+(250*i)+(12*x), 200+(12*y), 12, 12, 0); break; case 'j': case 'g': case 'e': al_draw_filled_rectangle(80+(250*i)+(12*x), 200+(12*y), 80+(250*i)+((12*x) +12), 200+((12*y )+12), al_map_rgb(255,255,255)); break; case 'c': al_draw_scaled_bitmap(this->_block, 258, 20, 58, 58, 80+(250*i)+(12*x), 200+(12*y), 12, 12, 0); break; case 'd': al_draw_scaled_bitmap(this->_block, 37, 20, 58, 58, 80+(250*i)+(12*x), 200+(12*y), 12, 12, 0); break; case 's': al_draw_filled_rectangle(80+(250*i)+(12*x), 200+(12*y), 80+(250*i)+((12*x) +12), 200+((12*y )+12), al_map_rgb(236,236,236)); break; } } } } m.setLevel(input.getX(0)); al_draw_rectangle(80+(250*input.getX(0)), 200, 320+(250*input.getX(0)), 370, al_map_rgb(140,40,40),5); al_draw_filled_rectangle(360, 385, 540, 430, al_map_rgb(20,20,20)); al_draw_text(this->_font20, al_map_rgb(255,255,255), 395, 390, 0, "Seleccionar"); }
void Blitter::commit(void) { al_set_target_bitmap(scale_buffer); al_draw_scaled_bitmap(main_buffer,0,0, BUFFER_WIDTH, BUFFER_HEIGHT,0,0, BUFFER_WIDTH*PRESCALE, BUFFER_HEIGHT*PRESCALE,0); al_set_target_backbuffer(display); al_clear_to_color(al_map_rgb(0,0,0)); int adjusted_width = display_width; int adjusted_height = display_height; // determine scaling information to preserve aspect ratio if (display_width > display_height * (4.0 / 3.0)) { adjusted_width = display_height * (4.0 / 3.0); } else if (display_height > display_width * 0.75) { adjusted_height = display_width * 0.75; } al_draw_scaled_bitmap(scale_buffer,0,0, BUFFER_WIDTH*PRESCALE, BUFFER_HEIGHT*PRESCALE, (display_width - adjusted_width) / 2, (display_height - adjusted_height) / 2, adjusted_width, adjusted_height,0); al_flip_display(); al_set_target_bitmap(main_buffer); al_clear_to_color(al_map_rgb(0,0,0)); }
void button_draw(button *b) { int bitmap_width, bitmap_height, text_width; double sx, sy; // draw the button bitmap if (b->is_pressed) { bitmap_width = al_get_bitmap_width(b->pressed_bitmap); bitmap_height = al_get_bitmap_height(b->pressed_bitmap); al_draw_scaled_bitmap(b->pressed_bitmap, 0, 0, bitmap_width, bitmap_height, b->sx, b->sy, b->width, b->height, 0); } else if (b->is_hovered) { bitmap_width = al_get_bitmap_width(b->hover_bitmap); bitmap_height = al_get_bitmap_height(b->hover_bitmap); al_draw_scaled_bitmap(b->hover_bitmap, 0, 0, bitmap_width, bitmap_height, b->sx, b->sy, b->width, b->height, 0); } else { bitmap_width = al_get_bitmap_width(b->release_bitmap); bitmap_height = al_get_bitmap_height(b->release_bitmap); al_draw_scaled_bitmap(b->release_bitmap, 0, 0, bitmap_width, bitmap_height, b->sx, b->sy, b->width, b->height, 0); } if (b->with_text) { text_width = al_get_text_width(b->text_font, b->text); sx = (b->width - text_width) / 2.0 + b->sx; sy = (b->height * (1 - TEXT_SIZE_SCALE)) / 2.0 + b->sy; al_draw_text(b->text_font, b->text_color, sx, sy, 0, b->text); } }
void _al_win_set_display_icon(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bmp) { ALLEGRO_BITMAP *sm_bmp, *big_bmp; HICON sm_icon, big_icon, old_small, old_big; ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *)display; ALLEGRO_STATE backup; int sm_w, sm_h, big_w, big_h; al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); sm_w = GetSystemMetrics(SM_CXSMICON); sm_h = GetSystemMetrics(SM_CYSMICON); big_w = GetSystemMetrics(SM_CXICON); big_h = GetSystemMetrics(SM_CYICON); sm_bmp = al_create_bitmap(sm_w, sm_h); al_set_target_bitmap(sm_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_scaled_bitmap(bmp, 0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, 0, sm_w, sm_h, 0); big_bmp = al_create_bitmap(big_w, big_h); al_set_target_bitmap(big_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_scaled_bitmap(bmp, 0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, 0, big_w, big_h, 0); al_restore_state(&backup); sm_icon = _al_win_create_icon(win_display->window, sm_bmp, 0, 0, false, false); big_icon = _al_win_create_icon(win_display->window, big_bmp, 0, 0, false, false); old_small = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_SMALL, (LPARAM)sm_icon); old_big = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_BIG, (LPARAM)big_icon); if (old_small) DestroyIcon(old_small); if (old_big) DestroyIcon(old_big); al_destroy_bitmap(sm_bmp); al_destroy_bitmap(big_bmp); }
static duk_ret_t js_Font_drawZoomedText(duk_context* ctx) { int x = duk_require_int(ctx, 0); int y = duk_require_int(ctx, 1); float scale = duk_require_number(ctx, 2); const char* text = duk_to_string(ctx, 3); ALLEGRO_BITMAP* bitmap; font_t* font; color_t mask; int text_w, text_h; duk_push_this(ctx); font = duk_require_sphere_obj(ctx, -1, "Font"); duk_get_prop_string(ctx, -1, "\xFF" "color_mask"); mask = duk_require_sphere_color(ctx, -1); duk_pop(ctx); duk_pop(ctx); if (!screen_is_skipframe(g_screen)) { text_w = get_text_width(font, text); text_h = get_font_line_height(font); bitmap = al_create_bitmap(text_w, text_h); al_set_target_bitmap(bitmap); draw_text(font, mask, 0, 0, TEXT_ALIGN_LEFT, text); al_set_target_backbuffer(screen_display(g_screen)); al_draw_scaled_bitmap(bitmap, 0, 0, text_w, text_h, x, y, text_w * scale, text_h * scale, 0x0); al_destroy_bitmap(bitmap); } return 0; }
void IntroStage::Render() { bkgImg = Framework::SystemFramework->GetImageManager()->GetImage( "resource/background.png" ); logoImg = Framework::SystemFramework->GetImageManager()->GetImage( "resource/tournamenthubintro.png" ); titleImg = Framework::SystemFramework->GetImageManager()->GetImage( "resource/tournamenthubtitle.png" ); int fontSize = min(Framework::SystemFramework->GetDisplayHeight() / 10, Framework::SystemFramework->GetDisplayWidth() / 22); if( bordersDelta < 0 ) { al_clear_to_color( al_map_rgb( 0, 0, 0 ) ); } else { al_clear_to_color( al_map_rgb( 22, 22, 22 ) ); } if( bordersDelta < 0 && bkgImg != 0 ) { al_draw_scaled_bitmap( bkgImg, 0, 0, al_get_bitmap_width( bkgImg ), al_get_bitmap_height( bkgImg ), 0, 0, Framework::SystemFramework->GetDisplayWidth(), Framework::SystemFramework->GetDisplayHeight(), 0 ); } if( platformImg != 0 ) { al_draw_bitmap( platformImg, (Framework::SystemFramework->GetDisplayWidth() / 2) - (al_get_bitmap_width(platformImg) / 2), (Framework::SystemFramework->GetDisplayHeight() / 2) - (al_get_bitmap_height(platformImg) / 2), 0 ); } if( borders > 0 ) { al_draw_filled_rectangle( 0, 0, Framework::SystemFramework->GetDisplayWidth(), borders - 2, al_map_rgb( 128, 128, 128 ) ); al_draw_filled_rectangle( 0, borders - 2, Framework::SystemFramework->GetDisplayWidth(), borders, al_map_rgb( 64, 64, 64 ) ); al_draw_filled_rectangle( 0, Framework::SystemFramework->GetDisplayHeight() - borders + 2, Framework::SystemFramework->GetDisplayWidth(), Framework::SystemFramework->GetDisplayHeight(), al_map_rgb( 128, 128, 128 ) ); al_draw_filled_rectangle( 0, Framework::SystemFramework->GetDisplayHeight() - borders, Framework::SystemFramework->GetDisplayWidth(), Framework::SystemFramework->GetDisplayHeight() - borders + 2, al_map_rgb( 255, 255, 255 ) ); al_draw_bitmap( logoImg, (Framework::SystemFramework->GetDisplayWidth() / 2) - (al_get_bitmap_width(logoImg) / 2), borders - al_get_bitmap_height(logoImg) - 8, 0 ); al_draw_bitmap( titleImg, (Framework::SystemFramework->GetDisplayWidth() / 2) - (al_get_bitmap_width(titleImg) / 2), Framework::SystemFramework->GetDisplayHeight() - borders + 8, 0 ); } }
void Wall::draw() { for (int i = box->left; i < box->right; i += scaledWidth) { for (int j = y; j < y + height; j += scaledHeight) { al_draw_scaled_bitmap(image, 0, 0, imageWidth, imageHeight, i, j, scaledWidth, scaledHeight, 0); } } }
void c_minimap::reload(void) { ALLEGRO_BITMAP * backup = al_get_target_bitmap(); if(minimap_bitmap) al_destroy_bitmap(minimap_bitmap); minimap_bitmap = al_create_bitmap(user_config.minimap_size,user_config.minimap_size); if(!map_list.biome_map) return; int bigsize = al_get_bitmap_width(map_list.biome_map); if (bigsize < al_get_bitmap_height(map_list.biome_map)) bigsize = al_get_bitmap_height(map_list.biome_map); scale = (double)user_config.minimap_size / (double)bigsize; al_set_target_bitmap(minimap_bitmap); al_draw_scaled_bitmap(map_list.biome_map, 0, 0, al_get_bitmap_width(map_list.biome_map), al_get_bitmap_height(map_list.biome_map), 0, 0, al_get_bitmap_width(map_list.biome_map)* scale, al_get_bitmap_height(map_list.biome_map) * scale, 0); al_set_target_bitmap(backup); }
void draw_billiard_balls(billiard_ball *balls) { int i; const double sx = 0; const double sy = 0; const double dw = 2 * BALL_RADIUS; const double dh = 2 * BALL_RADIUS; double sw, sh, dx, dy; /* DEBUG */ #ifdef DEBUG if(balls == NULL) { perror("billiard_ball null pointer"); return; } for(i = 0 ; i < BALL_COUNT ; i ++) al_draw_filled_circle(balls[i].cx, balls[i].cy, BALL_RADIUS, balls[i].color); #endif for(i = 0 ; i < BALL_COUNT ; i ++) { if(!balls[i].is_on_table) continue; sw = balls[i].bitmap_sw; sh = balls[i].bitmap_sh; dx = balls[i].cx - BALL_RADIUS; dy = balls[i].cy - BALL_RADIUS; al_draw_scaled_bitmap(balls[i].bitmap, sx, sy, sw, sh, dx, dy, dw, dh, 0); } }
static void Skins_Background_Draw_StretchInteger(ALLEGRO_BITMAP *bmp) { int size_x; int size_y; int factor = 0; // Find best fit factor const int w = al_get_bitmap_width(bmp); const int h = al_get_bitmap_height(bmp); do { factor += 1; size_x = (gui.info.screen.x - w * factor) / 2; size_y = (gui.info.screen.y - 2 * (gui.info.bars_height + 2) - h * factor) / 2; } while (size_x >= 0 && size_y >= 0); factor -= 1; // Draw grid Skins_Background_Redraw_Grid(); if (factor == 0) { Msg(MSGT_USER, "%s", Msg_Get(MSG_Theme_Error_BG_Big)); return; } { int sx = (gui.info.screen.x - w * factor) / 2; int sy = (gui.info.screen.y - 2 * (gui.info.bars_height + 2) - h * factor) / 2; sy += gui.info.bars_height + 2; al_draw_scaled_bitmap(bmp, 0, 0, w, h, sx, sy, w * factor, h * factor, 0x0000); } }
void Image::print() { ALLEGRO_DISPLAY *display = al_get_current_display(); switch (mode) { case IMAGE_MODE_DEFAULT: al_draw_bitmap(image, x, y, flag); break; case IMAGE_MODE_FULLSCREEN: al_draw_scaled_bitmap( image, 0, 0, al_get_bitmap_width(image), al_get_bitmap_height(image), 0, 0, al_get_display_width(display), al_get_display_height(display), flag); break; case IMAGE_MODE_REGION: //al_convert_mask_to_alpha(image, al_map_rgb(255,0,255)); al_draw_bitmap_region( image, region_x, region_y, region_w, region_h, x, y, flag); break; } }
void RenderTarget::resize(int32_t w, int32_t h) { ALLEGRO_BITMAP *newBitmap = al_create_bitmap(w, h); // Check if we have changed Smooth2D in between creating this rendertarget // and calling this function. If so, we need to clone this bitmap, because // bitmap resize operation flags have changed. ALLEGRO_BITMAP *bitmapToDrawResized; int bmFlags = al_get_bitmap_flags(this->bitmap); int32_t origW = this->width(); int32_t origH = this->height(); bool smooth2d = CBEnchanted::instance()->isSmooth2D(); if ((!smooth2d && (bmFlags & ALLEGRO_MAG_LINEAR) == ALLEGRO_MAG_LINEAR) || (smooth2d && (bmFlags & ALLEGRO_MAG_LINEAR) != ALLEGRO_MAG_LINEAR)) { // We need to clone. bitmapToDrawResized = al_clone_bitmap(this->bitmap); al_destroy_bitmap(this->bitmap); } else { // Phew, no need to clone. bitmapToDrawResized = this->bitmap; } al_set_target_bitmap(newBitmap); al_clear_to_color(al_map_rgb(0, 0, 0)); int32_t a, b, c; al_get_blender(&a, &b, &c); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_draw_scaled_bitmap(bitmapToDrawResized, 0, 0, origW, origH, 0, 0, w, h, 0); al_set_blender(a, b, c); al_destroy_bitmap(bitmapToDrawResized); this->bitmap = newBitmap; bindRenderTarget = this; }
void desenha_lives (Hud *hud){ int linha_vidas = 0; int coluna_vidas = 0; al_draw_text(hud->font, CINZA, hud->lives_posicao_x, hud->posicao_y, 0, "LIVES:"); for (int i = 0; i < hud->lives; i++) { if (hud->lives_posicao_x + (LARGURA_DISPLAY/12)*1.5 + hud->largura_bitmap_vida*1.25*(coluna_vidas) > LARGURA_DISPLAY - hud->largura_bitmap_vida) { linha_vidas++; coluna_vidas = 0; } al_draw_scaled_bitmap(hud->life, 0, 0, al_get_bitmap_width(hud->life), al_get_bitmap_height(hud->life), hud->lives_posicao_x + (LARGURA_DISPLAY/12)*1.5 + hud->largura_bitmap_vida*1.25*(coluna_vidas), hud->posicao_y + linha_vidas*(hud->altura_bitmap_vida*1.25), hud->largura_bitmap_vida, hud->altura_bitmap_vida, 0); coluna_vidas++; } }
void desenha_mothership (Mothership *mothership) { if (autoriza_mothership(mothership) || mothership->ativo) { al_draw_scaled_bitmap(mothership->bitmap, 0, 0, al_get_bitmap_width(mothership->bitmap), al_get_bitmap_height(mothership->bitmap), mothership->posicao_x, mothership->posicao_y, mothership->largura, mothership->altura, 0); if (mothership->direcao == DIREITA && mothership->posicao_x > LARGURA_DISPLAY) { reinicia_mothership (mothership); return; } if (mothership->direcao == ESQUERDA && mothership->posicao_x < 0) { reinicia_mothership (mothership); return; } movimenta_mothership (mothership); } }
void _al_win_set_display_icon(ALLEGRO_DISPLAY *display, ALLEGRO_BITMAP *bmp) { ALLEGRO_BITMAP *scaled_bmp; HICON icon, old_small, old_big; ALLEGRO_DISPLAY_WIN *win_display = (ALLEGRO_DISPLAY_WIN *)display; ALLEGRO_STATE backup; al_store_state(&backup, ALLEGRO_STATE_BITMAP | ALLEGRO_STATE_BLENDER); al_set_new_bitmap_flags(ALLEGRO_MEMORY_BITMAP); al_set_new_bitmap_format(ALLEGRO_PIXEL_FORMAT_ARGB_8888); scaled_bmp = al_create_bitmap(32, 32); al_set_target_bitmap(scaled_bmp); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO, al_map_rgb(255, 255, 255)); al_draw_scaled_bitmap(bmp, 0, 0, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, 0, 32, 32, 0); al_restore_state(&backup); icon = _al_win_create_icon(win_display->window, scaled_bmp, 0, 0, false); old_small = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_SMALL, (LPARAM)icon); old_big = (HICON)SendMessage(win_display->window, WM_SETICON, ICON_BIG, (LPARAM)icon); if (old_small) DestroyIcon(old_small); if (old_big) DestroyIcon(old_big); al_destroy_bitmap(scaled_bmp); }
//==================================================== DRAW_MENU ========================================================// void Menu_Draw(struct Game *game) { //RYSOWANIE TŁA Z MENU// al_draw_bitmap(game->menu.menu_bitmap,0,0,0); al_set_target_bitmap(al_get_backbuffer(game->display)); al_draw_bitmap_region(game->menu.mills, 0,game->menu.mills_y, 82,85, 799,485, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,0, 231,64, game->menu.cldpos1*1.2+300,0, 231,64, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,64, 213,44, game->menu.cldpos1+53,95, 213,44, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,108, 245,54, game->menu.cldpos1*1.5+723,24, 245,54, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,162, 190,41, game->menu.cldpos1*0.8+665,138, 190,41, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,0, 231,64, game->menu.cldpos2+475,175, 231*0.7,64*0.7, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,64, 213,44, game->menu.cldpos2*1.15+250,70, 213*0.9,44*0.9, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,108, 245,54, game->menu.cldpos2*1.1+22,220, 245*0.8,54*0.8, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,162, 190,41, game->menu.cldpos3+885,275, 190*0.7,41*0.7, 0); al_draw_scaled_bitmap(game->menu.cloud, 0,64, 213,44, game->menu.cldpos3*0.7+520,290, 213*0.4,44*0.4, 0); al_draw_bitmap(game->menu.smok,0,95,0); //PRZYCISKI// if(game->gamestate==0){ al_draw_bitmap_region(game->menu.buttons, 0,0, 195,43, 635,41, 0); //new game if(game->play.dragon_lives>0) al_draw_bitmap_region(game->menu.buttons, 0,43, 195,43, 635,119, 0); //resume game else al_draw_bitmap_region(game->menu.buttons, 0,215, 195,43, 635,119, 0); //resume game przygaszony al_draw_bitmap_region(game->menu.buttons, 0,86, 195,43, 635,197, 0); //options al_draw_bitmap_region(game->menu.buttons, 0,129, 195,43, 635,275, 0); //quit } //WYNIKI I INSTRUKCJA GRY// if(game->gamestate==2){ al_draw_bitmap_region(game->menu.buttons, 195,0, 132,211, 698,41, 0); //tablica wyników al_draw_bitmap_region(game->menu.buttons, 0,258, 498,211, 118,41, 0); //tablica informacji o grze al_draw_bitmap_region(game->menu.buttons, 0,172, 195,43, 635,275, 0); //przycisk 'menu' al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,84, ALLEGRO_ALIGN_LEFT, "1. %i", game->table[0]); // stara poprawiona wysokość = 77 i co 20 al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,104, ALLEGRO_ALIGN_LEFT, "2. %i", game->table[1]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,124, ALLEGRO_ALIGN_LEFT, "3. %i", game->table[2]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,144, ALLEGRO_ALIGN_LEFT, "4. %i", game->table[3]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,164, ALLEGRO_ALIGN_LEFT, "5. %i", game->table[4]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,184, ALLEGRO_ALIGN_LEFT, "6. %i", game->table[5]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,204, ALLEGRO_ALIGN_LEFT, "7. %i", game->table[6]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 737,224, ALLEGRO_ALIGN_LEFT, "8. %i", game->table[7]); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,61, ALLEGRO_ALIGN_LEFT, "Press or to move up and or to move down."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,81, ALLEGRO_ALIGN_LEFT, "Press or right click mouse to fire a fiery bullet!"); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,101, ALLEGRO_ALIGN_LEFT, "To pause game or enter menu press ."); //al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,121, ALLEGRO_ALIGN_LEFT, ""); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,141, ALLEGRO_ALIGN_LEFT, "You've got three lives."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,161, ALLEGRO_ALIGN_LEFT, "Avoid thrown pitchforks - they will kill you!"); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,181, ALLEGRO_ALIGN_LEFT, "Flying into a cloud of flour disables you for a while."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,201, ALLEGRO_ALIGN_LEFT, "Do not fly too low - you will fall and die."); al_draw_textf(game->sfont, al_map_rgb(70,64,58), 138,221, ALLEGRO_ALIGN_LEFT, "Shepherd boys fire exploding sheep defragmentators!"); } //BITMAPA KURSORA// al_draw_bitmap(game->menu.cursor,game->pos_x, game->pos_y, 0); }
static void Skins_Background_Draw_Stretch(ALLEGRO_BITMAP *bmp) { al_draw_scaled_bitmap(bmp, 0.0f, 0.0f, al_get_bitmap_width(bmp), al_get_bitmap_height(bmp), 0, gui.info.bars_height + 2, gui.info.screen.x, gui.info.screen.y - 2 * (gui.info.bars_height + 2), 0); }
void m_draw_scaled_target(MBITMAP *src, int sx, int sy, int sw, int sh, int dx, int dy, int dw, int dh, MBITMAP *dst) { ALLEGRO_BITMAP *old_target = al_get_target_bitmap(); m_set_target_bitmap(dst); al_draw_scaled_bitmap(src->bitmap, sx, sy, sw, sh, dx, dy, dw, dh, 0); al_set_target_bitmap(old_target); }
void DrawAnimation(const Animation* const animation) { int fx = (animation->cur_frame % animation->animation_columns) * animation->frame_source_size.w; int fy = (animation->cur_frame / animation->animation_columns) * animation->frame_source_size.h; al_draw_scaled_bitmap(animation->bitmap, fx, fy, animation->frame_source_size.w, animation->frame_source_size.h, animation->pos.x, animation->pos.y, animation->frame_dest_size.w, animation->frame_dest_size.h, 0); }
void Ad_Camera::present_to_display() { auto width = al_get_bitmap_width(display_buffer); auto height = al_get_bitmap_height(display_buffer); al_set_target_bitmap(al_get_backbuffer(ad_display)); al_draw_scaled_bitmap(display_buffer, 0, 0, width, height, 0, 0, ad_get_screen_width(), ad_get_screen_height(), 0); }
int do_gui(const std::vector<Widget *>& widgets, unsigned int selected) { ResourceManager& rm = ResourceManager::getInstance(); ALLEGRO_BITMAP *bg = (ALLEGRO_BITMAP *)rm.getData(RES_BACKGROUND); Input *input = (Input *)rm.getData(RES_INPUT); ALLEGRO_BITMAP *logo = (ALLEGRO_BITMAP *)rm.getData(RES_LOGO); int lw = al_get_bitmap_width(logo); int lh = al_get_bitmap_height(logo); ALLEGRO_FONT *myfont = (ALLEGRO_FONT *)rm.getData(RES_SMALLFONT); bool redraw = true; for (;;) { input->poll(); float ud = input->ud(); if (ud < 0 && selected) { selected--; my_play_sample(RES_FIRELARGE); al_rest(0.200); redraw = true; } else if (ud > 0 && selected < (widgets.size()-1)) { selected++; my_play_sample(RES_FIRELARGE); al_rest(0.200); redraw = true; } if (input->b1()) { if (!widgets[selected]->activate()) return selected; } if (input->esc()) return -1; if (!redraw) { al_rest(0.010); continue; } /* draw */ al_draw_scaled_bitmap(bg, 0, 0, al_get_bitmap_width(bg), al_get_bitmap_height(bg), 0, 0, BB_W, BB_H, 0); al_draw_bitmap(logo, (BB_W-lw)/2, (BB_H-lh)/4, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); al_draw_textf(myfont, al_map_rgb(255, 255, 0), BB_W/2, BB_H/2, ALLEGRO_ALIGN_CENTRE, "z/y to start"); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); for (unsigned int i = 0; i < widgets.size(); i++) { widgets[i]->render(i == selected); } al_flip_display(); redraw = false; } }
void Draw::menu(int menu, int selection, int WIDTH, int HEIGHT, int FPS, int Volume, float Pan){ al_draw_scaled_bitmap(menubg, 0, 0, this->menubgW, this->menubgH, 0, 0, this->WIDTH, this->HEIGHT, NULL); string text1 = ""; string text2 = ""; string text3 = ""; switch(menu){ case(1):{ text1 = "Play game"; text2 = "Settings"; text3 = "Quit"; break; } case(2):{ text1 = "Graphics"; text2 = "Audio"; text3 = "Back"; break; } case(3):{ text1 = "Resolution: " + to_string(WIDTH) + "X" + to_string(HEIGHT); text2 = "FPS: " + to_string(FPS); text3 = "Back"; break; } case(4):{ text1 = "Volume: " + to_string(Volume); text2 = "Pan: " + round(Pan); text3 = "Back"; break; } } const char* text1C = text1.c_str(); const char* text2C = text2.c_str(); const char* text3C = text3.c_str(); al_draw_text(font18, al_map_rgb(255, 0, 0), this->WIDTH/2, this->HEIGHT/8*3, ALLEGRO_ALIGN_CENTER, text1C); al_draw_text(font18, al_map_rgb(255, 0, 0), this->WIDTH/2, this->HEIGHT/8*4, ALLEGRO_ALIGN_CENTER, text2C); al_draw_text(font18, al_map_rgb(255, 0, 0), this->WIDTH/2, this->HEIGHT/8*5, ALLEGRO_ALIGN_CENTER, text3C); switch(selection){ case(1):{ al_draw_scaled_bitmap(msel, 0, 0, this->selectorW, this->selectorH, this->WIDTH/2 + (al_get_text_width(font18,text1C)/2), this->HEIGHT/8*3 -14, 40, 50, NULL); al_draw_scaled_bitmap(msel, 0, 0, this->selectorW, this->selectorH, this->WIDTH/2 - (al_get_text_width(font18,text1C)/2) - (playerWidth()/2.7), this->HEIGHT/8*3 -14, 40, 50, ALLEGRO_FLIP_HORIZONTAL); break; } case(2):{ al_draw_scaled_bitmap(msel, 0, 0, this->selectorW, this->selectorH, this->WIDTH/2 + (al_get_text_width(font18,text2C)/2), this->HEIGHT/8*4 -14, 40, 50, NULL); al_draw_scaled_bitmap(msel, 0, 0, this->selectorW, this->selectorH, this->WIDTH/2 - (al_get_text_width(font18,text2C)/2) - (playerWidth()/2.7), this->HEIGHT/8*4 -14, 40, 50, ALLEGRO_FLIP_HORIZONTAL); break; } case(3):{ al_draw_scaled_bitmap(msel, 0, 0, this->selectorW, this->selectorH, this->WIDTH/2 + (al_get_text_width(font18,text3C)/2), this->HEIGHT/8*5 -14, 40, 50, NULL); al_draw_scaled_bitmap(msel, 0, 0, this->selectorW, this->selectorH, this->WIDTH/2 - (al_get_text_width(font18,text3C)/2) - (playerWidth()/2.7), this->HEIGHT/8*5 -14, 40, 50, ALLEGRO_FLIP_HORIZONTAL); break; } } }
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); }
/******************* Expande ou a altura ou a largura, dependendo do parametro *******************/ void Bitmap :: printFullScreen(int x, int y, int flag) { if(sprite != NULL) { switch(flag) { case 0: al_draw_scaled_bitmap(sprite, 0, 0, getW(), SCREEN_H, x, y, SCREEN_W, SCREEN_H, 0); break; case 1: al_draw_scaled_bitmap(sprite, 0, 0, SCREEN_W, getH(), x, y, SCREEN_W, SCREEN_H, 0); break; case 2: al_draw_scaled_bitmap(sprite, 0, 0, getW(), getH(), x, y, SCREEN_W, SCREEN_H, 0); break; } } }
void create_font_symbols(Board *b){ ALLEGRO_BITMAP *bmp = NULL, *currbuf = al_get_target_bitmap(); ALLEGRO_FONT *newfont=NULL; int i, j; int texth = al_get_font_line_height(b->text_font); int bitmap_w, bitmap_h; int bw = al_get_bitmap_width(b->clue_unit_bmp[0][0]); int bh = al_get_bitmap_height(b->clue_unit_bmp[0][0]); int nbw, nbh; int range[2]; al_set_target_bitmap(NULL); nbw = bw*(float)texth/bh; nbh = texth; bitmap_w = 4 + b->n*(2+nbw); // extra column for buttons, n>=4 bitmap_h = 4 + (b->h+1)*(2+nbh); bmp = al_create_bitmap(bitmap_w, bitmap_h); al_set_target_bitmap(bmp); al_clear_to_color(NULL_COLOR); for(j=0; j<b->h; j++){ for(i=0; i<b->n; i++){ // the rectangle is to guarantee the right height for al_grab_font al_draw_scaled_bitmap(b->clue_unit_bmp[j][i], 0, 0, bw, bh, 2+i*(2+nbw), 2+ j*(2+nbh), nbw, nbh, 0); al_draw_rectangle( 2+i*(2+nbw)+0.5, 2+ j*(2+nbh) + 0.5, 2+i*(2+nbw) + nbw -0.5, 2+j*(2+nbh) + nbh- 0.5, al_map_rgba(1,1,1,1),1); } } // draw the buttons. now j= b->h for(i=0;i<b->n;i++){ bw=al_get_bitmap_width(b->button_bmp[i%4]); bh=al_get_bitmap_height(b->button_bmp[i%4]); al_draw_scaled_bitmap(b->button_bmp[i%4], 0, 0, bw, bh, 2+i*(2+nbw), 2+ j*(2+nbh), nbw, nbh, 0); al_draw_rectangle( 2+i*(2+nbw)+0.5, 2+ j*(2+nbh) + 0.5, 2+i*(2+nbw) + nbw -0.5, 2+j*(2+nbh) + nbh- 0.5, al_map_rgba(1,1,1,1),1); } range[0] = BF_CODEPOINT_START; range[1] = BF_CODEPOINT_START + b->n*b->h-1 + 4; newfont = al_grab_font_from_bitmap(bmp, 1, range); al_set_fallback_font(b->text_font, newfont); al_set_target_bitmap(currbuf); al_destroy_bitmap(bmp); }
void Prog::draw_bitmap(const std::string & str, const std::string &how, bool memory, bool destination) { int i = destination ? 1 : 0; int rv = r[i].get_cur_value(); int gv = g[i].get_cur_value(); int bv = b[i].get_cur_value(); int av = a[i].get_cur_value(); ALLEGRO_COLOR color = makecol(rv, gv, bv, av); ALLEGRO_BITMAP *bmp; if (contains(str, "Mysha")) bmp = (memory ? mysha_bmp : mysha); else bmp = (memory ? allegro_bmp : allegro); if (how == "original") { if (str == "Color") al_draw_filled_rectangle(0, 0, 320, 200, color); else if (contains(str, "tint")) al_draw_tinted_bitmap(bmp, color, 0, 0, 0); else al_draw_bitmap(bmp, 0, 0, 0); } else if (how == "scaled") { int w = al_get_bitmap_width(bmp); int h = al_get_bitmap_height(bmp); float s = 200.0 / h * 0.9; if (str == "Color") { al_draw_filled_rectangle(10, 10, 300, 180, color); } else if (contains(str, "tint")) { al_draw_tinted_scaled_bitmap(bmp, color, 0, 0, w, h, 160 - w * s / 2, 100 - h * s / 2, w * s, h * s, 0); } else { al_draw_scaled_bitmap(bmp, 0, 0, w, h, 160 - w * s / 2, 100 - h * s / 2, w * s, h * s, 0); } } else if (how == "rotated") { if (str == "Color") { al_draw_filled_circle(160, 100, 100, color); } else if (contains(str, "tint")) { al_draw_tinted_rotated_bitmap(bmp, color, 160, 100, 160, 100, ALLEGRO_PI / 8, 0); } else { al_draw_rotated_bitmap(bmp, 160, 100, 160, 100, ALLEGRO_PI / 8, 0); } } }
// Função de desenho do plano de fundo //! Essa função está definida para o tamanho da aplicação (800x600). Seria interessante que ela fosse substituída por uma onde esses parâmetros fossem consultados a partir da classe, para não deixá-la estática como está. void ScrollingBackground::draw ( void ) { if( al_get_bitmap_width(this->background)-this->x < 800 ) { al_draw_scaled_bitmap(this->background, this->x, this->y, al_get_bitmap_width(this->background) - this->x, 600, 0, 0, al_get_bitmap_width(this->background) - this->x, 600, 0); al_draw_scaled_bitmap(this->background, 0, this->y, 800 - (al_get_bitmap_width(this->background) - this->x), 600, (al_get_bitmap_width(this->background) - this->x), 0, 800 - (al_get_bitmap_width(this->background) - this->x), 600, 0); } else al_draw_scaled_bitmap(this->background, this->x, this->y, 800, 600, 0, 0, 800, 600, 0); }
void twoDImage::draw(){ int w, h; w = al_get_bitmap_width(this->bitmap); h = al_get_bitmap_height(this->bitmap); if((this->width == w) && (this->height == h)) al_draw_bitmap(this->bitmap, this->x, this->y, 0); else al_draw_scaled_bitmap(this->bitmap, 0, 0, w, h, this->x, this->y, this->width, this->height, 0); }
void DrawInput(const Input* const input) { float bar_bitmap_height = al_get_bitmap_height(input->bar_bitmap); al_draw_scaled_bitmap(input->bar_bitmap, 0, 0, input->strength.value * input->strength_scale1, bar_bitmap_height, input->bar_pos.x, input->bar_pos.y, input->strength.value * input->strength_scale2, BAR_HEIGHT, 0); float cx = 0; float cy = al_get_bitmap_height(input->arrow_bitmap) / 2; al_draw_scaled_rotated_bitmap(input->arrow_bitmap, cx, cy, input->arrow_pos.x, input->arrow_pos.y, input->arrow_scale.x, input->arrow_scale.y, DegToRad(input->angle), 1); }