Exemple #1
0
void TSpit::xtakeit(const ArgumentArray &args) {
	// Pick up and move a marble

	// First, let's figure out what marble we're now holding
	uint32 &marble = _vm->_vars["themarble"];
	marble = 0;

	for (uint32 i = 0; i < kMarbleCount; i++) {
		RivenHotspot *marbleHotspot = _vm->getCard()->getHotspotByName(s_marbleNames[i]);
		if (marbleHotspot->containsPoint(getMousePosition())) {
			marble = i + 1;
			break;
		}
	}

	// xtakeit() shouldn't be called if we're not on a marble hotspot
	assert(marble != 0);

	// Redraw the background
	_vm->getCard()->drawPicture(1);

	// Loop until the player lets go (or quits)
	while (mouseIsDown() && !_vm->hasGameEnded()) {
		_vm->doFrame();
	}

	// Check if we landed in a valid location and no other marble has that location
	uint32 &marblePos = _vm->_vars[s_marbleNames[marble - 1]];

	bool foundMatch = false;
	for (int y = 0; y < 25 && !foundMatch; y++) {
		for (int x = 0; x < 25 && !foundMatch; x++) {
			Common::Rect testHotspot = generateMarbleGridRect(x, y);

			// Let's try to place the marble!
			if (testHotspot.contains(getMousePosition())) {
				// Set this as the position
				setMarbleX(marblePos, x);
				setMarbleY(marblePos, y);

				// Let's make sure no other marble is in this spot...
				for (uint16 i = 0; i < kMarbleCount; i++)
					if (i != marble - 1 && _vm->_vars[s_marbleNames[i]] == marblePos)
						marblePos = 0;

				// We have a match
				foundMatch = true;
			}
		}
	}

	// If we still don't have a match, reset it to the original location
	if (!foundMatch)
		marblePos = 0;

	// Check the new hotspots and refresh everything
	marble = 0;
	setMarbleHotspots();
	drawMarbles();
}
Exemple #2
0
int SureExit(){
		outtextxy(320,100,"Play Again?");
		outtextxy(240,300,"Yes");
		outtextxy(400,300,"No and Quit");
	do{
		if(leftPress() != 1){
			getMousePosition(&mx,&my);
			if(mousex != mx||mousey != my){
				putimage(mousex,mousey,imagep,XOR_PUT);
				mousex = mx; mousey = my;
				putimage(mousex,mousey,imagep,XOR_PUT);
			}
		}else if(mouseLeftFlag == 1){
			mouseLeftFlag = 0;
			getMousePosition(&mx,&my);
			if(mx < 280 && mx > 200 && my < 320 && my > 280){
				cleardevice();
				return 1;
			}
			else if(mx < 440 && mx  > 360 && my < 320 && my > 280){
				cleardevice();
				return 0;
			}
		}
	}while(1);
}
Exemple #3
0
void assignment1_app::onMouseButton(int button, int action)
{
	int x, y;

	getMousePosition(x, y);
	// Check to see if left mouse button was pressed for rotation
	if (button == GLFW_MOUSE_BUTTON_LEFT && action == GLFW_PRESS) {
		bRotate = true;
		iPrevMouseX = iCurMouseX = x;
		iPrevMouseY = iCurMouseY = y;
	}
	// Check to see if right mouse button was pressed for zoom and pan
	else if (button == GLFW_MOUSE_BUTTON_RIGHT && action == GLFW_PRESS) {
		bZoom = false;
		bPan = false;
		if (bShiftPressed == true)
		{
			bZoom = true;
		}
		else if (bShiftPressed == false)
		{
			bPan = true;
		}
		iPrevMouseX = iCurMouseX = x;
		iPrevMouseY = iCurMouseY = y;
	}
	else {
		bRotate = false;
		bZoom = false;
		bPan = false;
	}

}
Exemple #4
0
/**
 * zooms in by factor f
 */
void RS_GraphicView::zoomIn(double f, const RS_Vector& center) {

	if (f<1.0e-6) {
		RS_DEBUG->print(RS_Debug::D_WARNING,
						"RS_GraphicView::zoomIn: invalid factor");
		return;
	}

    RS_Vector c = center;
    if (!c.valid) {
        //find mouse position
        c= getMousePosition();
    }

	zoomWindow(
				toGraph(RS_Vector(0,0))
				.scale(c, RS_Vector(1.0/f,1.0/f)),
				toGraph(RS_Vector(getWidth(),getHeight()))
				.scale(c, RS_Vector(1.0/f,1.0/f)));

	//adjustOffsetControls();
	//adjustZoomControls();
	// updateGrid();
	redraw();
}
Exemple #5
0
void BSpit::xbaitplate(const ArgumentArray &args) {
	// Remove the pellet from the plate and put it in your hand
	_vm->_cursor->setCursor(kRivenPelletCursor);
	_vm->getCard()->drawPicture(3);

	// Loop until the player lets go (or quits)
	while (mouseIsDown() && !_vm->hasGameEnded()) {
		_vm->doFrame();
	}

	// Set back the cursor
	_vm->_cursor->setCursor(kRivenMainCursor);

	RivenHotspot *bait = _vm->getCard()->getHotspotByBlstId(9);
	RivenHotspot *baitPlate = _vm->getCard()->getHotspotByBlstId(16);

	// Set the bait if we put it on the plate, remove otherwise
	if (baitPlate->containsPoint(getMousePosition())) {
		_vm->_vars["bbait"] = 1;
		_vm->getCard()->drawPicture(4);
		bait->enable(false); // Disable bait hotspot
		baitPlate->enable(true); // Enable baitplate hotspot
	} else {
		_vm->_vars["bbait"] = 0;
		bait->enable(true); // Enable bait hotspot
		baitPlate->enable(false); // Disable baitplate hotspot
	}
}
void ofxBKDoubleSlider::mouseDragged(ofMouseEventArgs &e)
{
	float targetVal = getValueForPosition(getMousePosition().x)-mouseDragOffset;
	if(currentDraggingValue == 1) setValue(targetVal);
	else if(currentDraggingValue == 2) setValue2(targetVal);

}
Exemple #7
0
/**
 * @brief Compute the parallelogram from one edge and one point (mouse position).
 *
 * [AB]: Input clicked edge
 * P: mouse position on press
 * M: moving mouse
 * [DC]: the computed edge keeping AB length and AP==DM
 *
 *     A ____________ D
 *      /           /
 *   P +           + M
 *    /           /
 * B /___________/ C
 *
 * This computation is in 2D Camera Space.
 *
 * @param[in] view Viewort
 * @param[in] onPressEdgeData clicked edge information
 * @param[in] onPressCSMousePos clicked mouse position in Camera Space coordinates
 * @param[out] intermediateCSEdgePoints the 2 new points (D and C) of the parallelogram
 */
void MVGManipulator::getIntermediateCSEdgePoints(
    M3dView& view, const MVGManipulatorCache::EdgeData* onPressEdgeData,
    const MPoint& onPressCSMousePos, MPointArray& intermediateCSEdgePoints)
{
    assert(onPressEdgeData != NULL);
    // vertex 1
    MVector mouseToVertexCSOffset =
        MVGGeometryUtil::worldToCameraSpace(view, onPressEdgeData->vertex1->worldPosition) -
        onPressCSMousePos;
    intermediateCSEdgePoints.append(getMousePosition(view) + mouseToVertexCSOffset);
    // vertex 2
    mouseToVertexCSOffset =
        MVGGeometryUtil::worldToCameraSpace(view, onPressEdgeData->vertex2->worldPosition) -
        onPressCSMousePos;
    intermediateCSEdgePoints.append(getMousePosition(view) + mouseToVertexCSOffset);
}
Exemple #8
0
void BSpit::xvalvecontrol(const ArgumentArray &args) {
	Common::Point startPos = getMouseDragStartPosition();

	// Set the cursor to the closed position
	_vm->_cursor->setCursor(kRivenClosedHandCursor);

	while (mouseIsDown()) {
		Common::Point mousePos = getMousePosition();
		int changeX = mousePos.x - startPos.x;
		int changeY = startPos.y - mousePos.y;

		// Get the variable for the valve
		uint32 valve = _vm->_vars["bvalve"];

		// FIXME: These values for changes in x/y could be tweaked.
		if (valve == 0 && changeY <= -10) {
			valveChangePosition(1, 2, 2);
		} else if (valve == 1) {
			if (changeX >= 0 && changeY >= 10) {
				valveChangePosition(0, 3, 1);
			} else if (changeX <= -10 && changeY <= 10) {
				valveChangePosition(2, 1, 3);
			}
		} else if (valve == 2 && changeX >= 10) {
			valveChangePosition(1, 4, 2);
		}

		_vm->doFrame();
	}
}
void PlanetWidget::wheelEvent (QWheelEvent* event) {
	getMousePosition();
	if(event->orientation() == Qt::Vertical) {
		activeRenderer->change_scale(vector(mousePosition), 1+0.0007*event->delta());
		update();
	}
}
Exemple #10
0
void Desktop::sendMouseMove()
{
    if (! mouseListeners.isEmpty())
    {
        startTimer (20);

        lastFakeMouseMove = getMousePosition();

        Component* const target = findComponentAt (lastFakeMouseMove);

        if (target != nullptr)
        {
            Component::BailOutChecker checker (target);
            const Point<int> pos (target->getLocalPoint (nullptr, lastFakeMouseMove));
            const Time now (Time::getCurrentTime());

            const MouseEvent me (getMainMouseSource(), pos, ModifierKeys::getCurrentModifiers(),
                                 target, target, now, pos, now, 0, false);

            if (me.mods.isAnyMouseButtonDown())
                mouseListeners.callChecked (checker, &MouseListener::mouseDrag, me);
            else
                mouseListeners.callChecked (checker, &MouseListener::mouseMove, me);
        }
    }
}
void ofxBKDoubleSlider::mousePressed(ofMouseEventArgs &e)
{
	currentDraggingValue = getNearestValueIndex(getValueForPosition(getMousePosition().x));
	mouseDragOffset = getValueForPosition(getMousePosition().x) - (currentDraggingValue == 1?value:value2);
	ofHideCursor();

	#ifdef _WIN32

	LPPOINT pt = LPPOINT();
	int x = ofGetWindowPositionX()+getGlobalBounds().x + (currentDraggingValue == 1?value:value2)*width;
	int y = ofGetWindowPositionY()+getGlobalBounds().y+getMousePosition().y;
	SetCursorPos(x,y);
	mouseDragOffset = 0;
	#endif

	isDragging = true;
}
	bool StaticRectangle::isCursorInside()
	{
		sf::Vector2f mousePos = getMousePosition();
		sf::FloatRect rect = mRect.getLocalBounds();
		rect.left += mRect.getPosition().x;
		rect.top += mRect.getPosition().y;
		return rect.contains(mousePos);
	}
Exemple #13
0
sf::Vector2f Window::getPointerPosition(unsigned int touchIndex) const
{
    #ifdef N_MOBILE_PLATFORM
    return getTouchPosition(touchIndex);
    #else
    return getMousePosition();
    #endif
}
//==============================================================================
void Desktop::timerCallback()
{
    int x, y;
    getMousePosition (x, y);

    if (lastMouseX != x || lastMouseY != y)
        sendMouseMove();
}
Exemple #15
0
void updateNrender(){
    float a, b;
    float time;
    u32 ms;
    getTimeElapsed(&ms);
    time = ms / 1000.f;
    getMousePosition(&a, &b);
    paddleX = s2p(a);
    paddleRot = s2p(b);
    static float rotate = 0;
    static float vx = 0, vy = -1, px = 0, py = 0, av =0;
    static char hasBounced = 0;

    rotate += av*time;
    px += time*vx, py += time*vy;
    square_rotateTo(ball, rotate);
    square_traslateTo(ball, px, py);

    square_traslateTo(paddle, paddleX, paddleY);
    square_rotateTo(paddle, paddleRot);

    squareList_update_pos(Sprites.squareList, buffer);

    //CHECK COLLISION :)
    if(hasBounced!= 1 && px <-1){ bounce(TAU/4, &vx, &vy, &av, 1.);hasBounced = 1; }
    if(hasBounced!=2 && px> 1){ bounce(-TAU/4, &vx, &vy, &av, 1.);hasBounced = 2;}
    if(hasBounced!=3 && py >1){ bounce(-TAU/2, &vx, &vy, &av, 1.); hasBounced = 3; }
    if(py <-1){
        game_die();
    }
    if(hasBounced!=4 && px<= paddleX+0.4 && px>=paddleX-0.4  && py<=paddleY+0.05 && py>=paddleY-0.05) {
        bounce(3/4*TAU-paddleRot, &vx, &vy, &av, 1.2);
        hasBounced = 4;
        score++;
    }
    puun_MouseClick click;
    getMouseClick(&click);
    puun_KEY key;
    getKeyboardKey(&key);
    if(click)
        printf("MOUSE CLICKED\n");
    if(key.isPressed) printf("%c\n", key.key);




    glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);

    renderSpriteList(Sprites);
    //uniImg.id = ballId;
    //uniImg.texnum = 0;
    //render_squareList(Squares, (Data)&uniImg, 1);


    puun_SWAP_BUFFERS();
    //SDL_GL_SwapBuffers();
}
void Desktop::resetTimer() throw()
{
    if (mouseListeners.size() == 0)
        stopTimer();
    else
        startTimer (100);

    getMousePosition (lastMouseX, lastMouseY);
}
Exemple #17
0
//==============================================================================
void Desktop::resetTimer()
{
    if (mouseListeners.size() == 0)
        stopTimer();
    else
        startTimer (100);

    lastFakeMouseMove = getMousePosition();
}
Exemple #18
0
/**
 * Mouse function : Is mouse in a given rect?
 * @remarks	Originally called 'dans_rect'
 */
bool MouseHandler::isMouseIn(Common::Rect r) {
	int x, y;
	bool click;

	getMousePosition(x, y, click);
	if ((x > r.left) && (x < r.right) && (y > r.top) && (y < r.bottom))
		return true;

	return false;
}
	void TextureControl::notifyMouseButtonReleased(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
	{
		if (_id == MyGUI::MouseButton::Right)
		{
			mMouseCapture = false;

			mTexture->setPointer("arrow");
			MyGUI::PointerManager::getInstance().setPointer("arrow");
			MyGUI::PointerManager::getInstance().eventChangeMousePointer("arrow");
		}
		else if (_id == MyGUI::MouseButton::Left)
		{
			if (!mMouseCapture && mMouseLeftPressed)
			{
				mMouseLeftPressed = false;
				onMouseButtonClick(getMousePosition());
			}
			onMouseButtonReleased(getMousePosition());
		}
	}
Exemple #20
0
	bool StaticImage::isCursorInside()
	{
		sf::Vector2f mousePos = getMousePosition();
		sf::FloatRect rect = mSprite.getLocalBounds();
		const sf::Vector2f &scale = mSprite.getScale();
		rect.left += mSprite.getPosition().x;
		rect.top += mSprite.getPosition().y;
		rect.width *= scale.x;
		rect.height *= scale.y;
		return rect.contains(mousePos);
	}
Exemple #21
0
void Window::display()
{
    if (mCursorVisibility == Window::MouseCursor::Custom)
    {
        setDefaultView();
        mCursor.setPosition(getMousePosition());
        draw(mCursor);
    }

    sf::RenderWindow::display();
}
glm::vec2 InputManager::getMouseWorldPosition()
{
	POINT mousePosition = getMousePosition();
	glm::vec2 p = glm::vec2((float)mousePosition.x, (float)mousePosition.y);
	float aspectRatio = Settings::getAspectRatio();
	if (aspectRatio > 1) {
		p.x *= -(Camera::getActiveCamera()->getPos().x - p.x * 100.0f / Settings::getWindowWidth() + 50.0f / aspectRatio);
		p.y *= Camera::getActiveCamera()->getPos().y - p.y * 100.0f * aspectRatio / Settings::getWindowHeight() + 50.0f;
	}
	else {
		p.x = Camera::getActiveCamera()->getPos().x + p.x * 100.0f / aspectRatio / Settings::getWindowWidth() - 50.0f / aspectRatio;
		p.y = Camera::getActiveCamera()->getPos().y - p.y * 100.0f / Settings::getWindowHeight() + 50.0f;
	}
	return p;
}
Exemple #23
0
bool TizenGraphicsManager::moveMouse(int16 &x, int16 &y) {
	int16 currentX, currentY;
	getMousePosition(currentX, currentY);

	// save the current hardware coordinates
	setMousePosition(x, y);

	// return x/y as game coordinates
	adjustMousePosition(x, y);

	// convert current x/y to game coordinates
	adjustMousePosition(currentX, currentY);

	// return whether game coordinates have changed
	return (currentX != x || currentY != y);
}
	void TextureControl::notifyMouseDrag(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
	{
		mMouseLeftPressed = false;

		if (_id == MyGUI::MouseButton::Right)
		{
			MyGUI::IntPoint mousePoint = MyGUI::InputManager::getInstance().getMousePositionByLayer();
			MyGUI::IntPoint mouseOffset = mousePoint - mRightMouseClick;

			MyGUI::IntPoint offset = mViewOffset + mouseOffset;
			mView->setViewOffset(offset);
		}
		else if (_id == MyGUI::MouseButton::Left)
		{
			onMouseDrag(getMousePosition());
		}
	}
void MouseHandler::updateMouseState(MouseState& mouseState)
{
	mouseState.resetMouseMoved();
	mouseState.resetKeyReleased();

	mouseState.setMousePosition(getMousePosition());

	SHORT buttonState = 0;
	buttonState = GetAsyncKeyState(VK_LBUTTON);
	mouseState.setKeyDown(MouseState::KEY_LEFT, getKeyStateDown(buttonState));

	buttonState = GetAsyncKeyState(VK_RBUTTON);
	mouseState.setKeyDown(MouseState::KEY_RIGHT, getKeyStateDown(buttonState));

	buttonState = GetAsyncKeyState(VK_MBUTTON);
	mouseState.setKeyDown(MouseState::KEY_CENTER, getKeyStateDown(buttonState));
}
	void TextureControl::notifyMouseButtonPressed(MyGUI::Widget* _sender, int _left, int _top, MyGUI::MouseButton _id)
	{
		if (_id == MyGUI::MouseButton::Right)
		{
			mMouseCapture = true;
			mRightMouseClick = MyGUI::InputManager::getInstance().getMousePositionByLayer();
			mViewOffset = mView->getViewOffset();

			mTexture->setPointer("hand");
			MyGUI::PointerManager::getInstance().setPointer("hand");
			MyGUI::PointerManager::getInstance().eventChangeMousePointer("hand");
		}
		else if (_id == MyGUI::MouseButton::Left)
		{
			mMouseLeftPressed = true;
			onMouseButtonPressed(getMousePosition());
		}
	}
static enum XdndState dndInPosition(enum XdndState state, XClientMessageEvent *evt)
{
  /*fdebugf((stderr, "Receive XdndPosition (input)\n"));*/

  if (xdndSourceWindow != xdndPosition_sourceWindow(evt))
    {
      fdebugf((stderr, "dndInPosition: wrong source window\n"));
      return XdndStateIdle;
    }

  getMousePosition();

  if ((state != XdndStateEntered) && (state != XdndStateTracking))
    {
      fdebugf((stderr, "dndInPosition: wrong state\n"));
      return XdndStateIdle;
    }
  
  if ((state == XdndStateEntered) && xdndWillAccept)
    recordDragEvent(DragEnter, 1);
  
  if (xdndWillAccept)
    {
      Atom action= xdndPosition_action(evt);
      /*fdebugf((stderr, "  dndInPosition: action = %ld %s\n", action, XGetAtomName(stDisplay, action)));*/
      xdndWillAccept= (action == XdndActionMove) | (action == XdndActionCopy)
	|             (action == XdndActionLink) | (action == XdndActionAsk);
    }

  if (xdndWillAccept)
    {
      /*fdebugf((stderr, "  dndInPosition: accepting\n"));*/
      dndSendStatus(1, XdndActionCopy);
      recordDragEvent(DragMove, 1);
    }
  else /* won't accept */
    {
      /*fdebugf((stderr, "  dndInPosition: not accepting\n"));*/
      dndSendStatus(0, XdndActionPrivate);
    }
  return XdndStateTracking;
}
void Desktop::sendMouseMove()
{
    if (mouseListeners.size() > 0)
    {
        startTimer (20);

        int x, y;
        getMousePosition (x, y);
        lastMouseX = x;
        lastMouseY = y;

        Component* const target = findComponentAt (x, y);

        if (target != 0)
        {
            target->globalPositionToRelative (x, y);

            ComponentDeletionWatcher deletionChecker (target);

            const MouseEvent me (x, y,
                                 ModifierKeys::getCurrentModifiers(),
                                 target,
                                 Time::getCurrentTime(),
                                 x, y,
                                 Time::getCurrentTime(),
                                 0, false);

            for (int i = mouseListeners.size(); --i >= 0;)
            {
                if (ModifierKeys::getCurrentModifiers().isAnyMouseButtonDown())
                    ((MouseListener*) mouseListeners[i])->mouseDrag (me);
                else
                    ((MouseListener*) mouseListeners[i])->mouseMove (me);

                if (deletionChecker.hasBeenDeleted())
                    return;

                i = jmin (i, mouseListeners.size());
            }
        }
    }
}
Exemple #29
0
void Window::display()
{
    if (mDebugInfoVisible)
    {
        setDefaultView();
        for (auto itr = mDebugInfo.begin(); itr != mDebugInfo.end(); itr++)
        {
            draw(itr->second);
        }
    }

    if (mCursor == MouseCursor::Custom)
    {
        setDefaultView();
        mCursorSprite.setPosition(getMousePosition());
        draw(mCursorSprite);
    }

    sf::RenderWindow::display();
}
Exemple #30
0
	void update()
	{
		auto doc = parent<InteractiveDocument>();
		Point oldPos = m_position.getValue(), newPos = doc->getMousePosition();

		Point delta;
		if(oldPos != newPos)
		{
			m_position.setValue(newPos);
			if(!m_firstTimestep)
				delta = newPos - oldPos;
		}

		if(delta != m_movement.getValue())
			m_movement.setValue(delta);

		m_clickState.setValue(doc->getMouseClick());

		m_firstTimestep = false;
	}