void obj_AI_Bubble::Draw() { //al_draw_scaled_rotated_bitmap(image, 104, 104, (x-_camX)*(1/_zoom), (y-_camY)*(1/_zoom), (1.0f/96.0f) * radius, (1.0f/96.0f) * radius,0, 0); //al_draw_scaled_bitmap(image, 0, 0, 208, 208, x-(104*(1/96.f)*radius*(1/_zoom)), y-(104*(1/96.f)*radius*(1/_zoom)),208*(1/96.f)*radius*(1/_zoom),208*(1/96.f)*radius*(1/_zoom),0); al_draw_tinted_scaled_rotated_bitmap(imageRed,al_map_rgba(r,r,r,r),104,104,x,y,(1/96.f)*radius,(1/96.f)*radius,0,0); al_draw_tinted_scaled_rotated_bitmap(imageGreen,al_map_rgba(g,g,g,g),104,104,x,y,(1/96.f)*radius,(1/96.f)*radius,0,0); al_draw_scaled_rotated_bitmap(image,104,104,x,y,(1.0/96.f)*radius,(1.0/96.f)*radius,0,0); }
/* Function: al_draw_scaled_rotated_bitmap */ void al_draw_scaled_rotated_bitmap(ALLEGRO_BITMAP *bitmap, float cx, float cy, float dx, float dy, float xscale, float yscale, float angle, int flags) { al_draw_tinted_scaled_rotated_bitmap(bitmap, solid_white, cx, cy, dx, dy, xscale, yscale, angle, flags); }
/* Function: al_draw_tinted_rotated_bitmap * * angle is specified in radians and moves clockwise * on the screen. */ void al_draw_tinted_rotated_bitmap(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR tint, float cx, float cy, float dx, float dy, float angle, int flags) { al_draw_tinted_scaled_rotated_bitmap(bitmap, tint, cx, cy, dx, dy, 1, 1, angle, flags); }
void shal_draw_tinted_scaled_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 xscale, float yscale, 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_scaled_rotated_bitmap(bitmap, tint, cx, cy, dx, dy, xscale, yscale, angle, flags); }
void DrawableBitmap::draw() { //al_draw_scaled_bitmap(bitmap, 0, 0, size.x, size.y, position.x-(size.x/2.0f)*scale, position.y-(size.y/2.0f)*scale, size.x*scale, size.y*scale, 0); float totalScale = scale*localScale; float totalRotation = rotation+localRotation; float totalRotationComplement = rotation-localRotation; al_draw_tinted_scaled_rotated_bitmap(bitmap, al_map_rgba(tintR, tintG, tintB, transparency), size.x/2.0f, size.y/2.0f, position.x, position.y, totalScale, totalScale, totalRotation, 0); if(hasReflection) { al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); //al_draw_tinted_scaled_rotated_bitmap(bitmap, al_map_rgb(100, 100, 100), size.x/2.0f, size.y/2.0f, position.x - sin(rotation)*(scale*size.y+floatingHeight*scale), position.y + cos(rotation)*scale*size.y+floatingHeight*scale, totalScale, totalScale, totalRotationComplement, 2); al_draw_tinted_scaled_rotated_bitmap(bitmap, al_map_rgba(0.9f*tintR, 0.9f*tintG, tintB, 100), size.x/2.0f, size.y/2.0f, position.x - sin(rotation)*(scale*size.y+floatingHeight*scale), position.y + cos(rotation)*scale*size.y+floatingHeight*scale, totalScale, totalScale, totalRotationComplement, 2); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); } }
static void draw(void) { const float sw = al_get_bitmap_width(bmp); const float sh = al_get_bitmap_height(bmp); const float dw = al_get_bitmap_width(dbuf); const float dh = al_get_bitmap_height(dbuf); const float dx = dw / 2.0; const float dy = dh / 2.0; float db_l; float db_r; float db; float scale; float disp; /* Whatever looks okay. */ if (rms_l > 0.0 && rms_r > 0.0) { db_l = 20 * log10(rms_l / 20e-6); db_r = 20 * log10(rms_r / 20e-6); db = (db_l + db_r) / 2.0; scale = db / 20.0; disp = (rms_l + rms_r) * 200.0; } else { db_l = db_r = db = scale = disp = 0.0; } al_set_target_bitmap(dbuf); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); al_draw_filled_rectangle(0, 0, al_get_bitmap_width(dbuf), al_get_bitmap_height(dbuf), al_map_rgba_f(0.8, 0.3, 0.1, 0.06)); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); al_draw_tinted_scaled_rotated_bitmap(bmp, al_map_rgba_f(0.8, 0.3, 0.1, 0.2), sw/2.0, sh/2.0, dx, dy - disp, scale, scale, theta, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); al_set_target_backbuffer(display); al_draw_bitmap(dbuf, 0, 0, 0); al_set_blender(ALLEGRO_ADD, ALLEGRO_ALPHA, ALLEGRO_INVERSE_ALPHA); al_draw_line(10, dh - db_l, 10, dh, al_map_rgb_f(1, 0.6, 0.2), 6); al_draw_line(20, dh - db_r, 20, dh, al_map_rgb_f(1, 0.6, 0.2), 6); al_flip_display(); theta -= (rms_l + rms_r) * 0.1; }
void ship_draw(const ship *s) { // draw the bullets bullet_draw(s->bullets); // draw the ship const uint32_t bitmap_width = al_get_bitmap_width(s->bitmap); const uint32_t bitmap_height = al_get_bitmap_height(s->bitmap); if (s->attr.is_immune) { const double time_passed = al_get_time() - s->attr.time_stamp; if (time_passed - floor(time_passed) < 0.5) { al_draw_tinted_scaled_rotated_bitmap(s->bitmap, color_gray(), bitmap_width / 2, bitmap_height / 2, s->center.x, s->center.y, SHIP_SIZE / bitmap_width, SHIP_SIZE / bitmap_height, s->direction, 0); } else { al_draw_scaled_rotated_bitmap(s->bitmap, bitmap_width / 2, bitmap_height / 2, s->center.x, s->center.y, SHIP_SIZE / bitmap_width, SHIP_SIZE / bitmap_height, s->direction, 0); } } else { al_draw_scaled_rotated_bitmap(s->bitmap, bitmap_width / 2, bitmap_height / 2, s->center.x, s->center.y, SHIP_SIZE / bitmap_width, SHIP_SIZE / bitmap_height, s->direction, 0); } #ifdef DEBUG al_draw_circle(s->center.x, s->center.y, 5, al_map_rgb(255, 0, 0), 3); #endif }
//Offsets are the map offset void CharacterSpawn::DrawObjectRotate(int xOffset, int yOffset) { //0.8 if (hasImage_ && hasColor_) { al_draw_tinted_scaled_rotated_bitmap( image_->GetImage(), chosenColor_, image_->GetImageWidth() / 2.0, image_->GetImageHeight() / 2.0, (currentPositionY_ + width_ / 2)*Constants::TileSize() + xOffset, (currentPositionY_ + height_ / 2)*Constants::TileSize() + yOffset, width_*Constants::TileSize() / (image_->GetImageWidth()*1.0), height_*Constants::TileSize() / (image_->GetImageHeight()*1.0), currentRotation_, 0 ); } else if (hasImage_) { al_draw_scaled_rotated_bitmap( image_->GetImage(), image_->GetImageWidth() / 2.0, image_->GetImageHeight() / 2.0, (currentPositionY_ + width_ / 2)*Constants::TileSize() + xOffset, (currentPositionY_ + height_ / 2)*Constants::TileSize() + yOffset, width_*Constants::TileSize() / (image_->GetImageWidth()*1.0), height_*Constants::TileSize() / (image_->GetImageHeight()*1.0), currentRotation_, 0 ); } };
void FlareManager::Flare::__default_draw(Flare *flare) { float inverse_counter = 1.0 - flare->counter; if (flare->bitmap) { if (flare->blending_mode == BLENDER_ADDITIVE) al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ONE); al_draw_tinted_scaled_rotated_bitmap(flare->bitmap, al_map_rgba_f(flare->opacity,flare->opacity,flare->opacity,flare->opacity), al_get_bitmap_width(flare->bitmap)*flare->align_x, al_get_bitmap_height(flare->bitmap)*flare->align_y, flare->x, flare->y, flare->scale, flare->scale, flare->rotation, 0); if (flare->blending_mode == BLENDER_ADDITIVE) al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_INVERSE_ALPHA); } else { al_draw_circle(flare->x, flare->y, 30*inverse_counter, al_map_rgba_f(flare->counter, flare->counter, flare->counter, flare->counter), 2); } }
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()); } }
static mrb_value bitmap_draw_tinted_scaled_rotated(mrb_state *mrb, mrb_value self) { ALLEGRO_BITMAP *b; mrb_float cx; mrb_float cy; mrb_float dx; mrb_float dy; mrb_float xscale; mrb_float yscale; 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, "dfffffff|nn", &tint, &mrbal_color_data_type, &cx, &cy, &dx, &dy, &xscale, &yscale, &angle, &flag1, &flag2); flags = argc > 8 ? mrbal_bitmap_get_flags(mrb, argc, flag1, flag2) : 0; al_draw_tinted_scaled_rotated_bitmap(b, *tint, cx, cy, dx, dy, xscale, yscale, angle, flags); return mrb_nil_value(); }
void Character::DrawObjectRotate(float mapXOffset, float mapYOffset) { //0.8 if (hasImage_ && hasColor_) { al_draw_tinted_scaled_rotated_bitmap( imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImage(), chosenColor_, imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageWidth() / 2.0, imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageHeight() / 2.0, (currentPositionX_ + width_ / 2)*Constants::TileSize() + mapXOffset, (currentPositionY_ + height_ / 2)*Constants::TileSize() + mapYOffset, width_*Constants::TileSize() / (imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageWidth()*1.0), height_*Constants::TileSize() / (imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageHeight()*1.0), currentRotation_, 0 ); } else if (hasImage_) { al_draw_scaled_rotated_bitmap( imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImage(), imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageWidth() / 2.0, imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageHeight() / 2.0, (currentPositionX_ + width_ / 2)*Constants::TileSize() + mapXOffset, (currentPositionY_ + height_ / 2)*Constants::TileSize() + mapYOffset, width_*Constants::TileSize() / (imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageWidth()*1.0), height_*Constants::TileSize() / (imageBundle_[0].GetImageStateGroupDictionary()[0]->GetImageDictionary()[0]->GetImageHeight()*1.0), currentRotation_, 0 ); } };
void RenderTarget::drawBitmap(ALLEGRO_BITMAP *r, float x, float y, float rot, float xscale, float yscale, const ALLEGRO_COLOR &tint) { setAsCurrent(); convertCoords(x, y); al_draw_tinted_scaled_rotated_bitmap(r, tint, al_get_bitmap_width(r) * 0.5f, al_get_bitmap_height(r) * 0.5f, x, y, xscale, yscale, rot, 0); }
/** Draws a tinted, scaled and rotated bitmap. @param color color. @param cx center x. @param cy center y. @param dx target horizontal position. @param dy target vertical position. @param xscale scale along the x axis. @param yscale scale along the y axis. @param angle angle in radians; clockwise. @param flags flags. */ void drawScaledRotated(const ALLEGRO_COLOR &color, float cx, float cy, float dx, float dy, float xscale, float yscale, float angle, int flags = 0) { al_draw_tinted_scaled_rotated_bitmap(get(), color, cx, cy, dx, dy, xscale, yscale, angle, flags); }
void drawSprite(struct SPRITE *s, float x, float y) { /* draw sprite, animate if it's got more than one frame */ if (!s) return; // don't bother if we're not even visible if (!s->__internal__visible) return; // figure out if we know our graphic index if (s->__internal__anim.graphicIndex == -1) s->__internal__anim.graphicIndex = searchForBmp(s->__internal__anim.name); // check for basic sprite, non-animated if (s->__internal__anim.index == -1) { /* this is a basic sprite with no animation, so just display it */ float w = al_get_bitmap_width(bmpLib[s->__internal__anim.graphicIndex].data) * s->GetScaleX(s); float h = al_get_bitmap_height(bmpLib[s->__internal__anim.graphicIndex].data) * s->GetScaleY(s); al_draw_tinted_scaled_rotated_bitmap(bmpLib[s->__internal__anim.graphicIndex].data, s->__internal_tint, 0, 0, x - (w / 2) - floorf(camera.x), y - h - floorf(camera.y), s->GetScaleX(s), s->GetScaleY(s), s->GetAngle(s), s->flipped); } else { /* otherwise, this is a fancier sprite - animate it */ struct FRAME f = s->__internal__anim.frame[s->GetAnim(s)][s->__internal__anim.index]; if (f.sound == -255) { // we've run out of frames, go back to zero if (s->__internal__looping) { f = s->__internal__anim.frame[s->GetAnim(s)][0]; s->__internal__anim.index = 0; } else { --s->__internal__anim.index; s->__internal__frameDelay = 0; f = s->__internal__anim.frame[s->GetAnim(s)][s->__internal__anim.index]; } } else { /* otherwise increment frame, if we've waited out the delay */ ++s->__internal__frameDelay; if (s->__internal__frameDelay > (f.delay * s->__internal_slowAnim)) { ++s->__internal__anim.index; s->__internal__frameDelay = 0; // play frame sound if we're allow by the playFrameSounds variable if (playFrameSounds) { if (f.sound > -1) { playSound(f.sound); } } } } /* finally, display retrieved frame */ al_draw_tinted_scaled_rotated_bitmap_region(bmpLib[s->__internal__anim.graphicIndex].data, f.x, f.y, f.w, f.h, s->__internal_tint, 0, 0, (x - (f.w / 2)) - floorf(camera.x), (y - f.h) - floorf(camera.y), s->GetScaleX(s), s->GetScaleY(s), s->GetAngle(s), s->flipped); //al_draw_rectangle(s->box.x - floorf(camera.x), s->box.y - floorf(camera.y), s->box.right - floorf(camera.x), s->box.bottom - floorf(camera.y), al_map_rgb(0, 255, 0), 1); } }
void al_draw_tinted_scaled_rotated_bitmap_w(ALLEGRO_BITMAP *bitmap, ALLEGRO_COLOR *tint, float cx, float cy, float dx, float dy, float xscale, float yscale, float angle, int flags) { return al_draw_tinted_scaled_rotated_bitmap(bitmap, *tint, cx, cy, dx, dy, xscale, yscale, angle, flags); }