Пример #1
0
void Octorok::shot() {
    SoundManager::playSound("shootBigBall");
    sf::Vector2f offset;
    offset.x = getHorizontal(_dir) * (getBounds().left+getBounds().width /2);
    offset.y = getVertical  (_dir) * (getBounds().top +getBounds().height/2);
    _scene->addEnemyWeapon(new RockProjectile(_map, getRelativeCenter(_sprite.getPosition(), getBounds(), RockProjectile::bounds()) + offset, _dir));
}
Пример #2
0
/* 
 * Loads, sorts and displays the closest restaurants to location on map
 * passed in, filtered by rating.
 */
void displayClosestRestaurants(uint16_t horiz, uint16_t vert, uint8_t minimumRating) {
  RestDist distances[RESTAURANTS_COUNT];
  uint16_t restaurantCount = loadDistances(horiz, vert, minimumRating, distances);
  Serial.print("# of Restauraunts loaded: ");
  Serial.println(restaurantCount);
  sortDistances(distances, restaurantCount);

  int16_t startingIndex = 0;
  int8_t scrollScale = 10;

  writeOutRestaurants(startingIndex, distances, restaurantCount);

  // wait for button to be pressed
  while(!isButtonPressed()) { 
    // following code implements scrolling up or down
    // the list of restaurants loaded previously
    uint16_t currentVertical = getVertical();
    int16_t shiftValue = 0;
    if(currentVertical > verticalMidpoint) {
      shiftValue = scrollScale;
    } else if (currentVertical < verticalMidpoint) {
      shiftValue = -scrollScale;
    }

    if(shiftValue) {
      uint16_t endIndex = startingIndex + 20;

      // If we're scrolling up or we're not already at the end of the list,
      // go ahead and scroll
      if(shiftValue < 0 || endIndex < restaurantCount) {
        startingIndex = startingIndex + shiftValue;
        if(startingIndex < 0) {
          // Don't want to scroll past the top!
          startingIndex = 0;
        } else {
          // Don't want to scroll past the end!
          if (startingIndex >= restaurantCount) {
            startingIndex = restaurantCount - 1;
          }
          writeOutRestaurants((uint16_t) startingIndex, distances, restaurantCount);
        }
      }
    }

    delay(100);
  }

  // wait for button to be released
  while(isButtonPressed()) { }
}
Пример #3
0
void loop() {
  uint8_t ratingFilter = getRatingFilter();
  uint16_t horiz = getHorizontal();
  uint16_t vert = getVertical();
  lightUpRatingLEDs(ratingFilter);

  tft.drawPixel(horiz, vert, 0);
  if(isButtonPressed()) {
    // wait for button to be released
    while(isButtonPressed()) { }
    displayClosestRestaurants(horiz, vert, ratingFilter * 2);
    drawMap();
  }
  lcd_image_draw(&map_image, &tft, horiz, vert, horiz, vert, 1, 1);
}
Пример #4
0
void State::update()
{
    _attackables.clear();
    //vertical
    for (size_t i = 0; i < _size; ++i) {
        auto v = getVertical(Position(0, i));
        updateLine(v);
    }
    //horizontal
    for (size_t i = 0; i < _size; ++i) {
        auto v = getHorizontal(Position(i, 0));
        updateLine(v);
    }
    //diagonalA
    for (size_t i = 4; i < _size-1; ++i) {
        auto v = getDiagonalA(Position(i, _size-1));
        updateLine(v);
    }
    {
        auto v = getDiagonalA(Position(_size - 1, _size - 1));
        updateLine(v);
    }
    for (size_t i = 1; i < _size - 4; ++i) {
        auto v = getDiagonalA(Position(i, 0));
        updateLine(v);
    }
    //diagonalB
    for (size_t i = 4; i < _size - 1; ++i) {
        auto v = getDiagonalB(Position(i, 0));
        updateLine(v);
    }
    {
        auto v = getDiagonalB(Position(_size - 1, 0));
        updateLine(v);
    }
    for (size_t i = 1; i < _size - 4; ++i) {
        auto v = getDiagonalB(Position(i, _size - 1));
        updateLine(v);
    }
    updated = true;
}
Пример #5
0
const GSvector2& Input::getVelocity()const
{
	GSvector2 vel(getHorizontal(),getVertical());
	return vel.normalize();
}
// Compute character height, based on window size and font.
float df::GraphicsManager::charHeight(){
	return (float)getVerticalPixels() / (float)getVertical();
}
Пример #7
0
bool State::isForbidden(Position p, Block b, const Test &test) const
{
    bool isForbidden = true;

    size_t count33 = 0;
    auto check33 = [&](Test t) {
        auto iter = std::find(t->position.cbegin(), t->position.cend(), p);
        assert(iter != t->position.cend());
        size_t i = iter - t->position.cbegin();
        assert(i < t->line.size());
        t->line[i] = b;

        size_t count = 0;
        for (size_t j = i+1; j < t->line.size(); ++j) {
            if (t->line[j] != b)
                break;
            ++count;
        }

        bool isS3 = false;

        if (isS3 == false  && count < 3 && i > 0 && t->line[i - 1] == SPACE) {
            auto attackable = check3(t, i);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count < 2 && i > 1 && t->line[i - 1] == b && t->line[i - 2] == SPACE) {
            auto attackable = check3(t, i - 1);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count == 0 && i > 2 && t->line[i - 1] == b && t->line[i - 2] == b && t->line[i - 3] == SPACE) {
            auto attackable = check3(t, i - 2);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }

        if (isS3 == false && count < 2 && i > 2 && t->line[i - 1] == SPACE && t->line[i - 2] == b && t->line[i - 3] == SPACE) {
            auto attackable = check3(t, i - 2);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3 == false && count == 0 &&  i > 3 && t->line[i - 1] == SPACE && t->line[i - 2] == b && t->line[i - 3] == b && t->line[i  - 4] == SPACE) {
            auto attackable = check3(t, i - 3);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3 == false && count == 0 && i > 3 && t->line[i - 1] == b && t->line[i - 2] == SPACE && t->line[i - 3] == b && t->line[i - 4] == SPACE) {
            auto attackable = check3(t, i - 3);
            if (attackable->rank == S_THREE) {
                isS3 = true;
            }
        }
        if (isS3) {
            ++count33;
        }
    };

    if (get(p) == SPACE) {
        isForbidden = false;
        auto vertical = getVertical(p);
        auto horizontal = getHorizontal(p);
        auto diagonalA = getDiagonalA(p);
        auto diagonalB = getDiagonalB(p);
        if (test) {
            if (vertical->position.front() == test->position.front()
                && vertical->position.back() == test->position.back()) {
                vertical = test;
            }
            else if (horizontal->position.front() == test->position.front()
                && horizontal->position.back() == test->position.back()) {
                horizontal = test;
            }
            else if (diagonalA->position.front() == test->position.front()
                && diagonalA->position.back() == test->position.back()) {
                diagonalA = test;
            }
            else if (diagonalB->position.front() == test->position.front()
                && diagonalB->position.back() == test->position.back()) {
                diagonalB = test;
            }
        }

        Rule *rule = b == BLACK ? Rule::getBlack() : Rule::getWhite();
        if (rule->getThreeAndThree() == false) {
            check33(vertical);
            check33(horizontal);
            if (diagonalA->line.size() > 0) {
                check33(diagonalA);
            }
            if (diagonalB->line.size() > 0) {
                check33(diagonalB);
            }
            if (count33 > 1) {
                isForbidden = true;
            }
        }
    }
    return isForbidden;
}