void AnimatedSprite::draw(float offx, float offy) { if (!image || !visible) return; if (rot != 0 || scale != 1) { if (hFlip && vFlip) al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, ALLEGRO_FLIP_HORIZONTAL | ALLEGRO_FLIP_VERTICAL); else if (hFlip) al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, ALLEGRO_FLIP_HORIZONTAL); else if (vFlip) al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, ALLEGRO_FLIP_VERTICAL); else al_draw_tinted_scaled_rotated_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, al_map_rgba(0, 0, 0, 0), frame_width/2, frame_height/2, x+offx, y+offy, scale, scale, rot, 0); } else { if (hFlip && vFlip) al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, ALLEGRO_FLIP_HORIZONTAL | ALLEGRO_FLIP_VERTICAL); else if (hFlip) al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, ALLEGRO_FLIP_HORIZONTAL); else if (vFlip) al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, ALLEGRO_FLIP_VERTICAL); else al_draw_bitmap_region(image, cur_frame*frame_width, cur_row*frame_height, frame_width, frame_height, x+offx, y+offy, 0); } }
//Draws dealer hand - 2nd card is only drawn if dealer is playing their turn (after //all other players have played their hands void Hand::RenderDealerHand(ALLEGRO_BITMAP *_cards, bool _isVisible) { if( _isVisible ) { for( unsigned int i = 0; i < m_hand.size(); i++ ) { al_draw_tinted_scaled_rotated_bitmap_region(_cards, (m_hand.at(i).GetNumber() - 1) * 80, m_hand.at(i).GetSuit() * 120, 80, 120, al_map_rgb(255,255,255), 0, 0, 84 + i * 20, 451 + (i * 8), 0.8, 0.8, 0, NULL); } } else if( m_hand.size() > 0 ) { al_draw_tinted_scaled_rotated_bitmap_region(_cards, 0, 4 * 120, 80, 120, al_map_rgb(255,255,255), 0, 0, 84, 451, 0.8, 0.8, 0, NULL); al_draw_tinted_scaled_rotated_bitmap_region(_cards, (m_hand.at(1).GetNumber() - 1) * 80, m_hand.at(1).GetSuit() * 120, 80, 120, al_map_rgb(255,255,255), 0, 0, 104, 459, 0.8, 0.8, 0, NULL); } }
//Draws player hand relative to what player number they are and what hand they are playing //This affects where they are drawn on table void Hand::RenderPlayerHand(ALLEGRO_BITMAP *_cards, int _handNo, int _playerNo) { for( unsigned int i = 0; i < m_hand.size(); i++ ) { al_draw_tinted_scaled_rotated_bitmap_region(_cards, (m_hand.at(i).GetNumber() - 1) * 80, m_hand.at(i).GetSuit() * 120, 80, 120, al_map_rgb(255,255,255), 0, 0, 495 + (_handNo * 165) + (i * 18), 80 + (_playerNo * 190) + (i * 3), 0.8, 0.8, 0, NULL); } }
static mrb_value bitmap_draw_tinted_scaled_rotated_region(mrb_state *mrb, mrb_value self) { ALLEGRO_BITMAP *b; mrb_float sx; mrb_float sy; mrb_float sw; mrb_float sh; 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, "ffffdfffffff|nn", &sx, &sy, &sw, &sh, &tint, &mrbal_color_data_type, &cx, &cy, &dx, &dy, &xscale, &yscale, &angle, &flag1, &flag2); flags = argc > 12 ? mrbal_bitmap_get_flags(mrb, argc, flag1, flag2) : 0; al_draw_tinted_scaled_rotated_bitmap_region(b, sx, sy, sw, sh, *tint, cx, cy, dx, dy, xscale, yscale, angle, flags); return mrb_nil_value(); }
void SpriteSheet::DrawSprite( int FrameNumber, int ScreenX, int ScreenY, float ScaleX, float ScaleY, Angle* Rotation ) { if( FrameNumber < 0 || FrameNumber >= (int)frames.size() ) { return; } SpriteSheetRegion* r = frames.at( FrameNumber ); if( (Rotation == 0 || Rotation->ToDegrees() == 0) && ScaleX == 1.0f && ScaleY == 1.0f ) { al_draw_bitmap_region( sheet, r->X, r->Y, r->Width, r->Height, ScreenX, ScreenY, 0 ); } else { int renderX = r->X + ((r->Width * ScaleX) / 2); if( Rotation == 0 ) { al_draw_tinted_scaled_rotated_bitmap_region( sheet, r->X, r->Y, r->Width, r->Height, al_map_rgba(255, 255, 255, 255), 0, 0, ScreenX, ScreenY, ScaleX, ScaleY, 0, 0 ); } else { al_draw_tinted_scaled_rotated_bitmap_region( sheet, r->X, r->Y, r->Width, r->Height, al_map_rgba(255, 255, 255, 255), r->Width / 2, r->Height / 2, ScreenX + ((r->Width * ScaleX) / 2), ScreenY + ((r->Height * ScaleY) / 2), ScaleX, ScaleY, Rotation->ToRadians(), 0 ); } } }
void Graphics::DrawRegion(Texture* source, float srcX, float srcY, float srcWidth, float srcHeight, float destX, float destY, float alpha, bool flipped, float angle) { if(!source) { al_show_native_message_box(TF::engine->display, "Error", "Error", "[TEXTURE DRAW] The texture is NULL!", NULL, ALLEGRO_MESSAGEBOX_ERROR); return; } if(angle == 0.0f) { if(!flipped) { al_draw_tinted_bitmap_region(source->tex, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), srcX, srcY, srcWidth, srcHeight, destX, destY, 0); } else { al_draw_tinted_bitmap_region(source->tex, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), srcX, srcY, srcWidth, srcHeight, destX, destY, ALLEGRO_FLIP_HORIZONTAL); } } else { if(!flipped) { al_draw_tinted_scaled_rotated_bitmap_region(source->tex, srcX, srcY, srcWidth, srcHeight, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), 0.0f, 0.0f, destX, destY, 1.0f, 1.0f, angle, 0); } else { al_draw_tinted_scaled_rotated_bitmap_region(source->tex, srcX, srcY, srcWidth, srcHeight, al_map_rgba_f(1.0f * alpha, 1.0f * alpha, 1.0f * alpha, alpha), 0.0f, 0.0f, destX, destY, 1.0f, 1.0f, angle, ALLEGRO_FLIP_HORIZONTAL); } } }
void t3f_draw_scaled_rotated_animation_region(T3F_ANIMATION * ap, float sx, float sy, float sw, float sh, ALLEGRO_COLOR color, int tick, float cx, float cy, float x, float y, float z, float scale, float angle, int flags) { float sscale_x, sscale_y; T3F_ANIMATION_FRAME * fp = t3f_animation_get_frame(ap, tick); float fox = 0.0; float foy = 0.0; float fsx, fsy, fsw, fsh; float pw; if(fp) { pw = t3f_project_x(1.0, z) - t3f_project_x(0.0, z); sscale_x = fp->width / (float)al_get_bitmap_width(ap->bitmaps->bitmap[fp->bitmap]); sscale_y = fp->height / (float)al_get_bitmap_height(ap->bitmaps->bitmap[fp->bitmap]); fsx = sx / sscale_x; fsy = sy / sscale_y; fsw = sw / sscale_x; fsh = sh / sscale_y; al_draw_tinted_scaled_rotated_bitmap_region(ap->bitmaps->bitmap[fp->bitmap], fsx, fsy, fsw, fsh, color, cx / sscale_x - fp->x, cy / sscale_y - fp->y, t3f_project_x(x + fox, z), t3f_project_y(y + foy, z), scale * sscale_x * pw, scale * sscale_y * pw, angle, flags); } }
void SpritesBlitSprite(int num, int clip, int x, int y, int width, int height, int centerX, int centerY, double angle, int a, int flip) { if (Sprite[num].text == NULL) { if (Sprite[num].texture != NULL) { al_draw_tinted_scaled_rotated_bitmap_region(Sprite[num].texture, Sprite[num].clip[clip].x, Sprite[num].clip[clip].y, Sprite[num].clip[clip].w, Sprite[num].clip[clip].h, al_map_rgba(255 * a / 255, 255 * a / 255, 255 * a / 255, 255 * a / 255), centerX, centerY, x, y, width / Sprite[num].clip[clip].w, height / Sprite[num].clip[clip].h, angle, 0); } } else { al_draw_ustr(Fonts.font[Sprite[num].fontNum], al_map_rgba(Sprite[num].textR * a / 255, Sprite[num].textG * a / 255, Sprite[num].textB * a / 255, 255 * a / 255), x, y, ALLEGRO_ALIGN_INTEGER, (const ALLEGRO_USTR *)Sprite[num].text); } }
void shal_draw_tinted_scaled_rotated_bitmap_region(ALLEGRO_BITMAP * bitmap, float sx, float sy, float sw, float sh, 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_region(bitmap, sx, sy, sw, sh, tint, cx, cy, dx, dy, xscale, yscale, angle, flags); }
void RenderTarget::drawBitmapRegion(ALLEGRO_BITMAP *r, float sx, float sy, float sw, float sh, float dx, float dy, float xscale, float yscale, float rot) { setAsCurrent(); convertCoords(dx, dy); al_draw_tinted_scaled_rotated_bitmap_region(r, sx, sy, sw, sh, al_map_rgba_f(1, 1, 1, 1), sw * 0.5, sh * 0.5, dx, dy, xscale, yscale, rot, 0); }
void RenderTarget::drawBitmapRegion(ALLEGRO_BITMAP *r, float sx, float sy, float sw, float sh, const ALLEGRO_COLOR &tint, float x, float y, float rot) { setAsCurrent(); convertCoords(x, y); al_draw_tinted_scaled_rotated_bitmap_region(r, sx, sy, sw, sh, tint, sw * 0.5f, sh * 0.5f, x, y, 1.0f, 1.0f, rot, 0); }
void Tile::draw(float posx,float posy) { //const enum TILETYPE{FLOOR,WALL,DOOR,WATER,POT,CHEST,TORCH}; switch (type) { case FLOOR: al_draw_bitmap_region(myimg,mystate * 32.0f, 0, 32.0f, 32.0f,posx,posy,0); break; case WALL: al_draw_bitmap_region(myimg,mystate * 32.0f,32.0f,32.0f,32.0f,posx,posy,0); break; case DOOR: if(gridy == 12) { if(gridx == 0) { if(mystate2 == 0) { al_draw_tinted_scaled_rotated_bitmap_region(myimg,0,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 0.0f / 180.0f,0); } else { al_draw_tinted_scaled_rotated_bitmap_region(myimg,32.0f,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 0.0f / 180.0f,0); } } else { if(mystate2 == 0) { al_draw_tinted_scaled_rotated_bitmap_region(myimg,0,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 180.0f / 180.0f,0); } else { al_draw_tinted_scaled_rotated_bitmap_region(myimg,32.0f,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 180.0f/ 180.0f,0); } } } else { if(gridy == 0) { if(mystate2 == 0) { al_draw_tinted_scaled_rotated_bitmap_region(myimg,0,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 270.0f/ 180.0f,0); } else { al_draw_tinted_scaled_rotated_bitmap_region(myimg,32.0f,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 270.0f/ 180.0f,0); } } else { if(mystate2 == 0) { al_draw_tinted_scaled_rotated_bitmap_region(myimg,0,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 90.0f / 180.0f,0); } else { al_draw_tinted_scaled_rotated_bitmap_region(myimg,32.0f,64.0f,32.0f,32.0f,al_map_rgb(255,255,255),16.0f,16.0f,posx + 16.0f,posy + 16.0f,1.0f,1.0f,3.14 * 90.0f / 180.0f,0); } } } break; case WATER: if(mystate > 32) { mystate = 0; } al_draw_bitmap_region(myimg,mystate++, 160, 32.0f, 32.0f,posx,posy,0); break; case POT: al_draw_bitmap_region(myimg,0, 0, 32.0f, 32.0f,posx,posy,0); al_draw_bitmap_region(myimg,mystate * 32.0 + 64, 64, 32.0f, 32.0f,posx,posy,0); break; case CHEST: al_draw_bitmap_region(myimg,0, 0, 32.0f, 32.0f,posx,posy,0); al_draw_bitmap_region(myimg,mystate * 32.0 + 64, 96, 32.0f, 32.0f,posx,posy,0); break; case TORCH: break; default: break; //al_set_blender(ALLEGRO_ADD, ALLEGRO_ONE, ALLEGRO_ZERO); } }
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); } }