Beispiel #1
0
bool Mode::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex) {
	_x = (int)(x + getX() + _container->getX() + app->_stage->getX());
	_y = (int)(y + getY() + _container->getY() + app->_stage->getY());
	if(isSelecting()) _touchPt.set(evt, _x, _y, true);
	else _touchPt.set(evt, _x, _y, _plane);
	_camera->pickRay(app->getViewport(), _x, _y, &_ray);
	switch(evt) {
		case Touch::TOUCH_PRESS: {
			cout << "mode ray: " << app->pv(_ray.getOrigin()) << " => " << app->pv(_ray.getDirection()) << endl;
			MyNode *node = getTouchNode();
			if(node) node->updateTransform();
			if(isSelecting()) {
				Vector3 point = getTouchPoint();
				if(node) node->setBase();
				setSelectedNode(node, point);
				if(node) cout << "selected: " << node->getId() << " at " << app->pv(point) << endl;
			} else {
				_cameraBase->getNode()->set(*_camera->getNode());
				_viewportBase = app->getViewport();
				app->copyCameraState(app->_cameraState, _cameraStateBase);
				cout << "touched: camera at " << app->pcam(_cameraStateBase) << endl;
			}
			break;
		} case Touch::TOUCH_MOVE: {
			if(isTouching() && app->_navMode >= 0) {
				placeCamera();
			}
			break;
		} case Touch::TOUCH_RELEASE: {
			break;
		}
	}
	return true;
}
Beispiel #2
0
bool Mode::touchEvent(Touch::TouchEvent evt, int x, int y, unsigned int contactIndex) {
    //GP_WARN("mode %s touch at %d,%d - index %d", _id.c_str(), x, y, contactIndex);
	_x = (int)(x /*+ getX() + _container->getX() + app->_stage->getX()*/);
	_y = (int)(y /*+ getY() + _container->getY() + app->_stage->getY()*/);
    if(isSelecting() || _subMode == 1) {
        _touchPt.set(evt, _x, _y, true);
    }
	else _touchPt.set(evt, _x, _y, _plane);
    _touchPt._lastEvent = evt;
	_camera->pickRay(app->getViewport(), _x, _y, &_ray);
	switch(evt) {
		case Touch::TOUCH_PRESS: {
			if(!isSelecting()) {
				_cameraBase->getNode()->set(*_camera->getNode());
				_viewportBase = app->getViewport();
				app->_cameraState->copy(_cameraStateBase);
			}
			break;
		} case Touch::TOUCH_MOVE: {
			if(isTouching() && app->_navMode >= 0) {
				//placeCamera();
			}
			break;
		} case Touch::TOUCH_RELEASE: {
			break;
		}
	}
	return true;
}
BOOL GameObject::isColliding(GameObject *object)
{
    assert(object != NULL);
    if (object != this)
    {
        if (object->getRoom() == getRoom())
        {
            RECT myRect,objectRect;
            getRect(&myRect);
            object->getRect(&objectRect);

            RECT newRect;

            // First get a rectangle that contains both rectangles here
            newRect.left   = (objectRect.left   < myRect.left   ? objectRect.left   : myRect.left);
            newRect.right  = (objectRect.right  > myRect.right  ? objectRect.right  : myRect.right);
            newRect.top    = (objectRect.top    < myRect.top    ? objectRect.top    : myRect.top);
            newRect.bottom = (objectRect.bottom > myRect.bottom ? objectRect.bottom : myRect.bottom);

            // now, traverse each point in that rectangle
            for (int row=newRect.top; row<newRect.bottom; row++)
            {
                // If this row is between the top/bottom of each object's rect
                if (BETWEEN(row,objectRect.top,objectRect.bottom) &&
                        BETWEEN(row,myRect.top,myRect.bottom) )
                {
                    for (int col=newRect.left; col<newRect.right; col++)
                    {
                        // If this column is between the top/bottom of each object's rect
                        // (which means that the x,y point col,row is within each object's rects)
                        if (BETWEEN(col,objectRect.left,objectRect.right) &&
                                BETWEEN(col,myRect.left,myRect.right) )
                        {
                            // See if the point is touching the object
                            if (object->isTouching(col,row) && isTouching(col,row))
                                return TRUE;
                        }
                    }
                }
            }
        }
    }

    return FALSE;
}
Beispiel #4
0
void ce_player::jump(){
	
	if (jumpCount == 0){

		//Jump down
		moveDown(jump_speed);

		//Stop jumping if collision with wall
		if (isTouching(cet_wall)){
			isJumping = false;
		}
	}else{

		//Jump up
		moveUp(jump_speed);
		jumpCount--;
	}
}
const c8 *CIrrOdeEventBodyMoved::toString() {
  sprintf(m_sString,"CIrrOdeEventBodyMoved: body=%i, flags=%i",m_iBodyId,m_iFlags);

  if (positionChanged())
    sprintf(m_sString,"%s, new position=(%.2f, %.2f, %.2f)",m_sString,m_vNewPos.X,m_vNewPos.Y,m_vNewPos.Z);

  if (rotationChanged())
    sprintf(m_sString,"%s, new rotation=(%.2f, %.2f, %.2f)",m_sString,m_vNewRot.X,m_vNewRot.Y,m_vNewRot.Z);

  if (linearVelChanged())
    sprintf(m_sString,"%s, new linear velocity=(%.2f, %.2f, %.2f)",m_sString,m_vNewLinVel.X,m_vNewLinVel.Y,m_vNewLinVel.Z);

  if (angularVelChanged())
    sprintf(m_sString,"%s, new angular velocity=(%.2f, %.2f, %.2f)",m_sString,m_vNewAngVel.X,m_vNewAngVel.Y,m_vNewAngVel.Z);

  if (isTouching())
    sprintf(m_sString,"%s, touching body: %i, mat: %i, pos: (%.2f, %.2f, %.2f)",m_sString,m_iTouchId,m_iColMaterial,m_vColPoint.X,m_vColPoint.Y,m_vColPoint.Z);

  return m_sString;
}
Beispiel #6
0
void ce_player::climbDown(){
	
	//Start climbing
	if (!isClimbingDown){
		isClimbing = true;
		isWalkingRight = false;
		isWalkingLeft = false;
		isClimbingUp = false;
		isClimbingDown = true;
		
		//Setup and start animation sequence
		stopAnimating();
		frame.size.height = 72;
		frame_y = 384;
		frame_sequence.clear();
		frame_sequence.push_back(0);
		frame_sequence.push_back(1);
		frame_sequence.push_back(2);
		frame_sequence.push_back(1);
		startAnimating();

		//Snap to grid
		frame.cord.x = actorTouching(cet_ladder)->frame.cord.x;
	}

	//Stop climbing if player has hit the floor
	if (isTouching(cet_wall)){
		isClimbingDown = false;
		isClimbing = false;
		stopAnimating();
		return;
	}

	//Climb
	moveDown(player_speed);
}