static int SDL_line(SDL_Surface* dst, int16_t x1, int16_t y1, int16_t x2, int16_t y2, uint8_t r, uint8_t g, uint8_t b, uint8_t a) { if(x1 == x2) return vlineRGBA(dst, x1, y1, y2, r, g, b, a); if(y1 == y2) return hlineRGBA(dst, x1, x2, y1, r, g, b, a); return lineRGBA(dst, x1, y1, x2, y2, r, g, b, a); }
void TriangleTool::draw(SDL_Renderer *r) { int x, y; SDL_GetMouseState(&x, &y); if (active && draw_bounds.collide_point(x, y)) { SDL_ShowCursor(SDL_DISABLE); hlineRGBA(r, x - pointer_width, x + pointer_width, y, 0, 0, 0, 255); vlineRGBA(r, x, y - pointer_width, y + pointer_width, 0, 0, 0, 255); } else SDL_ShowCursor(SDL_ENABLE); }
void GameDrawer::Draw() { boxRGBA(m_pSurface, m_pBoardMetrics->GetBoardLeft(), m_pBoardMetrics->GetBoardTop(), m_pBoardMetrics->GetBoardRight(), m_pBoardMetrics->GetBoardBottom(), GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B, 230); for(int nX=0; nX<=m_pBoardMetrics->GetWidth(); nX++) { vlineRGBA(m_pSurface, m_pBoardMetrics->GetLeftSpots() + nX*m_pBoardMetrics->GetPieceSize(), m_pBoardMetrics->GetTopSpots(), m_pBoardMetrics->GetBottomSpots(), 0, 0, 0, 255); } for(int nY=0; nY<=m_pBoardMetrics->GetHeight(); nY++) { hlineRGBA(m_pSurface, m_pBoardMetrics->GetLeftSpots(), m_pBoardMetrics->GetRightSpots(), m_pBoardMetrics->GetTopSpots() + nY*m_pBoardMetrics->GetPieceSize(), 0, 0, 0, 255); } for(int nX=0; nX<m_pBoardMetrics->GetWidth(); nX++) if( IsBinaryColDuplicate(m_Binary, nX) != BINARYLIB_ROW_UNIQUE ) { SDL_Rect rect; rect.w = m_pBoardMetrics->GetPieceSize(); rect.h = m_pBoardMetrics->GetBottomSpots() - m_pBoardMetrics->GetTopSpots(); rect.x = m_pBoardMetrics->GetXPos(nX); rect.y = m_pBoardMetrics->GetTopSpots(); SDL_FillRect(m_pSurface, &rect, SDL_MapRGB(m_pSurface->format, 255, 255, 0)); } for(int nY=0; nY<m_pBoardMetrics->GetHeight(); nY++) if( IsBinaryRowDuplicate(m_Binary, nY) != BINARYLIB_ROW_UNIQUE ) { SDL_Rect rect; rect.w = m_pBoardMetrics->GetRightSpots() - m_pBoardMetrics->GetLeftSpots(); rect.h = m_pBoardMetrics->GetPieceSize(); rect.x = m_pBoardMetrics->GetLeftSpots(); rect.y = m_pBoardMetrics->GetYPos(nY); SDL_FillRect(m_pSurface, &rect, SDL_MapRGB(m_pSurface->format, 255, 255, 0)); } for(int nX=0; nX<m_pBoardMetrics->GetWidth(); nX++) { for(int nY=0; nY<m_pBoardMetrics->GetHeight(); nY++) { DrawCell(nX, nY); } } }
void hc_menu::draw(void) { if(active) { active->draw(); return; } hc_box *tmp = nullptr; for(int i = 0; i < counter; i++) { if(is_in_rect(mouse_x, mouse_y, x, y + i * 64, max_width + 32, 48)) { tmp = box_active; if(mouse->get_state() == 1) { if(entries[i]->type == HC_MENU_ENTRY_SLIDER) { entries[i]->value = mouse_x - (x + entries[i]->width - 255 + 16); if(entries[i]->value > 255) { entries[i]->value = 255; } else if(entries[i]->value < 0) { entries[i]->value = 0; } } } } else { tmp = box_normal; } tmp->draw(x, y + i * 64, max_width + 32, 48); string label = entries[i]->label; if(entries[i]->type == HC_MENU_ENTRY_TEXT) { label += ": " + entries[i]->text_value; } else if(entries[i]->type == HC_MENU_ENTRY_TOOGLE) { vector<string> toogle = explode(entries[i]->text_value, '|'); label += ": " + toogle[entries[i]->value]; } else if(entries[i]->type == HC_MENU_ENTRY_PASSWORD) { label += ": "; for(uint8_t j = 0; j < entries[i]->text_value.length(); j++) // hide the password { label += "*"; } } else if(entries[i]->type == HC_MENU_ENTRY_SLIDER) { hlineRGBA(renderer, x + entries[i]->width - 255 + 16, x + entries[i]->width + 16, y + 24 + 64 * i, 0, 0, 0, 255); vlineRGBA(renderer, x + entries[i]->width - 255 + 16 + entries[i]->value, y + 24 + 64 * i - 5, y + 24 + 64 * i + 5, 0, 0, 0, 255); } text->print(x + width() / 2 - entries[i]->width / 2, y + 16 + 64 * i, 0, 0, label.c_str()); } }
int Surface::hline(Sint16 x, Sint16 y, Sint16 w, Uint8 r, Uint8 g, Uint8 b, Uint8 a) { return hlineRGBA(raw,x,x+w-1,y,r,g,b,a); }
void Game::UpdateDisplay() { m_ColorIntensity.Animate(); //Draw background if( !is_classic ) { SDL_BlitSurface(m_pBackground, NULL, m_pScreen, NULL); } else { SDL_FillRect(m_pScreen, NULL, SDL_MapRGB(m_pScreen->format, 255, 255, 255)); } int nWidth = GetHitoriBoardWidth(m_Hitori); int nHeight = GetHitoriBoardHeight(m_Hitori); int nPieceWidth = (SCREEN_WIDTH-1)/nWidth;//The -1 is just so range of pixels is 0->Dimension-1; instead of 0->Dimension int nPieceHeight = (SCREEN_HEIGHT-1)/nHeight; int nPieceSize = nPieceWidth < nPieceHeight ? nPieceWidth : nPieceHeight; int nBoardWidth = nPieceSize * nWidth; int nBoardHeight = nPieceSize * nHeight; int nTop = (SCREEN_HEIGHT - nBoardHeight) / 2; int nLeft = (SCREEN_WIDTH - nBoardWidth) / 2; /*SDL_Rect rectBoard; rectBoard.x = nLeft; rectBoard.y = nTop; rectBoard.w = nBoardWidth; rectBoard.h = nBoardHeight; SDL_FillRect(m_pScreen, &rectBoard, SDL_MapRGB(m_pScreen->format, GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B));*/ boxRGBA(m_pScreen, nLeft, nTop, nLeft + nBoardWidth, nTop + nBoardHeight, GAME_BACKGROUND_R, GAME_BACKGROUND_G, GAME_BACKGROUND_B, 180); for(int nX=0; nX<=nWidth; nX++) { vlineRGBA(m_pScreen, nLeft + nX*nPieceSize, nTop, nTop + nBoardHeight, 0, 0, 0, 255); } for(int nY=0; nY<=nHeight; nY++) { hlineRGBA(m_pScreen, nLeft, nLeft + nBoardWidth, nTop + nY*nPieceSize, 0, 0, 0, 255); } for(int nX=0; nX<nWidth; nX++) { for(int nY=0; nY<nHeight; nY++) { DrawCell(nX, nY, nLeft, nTop, nPieceSize); } } DrawSelector(nLeft, nTop, nPieceSize); #ifdef USE_GRAPHIC_YOU_WIN if( m_bGameOver ) { if( m_pWinGraphic == NULL ) { m_pWinGraphic = nSDL_LoadImage(image_HitoriYouWin); SDL_SetColorKey(m_pWinGraphic, SDL_SRCCOLORKEY, SDL_MapRGB(m_pWinGraphic->format, 255, 255, 255)); } SDL_Rect rectWin; rectWin.x = (SCREEN_WIDTH - m_pWinGraphic->w)/2; rectWin.y = (SCREEN_HEIGHT - m_pWinGraphic->h)/2; rectWin.w = m_pWinGraphic->w; rectWin.h = m_pWinGraphic->h; SDL_BlitSurface(m_pWinGraphic, NULL, m_pScreen, &rectWin); } #else if( !m_YouWinMessage.Animate() ) #endif { SDL_UpdateRect(m_pScreen, 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT); } }