void decrementCursor() { if (getCursorX() < 1) { if (getCursorY() < 1) { setCursorY(0); setCursorX(current_video_mode->width); } else { setCursorY(getCursorY() - 1); setCursorX(current_video_mode->width); } return; } setCursorX(getCursorX() - 1); }
void incrementCursor() { if (getCursorX() >= current_video_mode->width) { setCursorX(0); if (getCursorY() >= current_video_mode->height - 1) { newLine(); setCursorY(current_video_mode->height - 1); } else setCursorY(getCursorY() + 1); return; } else { setCursorX(getCursorX() + 1); } }
void video_reload() { int x, y; int old_x = getCursorX(); int old_y = getCursorY(); setCursor(FALSE); for(x = 0; x < current_video_mode->width; ++x) { for(y = 0; y < current_video_mode->height; ++y) { setCursorX(x); setCursorY(y); putC(current_video_mode->screen[x][y]); } } setCursor(TRUE); setCursorX(old_x); setCursorY(old_y); }
// Clears the screen from the given cursor to the end of the page. // And rolls the cursor back. void clear_screen_topdown() { int i = 0; int x = getCursorX(); int y = getCursorY(); setCursor(FALSE); while (i++ < (current_video_mode->width * (current_video_mode->height - y)) - x) { putchar(' '); } setCursor(TRUE); setCursorX(x); setCursorY(y); }
void Screen::setCursorYX(int y, int x) { setCursorY(y); setCursorX(x); }
// Starts default video. void initVideo() { clear_screen(); setCursorX(0); setCursorY(0); }
void moveCursorToStart() { setCursorX(0); setCursorY(0); }
void Mouse::think() { if (_animation) _animation->think(); SDL_GetMouseState(&_cursorX, &_cursorY); auto game = &Game::getInstance(); auto location = game->location(); if (location && game->states()->back()->scrollable()) { //check if cursor in the scrolling area if (cursorX() < 5) // LEFT { if (cursorY() < 5) // LEFT-UP { auto moved = location->scroll(true, false, true, false); setType( moved ? Mouse::SCROLL_NW : Mouse::SCROLL_NW_X); } else if (cursorY() > 475) //LEFT-DOWN { auto moved = location->scroll(false, true, true, false); setType(moved ? Mouse::SCROLL_SW : Mouse::SCROLL_SW_X); } else { auto moved = location->scroll(false, false, true, false); setType(moved ? Mouse::SCROLL_W : Mouse::SCROLL_W_X); } } else if (cursorX() > 635) // RIGHT { if (cursorY() < 5) // RIGHT-UP { auto moved = location->scroll(true, false, false, true); setType(moved ? Mouse::SCROLL_NE : Mouse::SCROLL_NE_X); } else if (cursorY() > 475) //RIGHT-DOWN { auto moved = location->scroll(false, true, false, true); setType(moved ? Mouse::SCROLL_SE : Mouse::SCROLL_SE_X); } else { auto moved = location->scroll(false, false, false, true); setType(moved ? Mouse::SCROLL_E : Mouse::SCROLL_E_X); } } else if (cursorY() < 5) // UP { auto moved = location->scroll(true, false, false, false); setType(moved ? Mouse::SCROLL_N : Mouse::SCROLL_N_X); } else if (cursorY() > 475) // DOWN { auto moved = location->scroll(false, true, false, false); setType(moved ? Mouse::SCROLL_S : Mouse::SCROLL_S_X); } else if (_type != _lastType) { setType(_lastType); } switch (type()) { case HEXAGON_RED: auto location = Game::getInstance().location(); int x = location->camera()->x() + this->cursorX(); int y = location->camera()->y() + this->cursorY(); unsigned int hexagon = location->positionToHexagon(x, y); setCursorX(location->hexagonToX(hexagon) - location->camera()->x()); setCursorY(location->hexagonToY(hexagon) - location->camera()->y()); break; } } }