void Allegro5Touch::handleTouch(const Util::ReferenceCount<TouchTrack> & touch, std::map<Key, bool> & new_buttons, bool press){ std::vector<Key> all = allKeys(); for (std::vector<Key>::iterator it = all.begin(); it != all.end(); it++){ if (inZone(*it, touch->x, touch->y)){ new_buttons[*it] = press; } } }
bool Stage::inAnyZone(Ship *ship) { for (int x = 0; x < numZones_; x++) { if (inZone(ship, zones_[x])) { return true; } } return false; }
bool Stage::inZone(Ship *ship, const char *tag) { for (int x = 0; x < numZones_; x++) { Zone *zone = zones_[x]; if (strcmp(zone->getTag(), tag) == 0 && inZone(ship, zone)) { return true; } } return false; }
void Character::render() { // If the character is dead, don't display it if(m_lifes <= 0) return; if(!m_isAttacking) { if(m_moving) playAnimation(m_x, m_y, m_direction); else drawFrame(m_x, m_y, m_direction); } // Test if character is in grass if(inZone(m_x, m_y, 2)) { m_grassEffect->setPosRect(m_x, m_y, m_grassEffect->width(), m_grassEffect->height()); m_grassEffect->render(); } // Test if character is in water if(inZone(m_x, m_y, 19)) { m_waterEffect->playAnimation(m_x, m_y + 8, 0); } }
bool Stage::touchedZone(Ship *oldShip, Ship *ship, Zone *zone) { if (inZone(ship, zone)) { return true; } Line2D *line = new Line2D(oldShip->x, oldShip->y, ship->x, ship->y); Line2D **zoneLines = zone->getLines(); for (int x = 0; x < 4; x++) { Line2D *zoneLine = zoneLines[x]; if (zoneLine->intersects(line)) { delete line; return true; } } delete line; return false; }