void FreeCamera::Update()
{
    float deltaT = 0.01f;
    static GLfloat ACCELERATION = 2.0f;

    if(GlobalVar::keys[GLFW_KEY_RIGHT_CONTROL])
        deltaT *= ACCELERATION;
    /* Camera movment*/
    if(GlobalVar::keys[GLFW_KEY_W]) MoveForward(deltaT);
    if(GlobalVar::keys[GLFW_KEY_S]) MoveForward(-deltaT);

    if(GlobalVar::keys[GLFW_KEY_A]) MoveRight(-deltaT);
    if(GlobalVar::keys[GLFW_KEY_D]) MoveRight(deltaT);

    if(GlobalVar::keys[GLFW_KEY_R]) MoveLift(deltaT);
    if(GlobalVar::keys[GLFW_KEY_F]) MoveLift(-deltaT);

    // Rotate camera
    if(GlobalVar::keys[GLFW_MOUSE_BUTTON_LEFT]){
        // Retrieve cursor current position
        GLdouble newposX, newposY;
        glfwGetCursorPos(GlobalVar::glfwWindow, &newposX, &newposY);

        static GLfloat Rx=0.0f, Ry=0.0f;
        static GLfloat MOUSESENSITIVTY =  0.1f;
        Rx = (GLfloat)(GlobalVar::dCursorRestpos[0] - newposX) * MOUSESENSITIVTY;
        Ry = (GLfloat)(newposY - GlobalVar::dCursorRestpos[1]) * MOUSESENSITIVTY;
        Rotate(Rx, Ry, 0);

        // Save last cursor position
        GlobalVar::dCursorRestpos[0] = newposX;
        GlobalVar::dCursorRestpos[1] = newposY;
    }
}
Exemplo n.º 2
0
void Camera::Input()
{
	float sensitivity = 0.001f;
	float movAmt = static_cast<float>(10 * Time::GetDelta());
	float rotAmt = static_cast<float>(1.5f * Time::GetDelta());

	if (Input::GetMouseDown(GLFW_MOUSE_BUTTON_1))
	{
		m_cursorStoredPos = Input::GetCursorPosition();
		vec2 centerPos = vec2((float)WIDTH / 2.0f, (float)WIDTH / 2.0f);
		Input::SetCursorPosition(centerPos);
		Input::SetCursorVisibility(false);
		m_mouselocked = true;
	}

	if (Input::GetMouseUp(GLFW_MOUSE_BUTTON_1))
	{
		Input::SetCursorPosition(m_cursorStoredPos);
		Input::SetCursorVisibility(true);
		m_mouselocked = false;
	}

	if (m_mouselocked)
	{
		vec2 centerPos = vec2((float)WIDTH / 2.0f, (float)WIDTH / 2.0f);
		vec2 currentPos = Input::GetCursorPosition();
		vec2 deltaPos = centerPos - currentPos;

		bool rotY = deltaPos.x != 0;
		bool rotX = deltaPos.y != 0;

		if (rotY)
			RotateY(deltaPos.x * sensitivity);
		if (rotX)
			RotateX(deltaPos.y * sensitivity);

		if (rotY || rotX)
			Input::SetCursorPosition(centerPos);
	}

	if (Input::GetKey(GLFW_KEY_W))
	{
		MoveUp(movAmt);
	}
	if (Input::GetKey(GLFW_KEY_S))
	{
		MoveUp(-movAmt);
	}
	if (Input::GetKey(GLFW_KEY_D))
	{
		MoveRight(movAmt);
	}
	if (Input::GetKey(GLFW_KEY_A))
	{
		MoveRight(-movAmt);
	}

}
/*
* Putting my own functionality in the TouchUpdate; this way we can swipe up/down/left/right from the center
* of the screen and move the character in that direction.
*/
void ASterlingResortsCharacter::TouchUpdate(const ETouchIndex::Type FingerIndex, const FVector Location)
{
    if ((TouchItem.bIsPressed == true) && (TouchItem.FingerIndex == FingerIndex))
    {
        if (TouchItem.bIsPressed)
        {
            if (GetWorld() != nullptr)
            {
                UGameViewportClient* ViewportClient = GetWorld()->GetGameViewport();
                if (ViewportClient != nullptr)
                {
                    FVector2D ScreenSize;
                    ViewportClient->GetViewportSize(ScreenSize);
                    FVector2D ScreenCenter = ScreenSize / 2.0f;

                    FVector MoveDelta = Location - TouchItem.Location;
                    FVector2D ScaledDelta = FVector2D(MoveDelta.X, MoveDelta.Y) / ScreenSize;
                    //FVector2D ScaledDelta = FVector2D(MoveDelta.X - ScreenCenter.X, MoveDelta.Y - ScreenCenter.Y) / ScreenCenter;
                    if (ScaledDelta.X != 0.0f)
                    {
                        TouchItem.bMoved = true;
                        MoveRight(ScaledDelta.X * BaseTurnRate * -1.0f);
                    }
                    if (ScaledDelta.Y != 0.0f)
                    {
                        TouchItem.bMoved = true;
                        MoveForward(ScaledDelta.Y * BaseTurnRate * -1.0f);
                    }
                }
            }
        }
    }
}
Exemplo n.º 4
0
void BfsHelper::EvaluateShortestPaths(std::pair<int, int> pos, int steps)
{
    EvaluateShortestPathsHelper(pos, MoveLeft(pos), steps);
    EvaluateShortestPathsHelper(pos, MoveRight(pos), steps);
    EvaluateShortestPathsHelper(pos, MoveUp(pos), steps);
    EvaluateShortestPathsHelper(pos, MoveDown(pos), steps);
}
Exemplo n.º 5
0
void CaretRight( LPCLASSDATA lpcd )
{
	/*
	 *	Block marker set?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to the end of the marker.
		 */
		lpcd->ptCaretPos = lpcd->ptSelEnd;

		/*
		 *	Clear marker.
		 */
		ClearMark( lpcd );

		/*
		 *	Update position.
		 */
		UpdateCaret( lpcd );
		return;
	}
	/*
	 *	Move the caret right.
	 */
	MoveRight( lpcd );
}
Exemplo n.º 6
0
void Game_Player::Update() {
	bool last_moving = IsMoving();

	if (!IsMoving() && !Game_Map::GetInterpreter().IsRunning() 
		&& !IsMoveRouteOverwritten() && !Game_Message::message_waiting) {
		switch (Input::dir4) {
			case 2:
				MoveDown();
				break;
			case 4:
				MoveLeft();
				break;
			case 6:
				MoveRight();
				break;
			case 8:
				MoveUp();
		}
	}

	int last_real_x = real_x;
	int last_real_y = real_y;

	Game_Character::Update();

	UpdateScroll(last_real_x, last_real_y);

	UpdateNonMoving(last_moving);
}
Exemplo n.º 7
0
void Fall_Block::Move()
{
	MoveRight();
	MoveLeft();

	fall_block->pos.x() += fall_block->vector.x();
}
Exemplo n.º 8
0
void Game_Character::MoveTypeCycleLeftRight() {
	if (IsStopping()) {
		cycle_stat ? MoveLeft() : MoveRight();

		cycle_stat = move_failed ? !cycle_stat : cycle_stat;
	}
}
Exemplo n.º 9
0
void Camera::Update(GameTime gameTime)
{
	// Check for movement of the camera.
	if(GetAsyncKeyState('Q'))
		MoveLeft(gameTime);
	else if(GetAsyncKeyState('E'))
		MoveRight(gameTime);

	if(GetAsyncKeyState('W'))
		MoveForward(gameTime);
	else if(GetAsyncKeyState('S'))
		MoveBack(gameTime);

	if(GetAsyncKeyState('A'))
		TurnHorizontal((float)(-gameTime.GetTimeSinceLastTick().Milliseconds) * C_TILTING_SPEED);
	else if(GetAsyncKeyState('D'))
		TurnHorizontal((float)gameTime.GetTimeSinceLastTick().Milliseconds * C_TILTING_SPEED);

	// Check for tilting of camera.
	//if(GetAsyncKeyState(VK_LBUTTON))
	//{
	//	float dx = prevInput.Mouse.x - currInput.Mouse.x;
	//	float dy = prevInput.Mouse.y - currInput.Mouse.y;
	//	//TurnHorizontal(dx * C_TILTING_SPEED);
	//	//TurnVertical(dy * C_TILTING_SPEED);
	//}
}
Exemplo n.º 10
0
// Handle and events
void TEXTBOX::Handle(INPUT_RECORD *inpt, int i){
	switch (inpt[i].EventType)
	{
	case KEY_EVENT: // keyboard input 
	{
						KEY_EVENT_RECORD ker = inpt[i].Event.KeyEvent;
						if (ker.bKeyDown && this->focus){
							switch (ker.wVirtualKeyCode){
							case VK_BACK:
								BackSpace();
								break;
							case VK_RIGHT:
							case VK_NUMPAD6:
								MoveRight();
								break;
							case VK_LEFT:
							case VK_NUMPAD4:
								MoveLeft();
								break;
							case VK_RETURN:
								break;
							case VK_DELETE:
								Delete();
								break;
							default:
								if ((ker.wVirtualKeyCode >= 65 && ker.wVirtualKeyCode <= 90) || (ker.wVirtualKeyCode >= 97 && ker.wVirtualKeyCode <= 122) || (ker.wVirtualKeyCode >= 48 && ker.wVirtualKeyCode <= 57) || (ker.wVirtualKeyCode == 32))
									PutChar(ker.wVirtualKeyCode);
								break;
							}
						}
	}
		break;

	case MOUSE_EVENT: // mouse input 
	{
						  MOUSE_EVENT_RECORD ker = inpt[i].Event.MouseEvent;
						  if (ker.dwButtonState == FROM_LEFT_1ST_BUTTON_PRESSED){
							  if (IsClicked(ker.dwMousePosition)){
								  SetColors();
								  SetFocus(&ker.dwMousePosition);
							  }
							  else{
								  SetFocus(NULL);
							  }
						  }
	}
		break;

	case WINDOW_BUFFER_SIZE_EVENT: // scrn buf. resizing 	
		break;

	case FOCUS_EVENT:  // disregard focus events 

	case MENU_EVENT:   // disregard menu events 
		break;

	default:
		break;
	}
}
Exemplo n.º 11
0
bool Dock::HandleEvent( sf::Event &e )
{
    if( e.Type == sf::Event::KeyPressed ) {
        switch( e.Key.Code ) {
            case sf::Key::Escape:
                Deactivate();
                break;
            case sf::Key::Up:
                MoveUp();
                break;
            case sf::Key::Down:
                MoveDown();
                break;
            case sf::Key::Left:
                MoveLeft();
                break;
            case sf::Key::Right:
                MoveRight();
                break;
            case sf::Key::Return:
            case sf::Key::Space:
                Execute();
                break;
            default:
                break;
        }
    }
    return true;
}
Exemplo n.º 12
0
// Update
void Game_Player::Update() {
	bool last_moving = IsMoving();

	if (!IsMoving() && !Game_Map::GetInterpreter().IsRunning()
		/*move_route_forcing || Game_Temp::message_window_showing*/) {
		switch (Input::dir4) {
			case 2:
				MoveDown();
				break;
			case 4:
				MoveLeft();
				break;
			case 6:
				MoveRight();
				break;
			case 8:
				MoveUp();
		}
	}

	int last_real_x = real_x;
	int last_real_y = real_y;

	Game_Character::Update();

	UpdateScroll(last_real_x, last_real_y);

	UpdateNonMoving(last_moving);
}
Exemplo n.º 13
0
/********************************************************************************
Strafe left or right. You can add in a deadzone here.
********************************************************************************/
void TPCamera::Strafe(const double dt)
{
	if (dt > 0)
		MoveRight(dt);
	else if (dt < 0)
		MoveLeft(abs(dt));
}
Exemplo n.º 14
0
void Player::Update(float deltaTime){
	animationTime+=deltaTime;
	isBlocking = false;
	if(KeyHandler::getKeys()->Key_Space)
	{
		Body->SetTransform(Body->GetPosition(),1.57079633f);
		isBlocking=true;
		jumpCharge=0;
	}
	else
	{
		Body->SetTransform(Body->GetPosition(),0);
		isBlocking=false;
		if(KeyHandler::getKeys()->Key_Up)
		{
			jumpCharge-=(jumpForceLevel+jumpCharge)/50;
		}
		else if(jumpCharge!=0)
		{
			Jump();
			jumpCharge=0;
			inAir = true;
		}
		if(KeyHandler::getKeys()->Key_Left)
			this->MoveLeft();
		if(KeyHandler::getKeys()->Key_Right)
			MoveRight();
	}


}
Exemplo n.º 15
0
/******************************************************************************
**
Strafe left or right. You can add in a deadzone here.
*******************************************************************************
*/
void Camera3::Strafe(const double dt)
{
	if(dt > 0)	//right
	{
		straftMovingRight = true;
		straftMovingLeft = false;
	}
	else
	{
		straftMovingRight = false;
		straftMovingLeft = true;
	}

	/* update */
	straftVelocity += moveAcceleration * dt;

	/* cap vel */
	if(straftVelocity > CAMERA_MAX_VELOCITY)
		straftVelocity = CAMERA_MAX_VELOCITY;
	else if(straftVelocity < -CAMERA_MAX_VELOCITY)
		straftVelocity = -CAMERA_MAX_VELOCITY;
		
	
	if(dt < 0)
		MoveLeft(-dt);
	else if(dt >= 0)
		MoveRight(dt);
}
Exemplo n.º 16
0
void EnemyMelee::Pat(Player* player)
{
	if(AccumulatedTime > GetDelay())
	{
		AccumulatedTime = 0.0;

		if(CalculateDistance_x() <= 192 && CalculateDistance_y() <= 192 && player->getIsHiding() != true)
		{
			Move();
		}
		else
		{
			if(Flush != true && colData[abs(static_cast<int>(GetPos_y())/32) + 25][static_cast<int>(GetPos_x())/32 + 1] < 100)
			{
				MoveRight();
			}

			if(Flush == true && colData[abs(static_cast<int>(GetPos_y())/32) + 25][static_cast<int>(GetPos_x())/32 - 1] < 100)
			{
				MoveLeft();
			}
		}


		if(colData[abs(static_cast<int>(GetPos_y())/32) + 25][static_cast<int>(GetPos_x())/32 + 1] >= 100)
		{
			Flush = true;
		}

		if(colData[abs(static_cast<int>(GetPos_y())/32) + 25][static_cast<int>(GetPos_x())/32 - 1] >= 100)
		{
			Flush = false;
		}
	}
}
Exemplo n.º 17
0
int CGUIListBox::Keyboard(UINT character, UINT state)
{
	if(character == VK_RETURN)
	{
		if(markListItem)
			EventArise(EList,0,markListItem->GetID(),0,0,0);
	}

	if (character == VK_UP) {
		MoveUp();
	}

	if (character == VK_DOWN) {
		MoveDown();
	}

	if (character == VK_RIGHT) {
		MoveRight();
	}

	if (character == VK_LEFT) {
		MoveLeft();
	}

	return 1;
}
Exemplo n.º 18
0
void Camera3::Update(double dt)
{
	int k = 'a';
	if(myKeys['w'])
	{
		MoveForward(dt);
		myKeys['w'] = false;
	}
	if(myKeys['a'])
	{
		MoveLeft(dt);
		myKeys['a'] = false;
	}
	if(myKeys['s'])
	{
		MoveBackward(dt);
		myKeys['s'] = false;
	}
	if(myKeys['d'])
	{
		MoveRight(dt);
		myKeys['d'] = false;
	}

}
Exemplo n.º 19
0
/*
 * SelectRight - update selected region, moving right
 */
vi_rc SelectRight( range *r, long count )
{
    if( !EditFlags.Dragging ) {
        startSelectedRegion( FALSE );
    }
    return MoveRight( r, count );

} /* SelectRight */
Exemplo n.º 20
0
int EList::ExecCommand(int Command, ExState &State) {
    int W = 1;
    int H = 1;

    if (View && View->MView && View->MView->Win) {
        View->MView->ConQuerySize(&W, &H);
        H--;
    }
    FixPos();
    switch (Command) {
    case ExMoveLeft:
        return MoveLeft();
    case ExMoveRight:
        return MoveRight();
    case ExMoveUp:
        return MoveUp();
    case ExMoveDown:
        return MoveDown();
    case ExMovePageUp:
        return MovePageUp();
    case ExMovePageDown:
        return MovePageDown();
    case ExScrollLeft:
        return ScrollLeft(8);
    case ExScrollRight:
        return ScrollRight(8);
    case ExMovePageStart:
        return MovePageStart();
    case ExMovePageEnd:
        return MovePageEnd();
    case ExMoveFileStart:
        return MoveFileStart();
    case ExMoveFileEnd:
        return MoveFileEnd();
    case ExMoveLineStart:
        return MoveLineStart();
    case ExMoveLineEnd:
        return MoveLineEnd();
    case ExRescan:
        RescanList();
        return ErOK;
    case ExActivate:
        return Activate();
    case ExListMark:
        return Mark();
    case ExListUnmark:
        return Unmark();
    case ExListToggleMark:
        return ToggleMark();
    case ExListMarkAll:
        return MarkAll();
    case ExListUnmarkAll:
        return UnmarkAll();
    case ExListToggleMarkAll:
        return ToggleMarkAll();
    }
    return EModel::ExecCommand(Command, State);
}
void cBall::Move(int *map)
{
	int state = GetState();

	if (state == STATE_WALKLEFT)		MoveLeft(map);
	else if (state == STATE_WALKRIGHT)	MoveRight(map);
	else if (state == STATE_WALKDOWN)	MoveDown(map);
	else if (state == STATE_WALKUP)		MoveUp(map);
}
Exemplo n.º 22
0
void Character::Tick()
{
	/** INVENTORY **/
	inventoryBar->Tick();

	/** STAMINA **/
	staminaBar->Tick();

	/** HEALTH **/
	healthBar->Tick();

	/** MOVEMENT **/
	if(game->keyboard->isPressed(VK_LSHIFT)) {
		if(game->keyboard->isPressed(VK_LEFT) | game->keyboard->isPressed('A'))
			SprintLeft();
		else if(game->keyboard->isPressed(VK_RIGHT) | game->keyboard->isPressed('D'))
			SprintRight();
	}
	else {
		if(game->keyboard->isPressed(VK_LEFT) | game->keyboard->isPressed('A'))
			MoveLeft();
		else if(game->keyboard->isPressed(VK_RIGHT) | game->keyboard->isPressed('D'))
			MoveRight();
	}

	/** JUMPING **/
	if(game->keyboard->isPressed(VK_SPACE) && !isJumpingUp && !isFallingDown) {
		isJumpingUp = true;
		jumpGoal = y+140;
	}

	/** GG PHYSICS **/
	if(isJumpingUp) {
		if(y < (jumpGoal - jumpPower)) {
			y += jumpPower;
		}
		else if(y < jumpGoal && y >= (jumpGoal - jumpPower)) {
			y = jumpGoal;
		}
		else if(y == jumpGoal) {
			isJumpingUp = false;
			isFallingDown = true;
		}
	}
	if(isFallingDown) {
		std::cout << y << ": ";
		if(y >= (height/2 + gravity)) {
			y -= gravity;
		}
		else if(y > height/2 && y < (height/2 + gravity)) {
			y = height/2;
		}
		else if(y == height/2) {
			isFallingDown = false;
		}
	}
}
Exemplo n.º 23
0
void TextBox::AddCharecter(char c) {
	if (focus) {
		if (textIndex < boxSize) {
			text[textIndex] = c;
			cout << c;
			MoveRight();
		}
	}
}
Exemplo n.º 24
0
void Game_Character::MoveAwayFromPlayer() {
	int sx = DistanceXfromPlayer();
	int sy = DistanceYfromPlayer();

	if (sx != 0 || sy != 0) {
		if ( std::abs(sx) > std::abs(sy) ) {
			(sx > 0) ? MoveRight() : MoveLeft();
			if (move_failed && sy != 0) {
				(sy > 0) ? MoveDown() : MoveUp();
			}
		} else {
			(sy > 0) ? MoveDown() : MoveUp();
			if (move_failed && sx != 0) {
				(sx > 0) ? MoveRight() : MoveLeft();
			}
		}
	}
}
Exemplo n.º 25
0
void CGUIPanelContainer::OnDown()
{
  CGUIAction action = GetAction(ACTION_MOVE_DOWN);
  bool wrapAround = action.GetNavigation() == GetID() || !action.HasActionsMeetingCondition();
  if (m_orientation == VERTICAL && MoveDown(wrapAround))
    return;
  if (m_orientation == HORIZONTAL && MoveRight(wrapAround))
    return;
  return CGUIControl::OnDown();
}
Exemplo n.º 26
0
void Restore(BTNode *p,int i)
//关键字删除后,调整B-树,找到一个关键字将其插入到p->ptr[i]中
{
	if (i==0)							//为最左边关键字的情况
		if (p->ptr[1]->keynum>Min)
			MoveLeft(p,1);
		else
			Combine(p,1);
	else if (i==p->keynum)				//为最右边关键字的情况
		if (p->ptr[i-1]->keynum>Min)
			MoveRight(p,i);
		else
			Combine(p,i);
	else if (p->ptr[i-1]->keynum>Min)	//为其他情况
		MoveRight(p,i);
	else if (p->ptr[i+1]->keynum>Min)
		MoveLeft(p,i+1);
	else
		Combine(p,i);
}
Exemplo n.º 27
0
void CGUIPanelContainer::OnRight()
{
  CGUIAction action = GetAction(ACTION_MOVE_RIGHT);
  bool wrapAround = action.GetNavigation() == GetID() || !action.HasActionsMeetingCondition();
  if (GetGlobalWrapDisable())
    wrapAround = false;
  if (m_orientation == VERTICAL && MoveRight(wrapAround))
    return;
  if (m_orientation == HORIZONTAL && MoveDown(wrapAround))
    return;
  return CGUIControl::OnRight();
}