PyObject* AIE_GetMouseButtonDown(PyObject *self, PyObject *args) { unsigned int iMouseButton; if (!PyArg_ParseTuple( args, "i", &iMouseButton ) ) { ParsePyTupleError( __func__, __LINE__ ); return nullptr; } bool bIsDown = GetMouseButtonDown(iMouseButton); if ( bIsDown ) Py_RETURN_TRUE; else Py_RETURN_FALSE; }
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 Hero::CheckForFire()/// change back to bool { if(GetMouseButtonDown(MOUSE_BUTTON_1)) { time += GetDeltaTime(); if(time > .1){ time = 0; for (std::list<Bullet>::iterator it=HBullets.begin(); it != HBullets.end(); ++it) { //HBullets.FireBullet(GetPosition()); if(!it->IsAlive()) { it->FireBullet(GetPosition()); return; } } } } }
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); } }
void Player::WeaponManager() { DrawString("Current Weapon:", 10, 50); DrawString(scpCurrentWeapon, 250, 50); if(GetMouseButtonDown(1)) { if(eCurrentWeapon == BULLET) { if(m_iBulletTimer > 40) { Fire(* GetProjectiles()[m_iBulletArrayPosition - m_iBulletAmmo]); m_iBulletAmmo--; m_iBulletTimer = 0; if(m_iBulletAmmo == 0) m_iBulletAmmo = c_iPlayerMaxBullets; } } if(eCurrentWeapon == MISSILE) { if(m_iMissileTimer > 100) { Fire(* GetProjectiles()[m_iMissileArrayPosition - m_iMissileAmmo]); m_iMissileAmmo--; m_iMissileTimer = 0; if(m_iMissileAmmo == 0) m_iMissileAmmo = c_iPlayerMaxMissiles; } } if(eCurrentWeapon == LASER) { if(m_iLaserTimer > 100) { Fire(* GetProjectiles()[m_iLaserArrayPosition - m_iLaserAmmo]); m_iLaserAmmo--; m_iLaserTimer = 0; if(m_iLaserAmmo == 0) m_iLaserAmmo = c_iPlayerMaxLasers; } } } if(IsKeyDown('Z')) { eCurrentWeapon = BULLET; scpCurrentWeapon = " Bullet "; } if(IsKeyDown('X')) { eCurrentWeapon = MISSILE; scpCurrentWeapon = " Missile "; } if(IsKeyDown('C')) { eCurrentWeapon = LASER; scpCurrentWeapon = " Laser "; } }
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); } } } } }