void Camera::Move3D() {
	if (m_moveState.forward) {
		Walk(m_speed * m_msec);
	}

	if (m_moveState.back) {
		Walk(-m_speed * m_msec);
	}

	if (m_moveState.left) {
		Strafe(m_speed * m_msec);
	}

	if (m_moveState.right) {
		Strafe(-m_speed * m_msec);
	}

	if (m_moveState.up) {
		Lift(m_speed * m_msec);
	}

	if (m_moveState.down) {
		Lift(-m_speed * m_msec);
	}
}
Beispiel #2
0
void BatRunThink (objtype *obj)
{
	id0_int_t deltax,deltay;

	deltax=player->tilex - obj->tilex;
	deltay=player->tiley - obj->tiley;

	if (deltax>=0)
		deltax = 0;
	else
		deltax = 2;

	if (deltay>=0)
		deltay = 0;
	else
		deltay = 2;

	obj->dir = dirtable[deltay*3+deltax];
	if (Walk(obj))
		return;

	obj->dir = dirtable[3+deltax];
	if (Walk(obj))
		return;

	obj->dir = dirtable[deltay*3+1];
	Walk(obj);
}
Beispiel #3
0
HRESULT Camera::HandleMessages(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
	switch(uMsg)
	{
	case WM_KEYDOWN:
		{
			switch( wParam )
			{
			case 'A':
			case VK_LEFT:
				Strafe(-0.1f) ;
				return TRUE ;

			case 'D':
			case VK_RIGHT:
				Strafe(0.1f) ;
				return TRUE ;

			case 'W':
			case VK_UP:
				Walk(0.1f) ;
				return TRUE ;

			case 'S':
			case VK_DOWN:
				Walk(-0.1f) ;
				return TRUE ;
			}
		}
	}

	return FALSE ;
}
Beispiel #4
0
void BatChaseThink (objtype *obj)
{
	id0_int_t deltax,deltay;

	deltax=player->tilex - obj->tilex;
	deltay=player->tiley - obj->tiley;

	if (deltax>0)
		deltax = 2;
	else if (deltax<0)
		deltax = 0;
	else deltax = 1;

	if (deltay>0)
		deltay = 2;
	else if (deltay<0)
		deltay = 0;
	else deltay = 1;

	obj->dir = dirtable[deltay*3+deltax];
	if (Walk(obj))
		return;

	obj->dir = dirtable[3+deltax];
	if (Walk(obj))
		return;

	obj->dir = dirtable[deltay*3+1];
	if (Walk(obj))
		return;

	obj->dir = nodir;
}
HRESULT STDMETHODCALLTYPE TextAreaTextRange::MoveEndpointByUnit(_In_ TextPatternRangeEndpoint endpoint, _In_ TextUnit unit, _In_ int count, _Out_ int *retVal)
{
    if (!IsWindow(_hwnd))
    {
        return UIA_E_ELEMENTNOTAVAILABLE;
    }
    *retVal = 0;

    if (endpoint == TextPatternRangeEndpoint_Start)
    {
        _range.begin = Walk(_range.begin, count > 0, unit, 0, abs(count), retVal);
        if (QuickCompareEndpoints(_range.begin, _range.end) > 0)
        {
            _range.end = _range.begin;
        }
    }
    else
    {
        _range.end = Walk(_range.end, count > 0, unit, 0, abs(count), retVal);
        if (QuickCompareEndpoints(_range.begin, _range.end) > 0)
        {
            _range.begin = _range.end;
        }
    }


    return S_OK;
}
HRESULT STDMETHODCALLTYPE TextAreaTextRange::Move(_In_ TextUnit unit, _In_ int count, _Out_ int *retVal)
{
    if (!IsWindow(_hwnd))
    {
        return UIA_E_ELEMENTNOTAVAILABLE;
    }
    *retVal = 0;

    bool isDegenerate = (QuickCompareEndpoints(_range.begin, _range.end) == 0);

    int walked;
    EndPoint back = Walk(_range.begin, false, unit, 0, 0, &walked);

    EndPoint destination = Walk(back, count > 0, unit, 0, abs(count), retVal);

    _range.begin = destination;
    _range.end = destination;

    if (!isDegenerate)
    {
        return ExpandToEnclosingUnit(unit);
    }

    return S_OK;
}
Beispiel #7
0
void FPS_Cam::UpdateInput(double dt)	//update if inputs available
{
	/* Strafe */
	if (CU::input.IsKeyPressed(Input::A) && !CU::input.IsKeyPressed(Input::D))
	{
		Strafe(-dt);
	}

	if (!CU::input.IsKeyPressed(Input::A) && CU::input.IsKeyPressed(Input::D))
	{
		Strafe(dt);
	}

	/* walk */
	if (CU::input.IsKeyPressed(Input::W) && !CU::input.IsKeyPressed(Input::S))
	{
		Walk(dt);
	}

	if (!CU::input.IsKeyPressed(Input::W) && CU::input.IsKeyPressed(Input::S))
	{
		Walk(-dt);
	}

	/* Fly */
	if (CU::input.IsKeyPressed(Input::K))
	{
		Fly(dt);
	}
	else if (CU::input.IsKeyPressed(Input::L))
	{
		Fly(-dt);
	}
}
Beispiel #8
0
int main()
{
    /**
    Initally there are walls everywhere,
    each move breaks walls
    */
    int N=0;
    scanf("%d",&N);
    for(int k=1;k<=N;k++)
    {
        scanf("%s %s",path[0],path[1]);

        POINT minpt(0,0), maxpt(0,0);

        POINT dir(0,-1);
        POINT pos(0,1);

        Walk(path[0],pos,dir, minpt,maxpt);

        dir=-dir;
        Walk(path[1],pos,dir, minpt,maxpt);

        printf("Case #%d:\n",k);
        for(int y=maxpt.imag();y>=minpt.imag();y--)
        {
            for(int x=minpt.real();x<=maxpt.real();x++)
            printf("%x",maze[std::make_pair(x,y)]);
            printf("\n");
        }

        maze.clear();
    }

    return 0;
}
Beispiel #9
0
void Camera3::Update(double dt, bool* myKeys)
{/*
	Vector3 view = (target - position).Normalized();
	Vector3 right = view.Cross(up);
	right.y = 0;
	Inertia: instant dir change

	* strafe */
	if(myKeys[KEY_A] && !myKeys[KEY_D])
		Strafe(-dt);
	else if(straftMovingLeft)
		DecelerateLeft(-dt);

	if(myKeys[KEY_D] && !myKeys[KEY_A])
		Strafe(dt);
	else if(straftMovingRight)
		DecelerateRight(dt);

	/* walk */
	if(myKeys[KEY_W] && !myKeys[KEY_S])
		Walk(dt);
	else if(walkMovingForward)
		DecelerateForward(dt);

	if(myKeys[KEY_S] && !myKeys[KEY_W])
		Walk(-dt);
	else if(walkMovingBackward)
		DecelerateBackward(-dt);

	if(myKeys[KEY_C] && !croutching)
		croutching = true;

	croutch(dt);


	/* fly */
	if(myKeys[KEY_K])
		Fly(dt);
	if(myKeys[KEY_L])
		Fly(-dt);

	if(myKeys[KEY_SPACE] && !jump)	//com runs too fast, spacebar 2 times
		setJump(dt);

	if(myKeys[KEY_T])	//reset
	{
		Reset();
	}
	

	/** update jump **/
	if(jump)
		Jump(dt);
	

	/** mouse **/
	Yaw(dt);
	Pitch(dt);
}
Beispiel #10
0
/**
 * Walk a tree, calling action once on each node.
 *
 * Operation:
 *   This routine walks through the specified sub_tree and invokes action
 *   action at each node as follows:
 *       action(context, data, level)
 *   data  the data contents of the node being visited,
 *   level is the level of the node in the tree with the root being level 0.
 * @param tree  root of the tree being walked.
 * @param action  action to be performed at every node
 * @param context  action's context
 * @param sub_tree  ptr to root of subtree to be walked
 * @param level  current level in the tree for this node
 */
void Walk(KDTREE *tree, void_proc action, void *context,
          KDNODE *sub_tree, inT32 level) {
  (*action)(context, sub_tree->Data, level);
  if (sub_tree->Left != NULL)
    Walk(tree, action, context, sub_tree->Left, NextLevel(tree, level));
  if (sub_tree->Right != NULL)
    Walk(tree, action, context, sub_tree->Right, NextLevel(tree, level));
}
Beispiel #11
0
// Determines the start point where the comparison of the current cluster must begin
// for the orientation "rotSym"
Pt StartPt(int rotSym, int name) {
	Pt p = Walk(minP, 1, rotSym) ;
	Pt res = minP ;
	if( p.x < minP.x )
		res.x = maxP.x ;
	if( p.y < minP.y )
		res.y = maxP.y ;
	while( get(res) != name )
		res = Walk(res, 0, rotSym) ;
	return res ;
}
Beispiel #12
0
// Compares two clusters according to the orientation "rotSym"
int CompareX(Pt p, Pt q, int arrow, int rotSym) {
	int a ;
	Pt np = Walk(p, arrow, 0), nq = Walk(q, arrow, rotSym) ;
	if( get(np) == '0' ) return get(nq) == '0' ;
	if( get(np) == '1' ) return true ;
	set(np, '1') ;

	if( get(nq) == '0' ) return false ;
	for( a = 0 ; a < 8 ; a++ )
		if( !CompareX(np, nq, a, rotSym) ) return false ;
	return true ;
}
Beispiel #13
0
void Entity::GoSideToSide(float dt)
{
	if (mGoUp)
	{
		Walk(dt*movementMult);
		if (mPosition.z > mOrigZ + mHeightToGo){ mGoUp = false; mGoDown = true; }
	}
	if (mGoDown)
	{
		Walk(-dt*movementMult);
		if (mPosition.z < mOrigZ - mHeightToGo){ mGoUp = true; mGoDown = false; }
	}
}
Beispiel #14
0
/* Registra informações sobre os comodos de uma planta */
void SetRooms(CharMat** Ap, int* nRooms, Stack** RoomSizes){

  int m = (*Ap)->lines;
  int n = (*Ap)->cols;
  int status;
  int roomSize;
  
  *nRooms = 0;
  
  for(int i=1; i<m-1; i++){
    for(int j=1; j<n-1; j++){
      
      status = IsRoomEdge(Ap, i, j);

      if(status > 0){
        
        roomSize = 0;
        
        Walk(Ap, i, j, &roomSize);

        if(roomSize > 0){
          (*nRooms)++;
          if(RoomSizes){
            InOrderStack(RoomSizes, roomSize);        
          }
        }
      }    
    }
  }
}
Beispiel #15
0
void ArrayUtil::Walk(VRefParam input, PFUNC_WALK walk_function,
                     const void *data, bool recursive /* = false */,
                     PointerSet *seen /* = NULL */,
                     CVarRef userdata /* = null_variant */) {
  assert(walk_function);

  Variant k;
  Variant v;
  for (MutableArrayIter iter = input->begin(&k, v); iter.advance(); ) {
    if (recursive && v.is(KindOfArray)) {
      assert(seen);
      ArrayData *arr = v.getArrayData();

      if (v.isReferenced()) {
        if (seen->find((void*)arr) != seen->end()) {
          raise_warning("array_walk_recursive(): recursion detected");
          return;
        }
        seen->insert((void*)arr);
      }

      Walk(directRef(v), walk_function, data, recursive, seen, userdata);
      if (v.isReferenced()) {
        seen->erase((void*)arr);
      }
    } else {
      walk_function(directRef(v), k, userdata, data);
    }
  }
}
Beispiel #16
0
void Walk(boost::filesystem::path p, unsigned short int top, std::string prefix, file_list& files)
{
    boost::filesystem::directory_iterator end;
    if(!boost::filesystem::exists(p))
    {
        std::cerr << "Could not open " << p.string() << std::endl;
        return;
    }

    top = AddFile(p, top, prefix, files);

    for(boost::filesystem::directory_iterator it(p); it != end; ++it)
    {
        if(!boost::filesystem::is_directory(it->status()))
            AddFile(it->path(), top, prefix, files);
        else
        {
            char* dirname;
            dirname = new char[strlen(it->path().string().c_str())+2];
            strcpy(dirname, it->path().string().c_str());
            Walk(dirname, top, prefix, files);
            delete[] dirname;
        }
    }
}
Beispiel #17
0
	int Ardb::ZRank(const DBID& db, const Slice& key, const Slice& member)
	{
		ZSetMetaValue meta;
		if (0 != GetZSetMetaValue(db, key, meta))
		{
			return ERR_NOT_EXIST;
		}
		Slice empty;
		ZSetKeyObject start(key, empty, meta.min_score, db);
		struct ZRankWalk: public WalkHandler
		{
				int rank;
				ValueObject z_member;
				int foundRank;
				int OnKeyValue(KeyObject* k, ValueObject* v, uint32 cursor)
				{
					ZSetKeyObject* zko = (ZSetKeyObject*) k;
					std::string str;
					if (zko->value.Compare(z_member) == 0)
					{
						foundRank = rank;
						return -1;
					}
					rank++;
					return 0;
				}
				ZRankWalk(const Slice& m) :
						rank(0), foundRank(ERR_NOT_EXIST)
				{
					smart_fill_value(m, z_member);
				}
		} walk(member);
		Walk(start, false, &walk);
		return walk.foundRank;
	}
Beispiel #18
0
	int Ardb::ZClear(const DBID& db, const Slice& key)
	{
		KeyLockerGuard keyguard(m_key_locker, db, key);
		ZSetMetaValue meta;
		if (0 != GetZSetMetaValue(db, key, meta))
		{
			return 0;
		}
		Slice empty;
		ZSetKeyObject sk(key, empty, meta.min_score, db);

		BatchWriteGuard guard(GetEngine());
		struct ZClearWalk: public WalkHandler
		{
				Ardb* z_db;
				int OnKeyValue(KeyObject* k, ValueObject* value, uint32 cursor)
				{
					ZSetKeyObject* sek = (ZSetKeyObject*) k;
					ZSetScoreKeyObject tmp(sek->key, sek->value, sek->db);
					z_db->DelValue(*sek);
					z_db->DelValue(tmp);
					return 0;
				}
				ZClearWalk(Ardb* db) :
						z_db(db)
				{
				}
		} walk(this);
		Walk(sk, false, &walk);
		KeyObject k(key, ZSET_META, db);
		DelValue(k);
		return 0;
	}
void KeyControlledTransitionBarbarian_cl::ProcessKeyboardEvents()
{
  bool bUp = VAppImpl::GetInputMap()->GetTrigger(CHARACTER_MOVE_FORWARD)!=0;
  bool bRotLeft = VAppImpl::GetInputMap()->GetTrigger(CHARACTER_ROTATE_LEFT)!=0;
  bool bRotRight = VAppImpl::GetInputMap()->GetTrigger(CHARACTER_ROTATE_RIGHT)!=0;
  bool bShift = VAppImpl::GetInputMap()->GetTrigger(CHARACTER_RUN)!=0;

	if (bUp)
  {
    // Trigger the run/walk actions when CURSOR UP is pressed.
    // Allow rotating the entity while walking/running
    if (bShift)
      Run();
    else
      Walk();

		if (bRotLeft)
      RotateLeft();
    else if (bRotRight)
      RotateRight();
  }
  else
  {
    if (bRotLeft)
      RotateLeft();
    else if (bRotRight)
      RotateRight();
    else
      Stand();
  }
}
HRESULT STDMETHODCALLTYPE TextAreaTextRange::FindAttribute(_In_ TEXTATTRIBUTEID textAttributeId, _In_ VARIANT val, _In_ BOOL searchBackward, _Outptr_result_maybenull_ ITextRangeProvider **retVal)
{
    HRESULT hr = S_OK;
    *retVal = NULL;

    EndPoint start = searchBackward ? _range.end : _range.begin;
    EndPoint finish   = searchBackward ? _range.begin : _range.end;
    EndPoint current = start;

    // This will loop until 'current' passes or is equal to the end
    while (QuickCompareEndpoints(searchBackward ? finish : current, searchBackward ? current : finish) < 0)
    {
        int walked;
        EndPoint next = Walk(current, !searchBackward, TextUnit_Format, textAttributeId, 1, &walked);
        VARIANT curValue = _control->GetAttributeAtPoint(searchBackward ? current : next, textAttributeId);

        hr = VarCmp(&val, &curValue, LOCALE_NEUTRAL);

        if (hr == VARCMP_EQ)
        {
            Range found;
            found.begin = searchBackward ? next : current;

            // For line based attributes, the start character will be the end of the previous line
            // bump it up one to make it an even line
            for (int i = 0; i < ARRAYSIZE(lineVariableAttributes); i++)
            {
                if (textAttributeId == lineVariableAttributes[i])
                {
                    if (found.begin.character > 0)
                    {
                        found.begin.character = 0;
                        found.begin.line++;
                    }
                    break;
                }
            }

            // If next is past the end of the current range, end at the end of the current range instead
            if (QuickCompareEndpoints(searchBackward ? finish : next, searchBackward ? next : finish) > 0)
            {
                found.end = finish;
            }
            else
            {
                found.end = searchBackward ? current : next;
            }
            *retVal = new TextAreaTextRange(_hwnd, _control, found);
            if (*retVal == NULL)
            {
                hr = E_OUTOFMEMORY;
            }
            break;
        }

        current = next;
    }
    return hr;
}
Beispiel #21
0
	int Ardb::ZRevRange(const DBID& db, const Slice& key, int start, int stop,
			ValueArray& values, QueryOptions& options)
	{
		ZSetMetaValue meta;
		if (0 != GetZSetMetaValue(db, key, meta))
		{
			return ERR_NOT_EXIST;
		}
		if (start < 0)
		{
			start = start + meta.size;
		}
		if (stop < 0)
		{
			stop = stop + meta.size;
		}
		if (start < 0 || stop < 0 || (uint32) start >= meta.size)
		{
			return ERR_INVALID_ARGS;
		}
		Slice empty;
		ZSetKeyObject tmp(key, empty, meta.max_score, db);
		struct ZRevRangeWalk: public WalkHandler
		{
				int rank;
				int count;
				int z_start;
				int z_stop;
				ValueArray& z_values;
				QueryOptions& z_options;
				ZRevRangeWalk(int start, int stop, ValueArray& values,
						QueryOptions& options) :
						rank(0), count(0), z_start(start), z_stop(stop), z_values(
								values), z_options(options)
				{
				}
				int OnKeyValue(KeyObject* k, ValueObject* v, uint32 cursor)
				{
					ZSetKeyObject* zsk = (ZSetKeyObject*) k;
					if (rank >= z_start && rank <= z_stop)
					{
						z_values.push_back(zsk->value);
						if (z_options.withscores)
						{
							z_values.push_back(ValueObject(zsk->score));
						}
						count++;
					}
					rank++;
					if (rank > z_stop)
					{
						return -1;
					}
					return 0;
				}
		} walk(start, stop, values, options);
		Walk(tmp, true, &walk);
		return walk.count;
	}
Beispiel #22
0
void XM_CALLCONV Camera::Update( float deltaTime ) {

	if( GetAsyncKeyState( VK_HOME ) ) {
		SetCamType();
	}
	
	if( GetCamType()==1 ) {

		if( GetAsyncKeyState( VK_LEFT ) ) {
			RotateY( 5.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_RIGHT ) ) {
			RotateY( -5.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_UP ) ) {
			Walk( -15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_DOWN ) ) {
			Walk( 15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_PRIOR ) ) {
			Pitch( 1.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_NEXT ) ) {
			Pitch( -1.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_OEM_COMMA ) ) {
			Strafe( -15.0f * deltaTime );
		}
		if( GetAsyncKeyState( VK_OEM_PERIOD ) ) {
			Strafe( 15.0f * deltaTime );
		}
	} else {

		// default camera
		
		//XMStoreFloat3( &target1, goblin1Pos);
		//XMVECTOR posV = XMLoadFloat3( &pos );
		//XMVECTOR targetV = goblin1Pos;
		//XMVECTOR upV = GetUpXM();
		//LookAt( posV, targetV, upV );
	}

	UpdateViewMatrix();
}
Beispiel #23
0
// Fills a cluster with the char "name"
void Fill(Pt p, int arrow, int name) {
	int a ;
	Pt np = Walk(p, arrow, 0) ;
	if( get(np) != '0' && get(np) != name ) {
		set(np, name) ;
		for( a = 0 ; a < 8 ; a++ )
			Fill(np, a, name) ;
	}
}
Beispiel #24
0
void CTreeIterator::Erase(void)
{
    _ASSERT(CheckValid());
    m_CurrentObject.Reset();

    _ASSERT(!m_Stack.empty());
    m_Stack.back()->Erase();
    Walk();
}
Beispiel #25
0
///////////////////////////////////////////////////////
// 	LevelCode
///////////////////////////////////////////////////////
HRESULT LevelCode(void *v, DWORD s)
{

	if(WalkOnMap)
		Walk();
	else
		MapMenu();

	return 0;
}
Beispiel #26
0
void NPC::E_Update(const int delta)
{
	if (!m_moving)
	{
		int direction = rand() % 240;

		if (direction < 4) Walk((E_Direction)direction);
	}

	Traveller::E_Update(delta);
}
Beispiel #27
0
void wxMenuComboListWalker::FillComboListCtrl(wxMenuBar *p, wxComboBox *combo)
{
	// these will be used in the recursive functions...
	m_pCategories = combo;
	
	// be sure that the given tree item is empty...
	m_pCategories->Clear();

	// ...start !!!
	Walk(p, NULL);
}
Beispiel #28
0
void wxMenuTreeWalker::FillTreeBranch(wxMenuBar *p, wxTreeCtrl *ctrl, wxTreeItemId branch)
{
	// these will be used in the recursive functions...
	m_root = branch;
	m_pTreeCtrl = ctrl;

	// be sure that the given tree item is empty...
	m_pTreeCtrl->DeleteChildren(branch);

	// ...start !!!
	Walk(p, &branch);
}
Beispiel #29
0
void EulerCamera::Collided(ObjectType colltype)
{

	if (colltype == ObjectType::ENEMY)
	{
		printf("Enemy collision");
	}
	else if (colltype == ObjectType::OBJECT)
	{
		printf("Object \n");
		if (LastMove==Moves::Forward)
			Walk(-0.1f);
		else if (LastMove == Moves::Backward)
			Walk(0.1f);
		else if (LastMove == Moves::Left)
			Strafe(0.1f);
		else if (LastMove == Moves::Right)
			Strafe(-0.1f);
	}

}
Beispiel #30
0
void T_Bat (objtype *ob)
{
	id0_long_t move;
	id0_long_t deltax,deltay,size;

	move = ob->speed*tics;
	size = (id0_long_t)ob->size + player->size + move;


	do
	{
		deltax = ob->x - player->x;
		deltay = ob->y - player->y;

		if (deltax <= size && deltax >= -size
		&& deltay <= size && deltay >= -size && !ob->temp1)
		{
			TakeDamage (4);
			ob->temp1 = 2;
		}

		if (move < ob->distance)
		{
			MoveObj (ob,move);
			break;
		}

		actorat[ob->tilex][ob->tiley] = 0;	// pick up marker from goal
		if (ob->dir == nodir)
			ob->dir = north;

		ob->x = ((id0_long_t)ob->tilex<<TILESHIFT)+TILEGLOBAL/2;
		ob->y = ((id0_long_t)ob->tiley<<TILESHIFT)+TILEGLOBAL/2;
		move -= ob->distance;

		if (ob->temp1)
		{
			Walk (ob);				// go straight
			if (!--ob->temp1)
			{
				ob->state = &s_batpast;
				ob->ticcount = ob->state->tictime;
			}
		}
		else
			BatChaseThink (ob);		// head towards player

		actorat[ob->tilex][ob->tiley] = COMPAT_OBJ_CONVERT_OBJ_PTR_TO_DOS_PTR(ob); // set down a new goal marker
		//actorat[ob->tilex][ob->tiley] = ob;	// set down a new goal marker
	} while (0);	// just once
	CalcBounds (ob);
}