void Player::render(int offx, int offy, ALLEGRO_COLOR tint) { if (lives <= 0) return; int rx = (int)(offx + x), ry = (int)(offy + y); if (!isDestructable) { al_draw_tinted_rotated_bitmap(trans_bitmap, tint, draw_radius, draw_radius, rx, ry, angle+(ALLEGRO_PI/2.0f), 0); } else { al_draw_tinted_rotated_bitmap(bitmap, tint, draw_radius, draw_radius, rx, ry, angle+(ALLEGRO_PI/2.0f), 0); } if (draw_trail) { int tw = al_get_bitmap_width(trail_bitmap); int th = al_get_bitmap_height(trail_bitmap); float ca = (ALLEGRO_PI*2)+angle; float a = ca + ((210.0f / 180.0f) * ALLEGRO_PI); float tx = rx + 42.0f * cos(a); float ty = ry + 42.0f * sin(a); al_draw_tinted_rotated_bitmap(trail_bitmap, tint, tw, th/2, tx, ty, a, 0); a = ca + ((150.0f / 180.0f) * ALLEGRO_PI); tx = rx + 42.0f * cos(a); ty = ry + 42.0f * sin(a); al_draw_tinted_rotated_bitmap(trail_bitmap, tint, tw, th/2, tx, ty, a, 0); } }
void shal_draw_tinted_rotated_bitmap(ALLEGRO_BITMAP * bitmap, float tint_r, float tint_g, float tint_b, float tint_a, float cx, float cy, float dx, float dy, float angle, int flags) { ALLEGRO_COLOR tint; tint.r = tint_r; tint.g = tint_g; tint.b = tint_b; tint.a = tint_a; return al_draw_tinted_rotated_bitmap(bitmap, tint, cx, cy, dx, dy, angle, flags); }
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); } } }
void Image::draw() { Position *position = POSITION(this->entity); unsigned char opacity = VISIBILITY(this->entity)->opacity; float angle = ROTATION(this->entity)->angle; if (this->bitmap) al_draw_tinted_rotated_bitmap(this->bitmap, al_map_rgba(opacity, opacity, opacity, opacity), angle == 0 ? 0 : al_get_bitmap_width(this->bitmap) / 2, angle == 0 ? 0 : al_get_bitmap_height(this->bitmap) / 2, angle == 0 ? position->x : position->x + al_get_bitmap_width(this->bitmap) / 2, angle == 0 ? position->y : position->y + al_get_bitmap_height(this->bitmap) / 2, angle, 0); }
static void _al_draw_orthogonal_tile_layer(ALLEGRO_MAP_LAYER *layer, ALLEGRO_MAP *map, ALLEGRO_COLOR tint, float sx, float sy, float sw, float sh, float dx, float dy, int flags) { if (!layer->visible) { return; } float r, g, b, a; al_unmap_rgba_f(tint, &r, &g, &b, &a); ALLEGRO_COLOR color = al_map_rgba_f(r, g, b, a * layer->opacity); int mx, my; int ystart = sy / map->tile_height, yend = (sy + sh) / map->tile_height; int xstart = sx / map->tile_width, xend = (sx + sw) / map->tile_width; // defer rendering until everything is drawn al_hold_bitmap_drawing(true); for (my = ystart; my <= yend; my++) { for (mx = xstart; mx <= xend; mx++) { ALLEGRO_MAP_TILE *tile = al_get_single_tile(map, layer, mx, my); flags = 0; if (!tile) { continue; } float x = mx*(map->tile_width) - sx + dx; float y = my*(map->tile_height) - sy + dy; if (flipped_vertically(layer, mx, my)) flags ^= ALLEGRO_FLIP_VERTICAL; if (flipped_horizontally(layer, mx, my)) flags ^= ALLEGRO_FLIP_HORIZONTAL; if (flipped_diagonally(layer, mx, my)) { int tile_center_h = map->tile_width / 2; int tile_center_w = map->tile_height / 2; flags ^= ALLEGRO_FLIP_VERTICAL; al_draw_tinted_rotated_bitmap(tile->bitmap, color, tile_center_w, tile_center_h, x + tile_center_h, y + tile_center_w, -ALLEGRO_PI/2, flags); } else { al_draw_tinted_bitmap(tile->bitmap, color, x, y, flags); } } } al_hold_bitmap_drawing(false); }
static mrb_value bitmap_draw_tinted_rotated(mrb_state *mrb, mrb_value self) { ALLEGRO_BITMAP *b; mrb_float cx; mrb_float cy; mrb_float dx; mrb_float dy; mrb_float angle; mrb_sym flag1; mrb_sym flag2; int argc; ALLEGRO_COLOR *tint; int flags; Check_Destroyed(mrb, self, bitmap, b); argc = mrb_get_args(mrb, "dfffff|nn", &tint, &mrbal_color_data_type, &cx, &cy, &dx, &dy, &angle, &flag1, &flag2); flags = argc > 6 ? mrbal_bitmap_get_flags(mrb, argc, flag1, flag2) : 0; al_draw_tinted_rotated_bitmap(b, *tint, cx, cy, dx, dy, angle, flags); return mrb_nil_value(); }
// |----------------------------------------------------------------------------| // | draw() | // |----------------------------------------------------------------------------| void Image::draw() { if (graphic) { if (angle) { if (alpha != 1) { al_draw_tinted_rotated_bitmap(graphic, al_map_rgba_f(1, 1, 1, alpha), size.x/2, size.y/2, anchor.x + size.x/2, anchor.y + size.y/2, angle, 0); } else { al_draw_rotated_bitmap(graphic, size.x/2, size.y/2, anchor.x + size.x/2, anchor.y + size.y/2, angle, 0); } } else { if (alpha != 1) { al_draw_tinted_bitmap(graphic, al_map_rgba_f(1, 1, 1, alpha), anchor.x, anchor.y, 0); } else { al_draw_bitmap(graphic, anchor.x, anchor.y, 0); } } } }
void Whack_a_Skunk_Loop::draw(void) { al_clear_to_color(al_map_rgb(0x00, 0x00, 0x00)); al_draw_bitmap( bg_bitmap->bitmap, top_offset.x, top_offset.y, 0 ); float scales[3] = { 0.83f, 0.9f, 1.0f }; Wrap::Bitmap *hole_bmps[3] = { mask_back, mask_middle, mask_front }; int hole_yoffs[3] = { 6, 8, 10 }; Wrap::Bitmap *highlight_bmps[3] = { highlight_back, highlight_middle, highlight_front }; int highlight_yoffs[3] = { 5, 6, 8 }; Wrap::Bitmap *maskhighlight_bmps[3] = { mask_backhighlight, mask_middlehighlight, mask_fronthighlight }; for (int i = 0; i < 9; i++) { int row = i / 3; if (i == curr_hole) { Wrap::Bitmap *highlight = highlight_bmps[row]; int highlight_w = al_get_bitmap_width(highlight->bitmap); int highlight_h = al_get_bitmap_height(highlight->bitmap); al_draw_bitmap( highlight->bitmap, holes[i].x-highlight_w/2+top_offset.x, holes[i].y-highlight_h+highlight_yoffs[row]+top_offset.y, 0 ); } Animation_Set *anim_set; bool done = get_skunk_info(i, &anim_set); int x = holes[i].x - skunk_size.w/2 + top_offset.x; int y = holes[i].y - skunk_size.h + top_offset.y; float scale = scales[row]; int ox = (skunk_size.w * (1.0f-scale)) / 2; int oy = 10; oy += (skunk_size.h * (1.0f-scale)) / 2; int len = anim_set->get_length(anim_set->get_sub_animation_name()); if (holes[i].count > len/2) { oy += ((float)(holes[i].count-(len/2)) / (len/2)) * 60 /* 60 = base skunk height */; } else { oy += (1.0 - ((float)holes[i].count / (len/2))) * 60; } if (!done) { int cx, cy, cw, ch; al_get_clipping_rectangle(&cx, &cy, &cw, &ch); General::set_clipping_rectangle(x, y, skunk_size.w, skunk_size.h); if (holes[i].status == ALIVE || holes[i].status == TAUNTING || holes[i].status == GOING_DOWN) { anim_set->get_current_animation()->draw_scaled( 0, 0, skunk_size.w, skunk_size.h, x+ox, y+oy, skunk_size.w*scale, skunk_size.h*scale, 0 ); } else if (holes[i].status == DYING) { std::string name = anim_set->get_sub_animation_name(); int frame = anim_set->get_current_animation()->get_current_frame_num(); anim_set->set_sub_animation("popup"); anim_set->set_frame(holes[i].type == FAKE ? 0 : 3); anim_set->get_current_animation()->draw_scaled( 0, 0, skunk_size.w, skunk_size.h, x+ox, y+oy, skunk_size.w*scale, skunk_size.h*scale, 0 ); anim_set->set_sub_animation(name); anim_set->set_frame(frame); } al_set_clipping_rectangle(cx, cy, cw, ch); } Wrap::Bitmap *mask = i == curr_hole ? maskhighlight_bmps[row] : hole_bmps[row]; int mask_w = al_get_bitmap_width(mask->bitmap); int mask_h = al_get_bitmap_height(mask->bitmap); al_draw_bitmap( mask->bitmap, holes[i].x-mask_w/2+top_offset.x, holes[i].y-mask_h+hole_yoffs[row]+top_offset.y, 0 ); if (!done) { if (holes[i].status == DYING) { anim_set->get_current_animation()->draw_scaled( 0, 0, skunk_size.w, skunk_size.h, x+ox, y+oy, skunk_size.w*scale, skunk_size.h*scale, 0 ); } } } // Draw timer int digits; if (timer/1000 >= 10) { digits = 2; } else { digits = 1; } int font_w = font->get_current_animation()->get_current_frame()->get_width(); float xx = (cfg.screen_w-font_w*(digits+1))/2; float yy = 5; int tmp = timer; for (int i = 0; i < digits; i++) { int p = powf(10, (digits-i)+2); int frame = tmp / p; font->set_sub_animation(General::itos(frame)); font->get_current_animation()->draw( xx, yy, 0 ); tmp -= frame * p; xx += font_w; } font->set_sub_animation("s"); font->get_current_animation()->draw( xx, yy, 0 ); // Draw score/hitx if (hits < 0) { hits = 0; } char buf[100]; snprintf(buf, 100, "%d", hits); draw_centered_text(font, al_map_rgb(0x00, 0xff, 0x00), buf, cfg.screen_w/4-30, 5); int hitx; if (hits_in_a_row >= 7) { hitx = 3; } else if (hits_in_a_row >= 3) { hitx = 2; } else { hitx = 1; } snprintf(buf, 100, "x%d", hitx); draw_centered_text(font, al_map_rgb(0xff, 0xd7, 0x00), buf, cfg.screen_w*3/4+15, 5); std::list<Pow>::iterator pow_it; for (pow_it = pows.begin(); pow_it != pows.end(); pow_it++) { Pow &p = *pow_it; ALLEGRO_COLOR tint; float a; if (p.count < POW_LIFETIME/2) { a = 1.0; } else { a = ((float)p.count-POW_LIFETIME/2) / (POW_LIFETIME/2); if (a > 1.0) a = 1.0; a = 1.0 - a; } tint = al_map_rgba_f(1.0, 1.0, 1.0, a); int r = (cfg.screen_w / 120) * 2 + 1; al_draw_tinted_bitmap( p.kratch ? kratch_bmp->bitmap : pow_bmp->bitmap, tint, p.x-al_get_bitmap_width(pow_bmp->bitmap)/2+General::rand()%r-(r/2)+top_offset.x, p.y-al_get_bitmap_height(pow_bmp->bitmap)/2+General::rand()%r-(r/2)+top_offset.y, 0 ); } std::list<Star>::iterator star_it; for (star_it = stars.begin(); star_it != stars.end(); star_it++) { Star &s = *star_it; ALLEGRO_COLOR tint; float b = (float)s.count / STAR_LIFETIME; if (b > 1.0) b = 1.0; tint = al_map_rgb_f(1.0, 1.0, b); al_draw_tinted_rotated_bitmap( star_bmp->bitmap, tint, al_get_bitmap_width(star_bmp->bitmap)/2, al_get_bitmap_height(star_bmp->bitmap)/2, s.x+top_offset.x, s.y+top_offset.y, s.angle, 0 ); } if (bashing) { float xx = holes[curr_hole].x; float yy = holes[curr_hole].y - hand_size.h; xx += top_offset.x; yy += top_offset.y; xx += 90; // trial and error yy += 110; if (curr_hole == 0 || curr_hole == 3 || curr_hole == 6) { hand->set_sub_animation("left"); } else if (curr_hole == 1 || curr_hole == 4 || curr_hole == 7) { hand->set_sub_animation("middle"); xx -= 68; } else { hand->set_sub_animation("right"); xx -= 68*2; } hand->get_current_animation()->draw( xx-hand_size.w/2, yy, 0 ); } }
/* Function: al_draw_rotated_bitmap */ void al_draw_rotated_bitmap(ALLEGRO_BITMAP *bitmap, float cx, float cy, float dx, float dy, float angle, int flags) { al_draw_tinted_rotated_bitmap(bitmap, solid_white, cx, cy, dx, dy, angle, flags); }
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y, float rot, const ALLEGRO_COLOR &tint) { setAsCurrent(); convertCoords(x, y); al_draw_tinted_rotated_bitmap(r, tint, al_get_bitmap_width(r) * 0.5f, al_get_bitmap_height(r) * 0.5f, x, y, rot, 0); }
// -angle?!?! really?! void m_draw_tinted_rotated_bitmap(MBITMAP *bitmap, MCOLOR tint, int cx, int cy, int dx, int dy, float angle, int flags) { al_draw_tinted_rotated_bitmap(bitmap->bitmap, tint, cx, cy, dx, dy, -angle, flags); }
/** Draws a tinted rotated bitmap. @param color color. @param cx center x. @param cy center y. @param dx target horizontal position. @param dy target vertical position. @param angle angle in radians; clockwise. @param flags flags. */ void drawTintedRotated(const ALLEGRO_COLOR &color, float cx, float cy, float dx, float dy, float angle, int flags = 0) { al_draw_tinted_rotated_bitmap(get(), color, cx, cy, dx, dy, angle, flags); }
void drawRotatedTintedPicture(ALLEGRO_BITMAP *img, ALLEGRO_COLOR tint, float dx, float dy, float angle) { al_draw_tinted_rotated_bitmap(img, tint, al_get_bitmap_width(img)/2, al_get_bitmap_height(img)/2 , dx, dy, angle, 0); }
void al_draw_tinted_rotated_bitmap_w(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR *tint, float cx, float cy, float dx, float dy, float angle, int flags) { return al_draw_tinted_rotated_bitmap(bitmap, *tint, cx, cy, dx, dy, angle, flags); }