Beispiel #1
0
void CaretLeft( LPCLASSDATA lpcd )
{
	/*
	 *	Do we have a block marker?
	 */
	if ( HasMark( lpcd ))
	{
		/*
		 *	Move to the start of the block.
		 */
		lpcd->ptCaretPos = lpcd->ptSelStart;

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

		/*
		 *	Update position.
		 */
		UpdateCaret( lpcd );
		return;
	}
	/*
	 *	Move left....
	 */
	MoveLeft( lpcd );
}
Beispiel #2
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);
}
Beispiel #3
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));
}
Beispiel #4
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;
		}
	}
}
Beispiel #5
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);
}
Beispiel #6
0
void Game_Character::MoveTypeCycleLeftRight() {
	if (IsStopping()) {
		cycle_stat ? MoveLeft() : MoveRight();

		cycle_stat = move_failed ? !cycle_stat : cycle_stat;
	}
}
Beispiel #7
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;
	}
}
Beispiel #8
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;
	}

}
Beispiel #9
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;
}
Beispiel #10
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);
}
Beispiel #11
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);
	//}
}
Beispiel #12
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);
}
Beispiel #13
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;
}
Beispiel #14
0
void Fall_Block::Move()
{
	MoveRight();
	MoveLeft();

	fall_block->pos.x() += fall_block->vector.x();
}
void AKeyboardControllerSFML::subStep(double dt) {
  if(!mEnabled) return;
  double MouseClickRelaxTime = SECOND / 4.0;
  double KeyRelaxTime = SECOND / 4.0;
  static double t = 0;
  static double t1 = 0;
  t += dt;
  t1 += dt;
  static int x = Game::Window->getSize().x / 2/* + Game::Window->getPosition().x*/;
  int dx = sf::Mouse::getPosition(*Game::Window).x;
  if(dx < 0) dx = 0;
  if(dx > Game::Window->getSize().x) dx = Game::Window->getSize().x;
  dx = x - dx;
  sf::Mouse::setPosition(sf::Vector2i(x, 500), *Game::Window);

  if(sf::Keyboard::isKeyPressed(sf::Keyboard::W)) {
    moveForward();
  }
  if(sf::Keyboard::isKeyPressed(sf::Keyboard::S)) {
    moveBack();
  }
  if(sf::Keyboard::isKeyPressed(sf::Keyboard::A)) {
    moveRight();
  }
  if(sf::Keyboard::isKeyPressed(sf::Keyboard::D)) {
    MoveLeft();
  }

  if(dx != 0) {
    turn((int)(dx /** Abs(dx) / 400*/));
  }

  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Right)) {
    turn(RIGHT);
  }
  if(sf::Keyboard::isKeyPressed(sf::Keyboard::Left)) {
    turn(LEFT);
  }

  if(sf::Mouse::isButtonPressed(sf::Mouse::Left) && t > MouseClickRelaxTime) {
    t = 0;
    character->mCombatModel->GenerateAction(Strike);
  }
  if(t1 > KeyRelaxTime) {
    if(sf::Keyboard::isKeyPressed(sf::Keyboard::R) ) {
      t1 = 0;
      character->mCombatModel->GenerateAction(HighHit);
    } else
    if(sf::Keyboard::isKeyPressed(sf::Keyboard::F)) {
      t1 = 0;
      character->mCombatModel->GenerateAction(MediumHit);
    } else
    if(sf::Keyboard::isKeyPressed(sf::Keyboard::V)) {
      t1 = 0;
      character->mCombatModel->GenerateAction(LowHit);
    }
  }

}
Beispiel #16
0
/*
 * SelectLeft - update selected region, moving left
 */
vi_rc SelectLeft( range *r, long count )
{
    if( !EditFlags.Dragging ) {
        startSelectedRegion( FALSE );
    }
    return MoveLeft( r, count );

} /* SelectLeft */
Beispiel #17
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);
}
Beispiel #18
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();
			}
		}
	}
}
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);
}
Beispiel #20
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;
		}
	}
}
Beispiel #21
0
void UIListTreeType::GoHome()
{

    while(curlevel > 0)
    {
        MoveLeft(false);
    }
    MoveUp(MoveMax);
    Redraw();
}
Beispiel #22
0
void CGUIPanelContainer::OnUp()
{
  CGUIAction action = GetAction(ACTION_MOVE_UP);
  bool wrapAround = action.GetNavigation() == GetID() || !action.HasActionsMeetingCondition();
  if (m_orientation == VERTICAL && MoveUp(wrapAround))
    return;
  if (m_orientation == HORIZONTAL && MoveLeft(wrapAround))
    return;
  CGUIControl::OnUp();
}
Beispiel #23
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);
}
Beispiel #24
0
void UIListTreeType::Redraw(void)
{
    if (!currentlevel)
    {
        return;
    }
    if (currentlevel->GetCount() == 0)
        MoveLeft();
    else
        emit requestUpdate();
}
Beispiel #25
0
void Game_Character::MoveTypeCycleLeftRight() {
	if (IsStopping()) {
		cycle_stat ? MoveLeft() : MoveRight();

		if (move_failed) {
			Wait();
			stop_count = 0;
			// TODO: After waiting, try once more in the same direction
			cycle_stat = move_failed ? !cycle_stat : cycle_stat;
		}
	}
}
Beispiel #26
0
void Enemy::AI(int *map){
	switch(enemyType) {
		case ENEMY_ONE:
			++movsps;
			if(movsps > 30) {
				movsps =0;
				rnd = rand()%100; 
			}
			else if (!throwing){
				if(rand()%1000 <= 5) {
					Jump(map);
				}
				if(rnd < 50) {
					MoveLeft(map);
				}
				else if (rnd > 50) {
					MoveRight(map);
				}
			}
			if (rand()%1000 < 9) Throw(map);
			break;

		case ENEMY_TWO:
			++movsps;
			if(movsps == 30) {
				movsps =0;
				rnd = rand()%100; 
			}
			if(rand()%1000 <= 5) {
				Jump(map);
			}
			if(rnd < 50) {
				MoveLeft(map);
			}
			else if (rnd > 50) {
				MoveRight(map);
			}
			break;
	}
}
Beispiel #27
0
void Camera3::DecelerateLeft(const double dt)
{
	if(straftVelocity < 0)
	{
		straftVelocity += -moveAcceleration * dt;
		MoveLeft(-dt);
	}
	else
	{
		straftVelocity = 0.f;
		straftMovingLeft = false;
	}
}
Beispiel #28
0
std::pair<int, int> BfsHelper::BacktrackFromSquare(std::pair<int, int> target_pos)
{
    //std::cout << "Backtrack path: "  << x << y << std::endl;

    if (!CanReachSquare(target_pos)) {
        std::cerr << "ERROR: Attempted backtracking from unreachable square!" << std::endl;
        return std::make_pair(-1, -1);
    }

    // Steps to square
    int steps = StepsToSquare(target_pos);

    // one step - found the next square
    if (steps == 1) {
        return target_pos;
    }

    // Shortest path is one step less
    if (StepsToSquare(MoveLeft(target_pos)) == (steps-1)) {
        return BacktrackFromSquare(MoveLeft(target_pos));
    }

    if (StepsToSquare(MoveRight(target_pos)) == (steps-1)) {
        return BacktrackFromSquare(MoveRight(target_pos));
    }

    if (StepsToSquare(MoveUp(target_pos)) == (steps-1)) {
        return BacktrackFromSquare(MoveUp(target_pos));
    }

    if (StepsToSquare(MoveDown(target_pos)) == (steps-1)) {
        return BacktrackFromSquare(MoveDown(target_pos));
    }

    // How did this happend??
    return std::make_pair(-1, -1);
}
Beispiel #29
0
Consoden::TankGame::Direction::Enumeration BfsHelper::FindDirection(std::pair<int, int> start_pos, std::pair<int, int> target_pos)
{
    if (MoveLeft(start_pos) == target_pos) {
        return Consoden::TankGame::Direction::Left;
    } else if (MoveRight(start_pos) == target_pos) {
        return Consoden::TankGame::Direction::Right;
    } else if (MoveUp(start_pos) == target_pos) {
        return Consoden::TankGame::Direction::Up;
    } else if (MoveDown(start_pos) == target_pos) {
        return Consoden::TankGame::Direction::Down;
    }

    std::cerr << "ERROR: FindDirection was called with a pair of squares which are not adjacent!" << std::endl;
    return Consoden::TankGame::Direction::Neutral;
}
Beispiel #30
0
void Game_Character::MoveRandom() {
	switch (rand() % 4) {
	case 0:
		MoveDown();
		break;
	case 1:
		MoveLeft();
		break;
	case 2:
		MoveRight();
		break;
	case 3:
		MoveUp();
		break;
	}
}