示例#1
0
文件: UIelement.cpp 项目: J-Nunes/UI
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(), &section, 0.0f);
}
示例#2
0
int32_t
BoxObject::GetScreenY(ErrorResult& aRv)
{
    int32_t ret = 0;
    aRv = GetScreenY(&ret);
    return ret;
}
示例#3
0
文件: textbox.cpp 项目: fkfc/lobots
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);
     
}   
示例#4
0
文件: UIelement.cpp 项目: J-Nunes/UI
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;
	}
}
示例#5
0
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);
}
示例#6
0
int Game_Character::GetScreenZ() const {
	int z = this == Main_Data::game_player.get() ? 1 : 0;

	// For events on the screen, this should be inside a 0-40 range
	z += GetScreenY() >> 3;

	z += GetLayer() * 50;

	return z;
}
示例#7
0
文件: UIelement.cpp 项目: J-Nunes/UI
void Label::Draw()
{
	App->render->Blit(texture, GetScreenX(), GetScreenY(), NULL, 0.0f);
}
示例#8
0
文件: UIelement.cpp 项目: J-Nunes/UI
void InputText::Draw()
{
	App->render->Blit(texture, GetScreenX(), GetScreenY(), NULL, 0.0f);
}
示例#9
0
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;
	}
}