//ProcessInput, for updating mouse position and checking relevant keypresses //EXPAND THIS FUNCTION with key press checks, to add functionality! void InputManager::ProcessInput() { //update location of mouse cursor input_MousePos = GetMouseLocation(); //bound the mouse inside the window if (input_MousePos.X < 0) { input_MousePos.X = 0; } if (input_MousePos.Y < 0) { input_MousePos.Y = 0; } if (input_MousePos.X > input_screenWidth) { input_MousePos.X = input_screenWidth; } if (input_MousePos.Y > input_screenHeight) { input_MousePos.Y = input_screenHeight; } //keyboard checks here? likely just app-layer stuff instead return; }
void Hero::UpdateHero() { GetMouseLocation(MouseX, MouseY); m_Position.SetX (MouseX); m_Position.SetY (MouseY); CheckForFire(); Move(); Draw(); for (std::list<Bullet>::iterator it=HBullets.begin(); it != HBullets.end(); ++it) { if(it->IsAlive()) { it->UpdateBullet(); it->Move(); it->Draw(); } } }
void EnemySpawn::Update(float a_dt) { if (!SpawnBase::IsActive && !m_placed) { double c_x, c_y; GetMouseLocation(c_x, c_y); c_y = g_h - c_y + m_h; // mouse and window Ys are inverted m_y = c_y; m_x = c_x; if (GetMouseButtonDown(0)) { SpawnBase::s_lock = false; draw(); SpawnBase::IsActive = true; m_placed = true; } } }
void Game::update(float dt) { m_spawnTimer += dt; if(m_spawnTimer >= 1.5f) { m_spawnTimer = 0; // spawn new cat Message msg; Vector2 spawnPos; spawnPos.x = 50 + (rand() % (iScreenWidth - 100)); spawnPos.y = 50 + (rand() % (iScreenHeight - 100)); msg.msg = Message::SPAWN_REQUEST; msg.data = spawnPos; msg.consumed = false; notify(msg); } if( GetMouseButtonDown( 0 ) ) { int x, y; Vector2 mousePos; GetMouseLocation( x, y ); mousePos.x = x; mousePos.y = y; Message msg; msg.msg = Message::ON_CLICK; msg.data = mousePos; msg.consumed = false; notify(msg); } }
PyObject* AIE_GetMouseLocation(PyObject *self, PyObject *args) { int iMouseX, iMouseY; GetMouseLocation( iMouseX, iMouseY ); return Py_BuildValue("ii", iMouseX, iMouseY ); }
void Framework::MoveMouse(Vec2 loc) { glfwSetCursorPos(window, GetMouseLocation().x + loc.x, GetMouseLocation().y + loc.y); }
void HermiteSpline::HandleUI(StateManager* stateMan) { if (IsKeyDown('M')) { stateMan->PopState(); return; } if (GetMouseButtonDown(MOUSE_BUTTON_1)) { //loop through objects and see if clicked for (Sprite* object : objectList) { if (object->ID == objectList[0]->ID) { double mousePosX = 0.0; double mousePosY = 0.0; GetMouseLocation(mousePosX, mousePosY); mousePosY = screenHeight - mousePosY; //std::cout << "x: " << mousePosX << " y: " << mousePosY << std::endl; bool isCollided = object->IsCollided(Vector2(mousePosX, mousePosY)); //std::cout << "object: " << object->name << " clicked: " << isCollided << std::endl; if (object->IsCollided(Vector2(mousePosX, mousePosY))) { object->position = Vector2(mousePosX, mousePosY); } } } } }