void Image::Draw() { if (section.x == 0 && section.y == 0 && section.w == 0 && section.h == 0) App->render->Blit(texture, GetScreenX(), GetScreenY(), NULL, 0.0f); else App->render->Blit(texture, GetScreenX(), GetScreenY(), §ion, 0.0f); }
int32_t BoxObject::GetScreenX(ErrorResult& aRv) { int32_t ret = 0; aRv = GetScreenX(&ret); return ret; }
void CChildView::OnPaint() { //获取窗口DC指针 CDC *cDC=this->GetDC(); //获取窗口大小 GetClientRect(&m_client); //创建缓冲DC m_cacheDC.CreateCompatibleDC(NULL); m_cacheCBitmap.CreateCompatibleBitmap(cDC,m_client.Width(),m_client.Height()); m_cacheDC.SelectObject(&m_cacheCBitmap); //计算背景地图起始位置 GetMapStartX(); //————————————————————开始绘制—————————————————————— //贴背景,现在贴图就是贴在缓冲DC:m_cache中了 m_bg.Draw(m_cacheDC,0,0,WINDOW_WIDTH,WINDOW_HEIGHT,m_xMapStart,0,WINDOW_WIDTH,WINDOW_HEIGHT); //贴英雄 MyHero.hero.Draw(m_cacheDC,GetScreenX(MyHero.x,m_mapWidth),MyHero.y,80,80,MyHero.frame*80,MyHero.direct*80,80,80); //最后将缓冲DC内容输出到窗口DC中 cDC->BitBlt(0,0,m_client.Width(),m_client.Height(),&m_cacheDC,0,0,SRCCOPY); //————————————————————绘制结束————————————————————— //在绘制完图后,使窗口区有效 ValidateRect(&m_client); //释放缓冲DC m_cacheDC.DeleteDC(); //释放对象 m_cacheCBitmap.DeleteObject(); //释放窗口DC ReleaseDC(cDC); }
void TTextBox::Draw(int w, int h) { int x = Parent->X; int y = Parent->Y; int Height = this->Height - 4; int Width = this->Width - 4; int fposx = (GetScreenX()) + 2; int fposy = (GetScreenY()) + this->Height/2 - Font->Height/2 + 2; char TextShown[WIDG_MAX_TEXT]; int NumShown = Width/Font->Width; int StartIndex = 0; if (HasFocus && NumShown - 1 < strlen(Text)) StartIndex = strlen(Text) - NumShown + 1; else StartIndex = horizontalScrollPos; strcpy(TextShown, &Text[StartIndex]); if (HasFocus) strcat(TextShown, "_"); TextShown[NumShown] = 0; Font->Draw(fposx, fposy, TextShown, 0, 0, 0, w, h); Pressed = HasFocus; strcpy(TextShown, Text); SetText(""); this->TButton::Draw(w, h); SetText(TextShown); }
void Button::Draw() { switch (state) { case IDLE: App->render->Blit(texture, GetScreenX(), GetScreenY(), &draw_idle, 0.0f); break; case HOVER: App->render->Blit(texture, GetScreenX(), GetScreenY(), &draw_hover, 0.0f); break; case CLICK: App->render->Blit(texture, GetScreenX(), GetScreenY(), &draw_click, 0.0f); break; } }
void Game_Player::UpdateScroll() { int center_x = DisplayUi->GetWidth() / 2 - TILE_SIZE / 2 - Game_Map::GetPanX() / (SCREEN_TILE_WIDTH / TILE_SIZE); int center_y = DisplayUi->GetHeight() / 2 + TILE_SIZE / 2 - Game_Map::GetPanY() / (SCREEN_TILE_WIDTH / TILE_SIZE); int dx = 0; int dy = 0; if (!Game_Map::IsPanLocked()) { if (IsMoving()) { int d = GetDirection(); if ((d == Right || d == UpRight || d == DownRight) && GetScreenX() >= center_x) dx = 1; else if ((d == Left || d == UpLeft || d == DownLeft) && GetScreenX() <= center_x) dx = -1; dx <<= 1 + GetMoveSpeed(); if ((d == Down || d == DownRight || d == DownLeft) && GetScreenY() >= center_y) dy = 1; else if ((d == Up || d == UpRight || d == UpLeft) && GetScreenY() <= center_y) dy = -1; dy <<= 1 + GetMoveSpeed(); } else if (IsJumping()) { int move_speed = GetMoveSpeed(); int diff = move_speed < 5 ? 48 / (2 + pow(2.0, 3 - move_speed)) : 64 / (7 - move_speed); dx += (GetX() - jump_x) * diff; dy += (GetY() - jump_y) * diff; } } if (Game_Map::GetPanX() != last_pan_x || Game_Map::GetPanY() != last_pan_y) { dx += Game_Map::GetPanX() - last_pan_x; dy += Game_Map::GetPanY() - last_pan_y; last_pan_x = Game_Map::GetPanX(); last_pan_y = Game_Map::GetPanY(); } if (dx > 0) Game_Map::ScrollRight(dx); else if (dx < 0) Game_Map::ScrollLeft(-dx); if (dy > 0) Game_Map::ScrollDown(dy); else if (dy < 0) Game_Map::ScrollUp(-dy); }
void CChildView::OnPaint() { //获取窗口DC指针 CDC *cDC=this->GetDC(); //获取窗口大小 GetClientRect(&m_client); //创建缓冲DC m_cacheDC.CreateCompatibleDC(NULL); m_cacheCBitmap.CreateCompatibleBitmap(cDC,m_client.Width(),m_client.Height()); m_cacheDC.SelectObject(&m_cacheCBitmap); //计算背景地图起始位置 GetMapStartX(); //————————————————————开始绘制—————————————————————— //贴背景,现在贴图就是贴在缓冲DC:m_cache中了 m_bg.Draw(m_cacheDC,0,0,WINDOW_WIDTH,WINDOW_HEIGHT,m_xMapStart,0,WINDOW_WIDTH,WINDOW_HEIGHT); //贴英雄 MyHero.hero.Draw(m_cacheDC,GetScreenX(MyHero.x,m_mapWidth),MyHero.y,80,80,MyHero.frame*80,MyHero.direct*80,80,80); //绘制雪花粒子 for(int i=0;i<SNOW_NUMBER;i++) { //画出粒子 m_snowMap[Snow[i].number].Draw(m_cacheDC,Snow[i].x,Snow[i].y,32,32); //对粒子的位置进行更新 Snow[i].y+=1; if(Snow[i].y>=600) //当落到最下面后,再回到最上面去 Snow[i].y=0; //为了更自然,在水平方向上也发生位移,就像有风一样 if(rand()%2==0) Snow[i].x+=1; else Snow[i].x-=1; if(Snow[i].x<0) Snow[i].x=WINDOW_WIDTH; //水平方向上出界后到另一边去 else if(Snow[i].x>=WINDOW_WIDTH) Snow[i].x=0; } //最后将缓冲DC内容输出到窗口DC中 cDC->BitBlt(0,0,m_client.Width(),m_client.Height(),&m_cacheDC,0,0,SRCCOPY); //————————————————————绘制结束————————————————————— //在绘制完图后,使窗口区有效 ValidateRect(&m_client); //释放缓冲DC m_cacheDC.DeleteDC(); //释放对象 m_cacheCBitmap.DeleteObject(); //释放窗口DC ReleaseDC(cDC); }
void Label::Draw() { App->render->Blit(texture, GetScreenX(), GetScreenY(), NULL, 0.0f); }
void ScrollBar::Update() { current_value = thumb->GetScreenX() / (GetScreenX() + pos.w); }
void InputText::Draw() { App->render->Blit(texture, GetScreenX(), GetScreenY(), NULL, 0.0f); }
void Game_Player::UpdateScroll() { // First, update for the player's movement... int center_x = DisplayUi->GetWidth() / 2 - TILE_SIZE / 2 - actual_pan_x / (SCREEN_TILE_WIDTH / TILE_SIZE); int center_y = DisplayUi->GetHeight() / 2 + TILE_SIZE / 2 - actual_pan_y / (SCREEN_TILE_WIDTH / TILE_SIZE); int dx = 0; int dy = 0; if (!Game_Map::IsPanLocked()) { if (IsMoving() || last_remaining_move > 0) { if (last_remaining_move == 0) last_remaining_move = SCREEN_TILE_WIDTH; int d = GetDirection(); if ((d == Right || d == UpRight || d == DownRight) && GetScreenX() > center_x) dx = 1; else if ((d == Left || d == UpLeft || d == DownLeft) && GetScreenX() < center_x) dx = -1; dx *= last_remaining_move - remaining_step; if ((d == Down || d == DownRight || d == DownLeft) && GetScreenY() > center_y) dy = 1; else if ((d == Up || d == UpRight || d == UpLeft) && GetScreenY() < center_y) dy = -1; dy *= last_remaining_move - remaining_step; last_remaining_move = remaining_step; } else if (IsJumping() || last_remaining_jump > 0) { if (last_remaining_jump == 0) last_remaining_jump = SCREEN_TILE_WIDTH; if ((GetX() > jump_x && GetScreenX() > center_x) || (GetX() < jump_x && GetScreenX() < center_x)) dx = (GetX() - jump_x) * (last_remaining_jump - remaining_step); if ((GetY() > jump_y && GetScreenY() > center_y) || (GetY() < jump_y && GetScreenY() < center_y)) dy = (GetY() - jump_y) * (last_remaining_jump - remaining_step); last_remaining_jump = remaining_step; } } Game_Map::ScrollRight(dx); Game_Map::ScrollDown(dy); // Second, update for the change in pan... int pan_x = Game_Map::GetPanX(); int pan_y = Game_Map::GetPanY(); int pan_dx = pan_x - last_pan_x; int pan_dy = pan_y - last_pan_y; last_pan_x = pan_x; last_pan_y = pan_y; // Change pan_dx/pan_dy to account for hitting the edges int screen_x = Game_Map::GetPositionX(); int screen_y = Game_Map::GetPositionY(); Game_Map::AddScreenX(screen_x, pan_dx); Game_Map::AddScreenY(screen_y, pan_dy); // Only move for the pan if we're closer to the target pan than we were before. if (std::abs(actual_pan_x + pan_dx - Game_Map::GetTargetPanX()) < std::abs(actual_pan_x - Game_Map::GetTargetPanX())) { Game_Map::ScrollRight(pan_dx); actual_pan_x += pan_dx; } if (std::abs(actual_pan_y + pan_dy - Game_Map::GetTargetPanY()) < std::abs(actual_pan_y - Game_Map::GetTargetPanY())) { Game_Map::ScrollDown(pan_dy); actual_pan_y += pan_dy; } }