E
E
Evgeny Petryaev2019-06-19 19:57:20
Game development
Evgeny Petryaev, 2019-06-19 19:57:20

Make a single rotation around an axis?

void Scene1::ShowDrum(int countdrums,int counttextureondrums,std::vector<std::string> drum, bool*buttons)
{
....
        if (buttons[2]) {
    StartRotate();
  }
  Rotate();
....
}
void Scene1::Rotate()
{
  for (int i = 0; i<CountDrum; i++)
  {
    if (startrotate[i])
    {
      if (rotate[i]<360.0f)
        rotate[i] += 5.0f;
      else
      {
        startrotate[i] = false;
        rotate[i] = 0.0f;
      }
    }
  }
}
void Scene1::StartRotate()
{
  for (int i = 0; i<CountDrum; i++)
  {
    if (startrotate[i] && rotate[i] != 0.0f)
      continue;
    startrotate[i] = true;
    rotate[i] = 0.0f;
  }
}

It turns out that when pressed, sometimes it spins more than 360 degrees (for example, if you hold down button[2] longer than the rotation occurs, and sometimes xs from what)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Petryaev, 2019-06-19
@Gremlin92

Added a pressbutton variable that increases by 1 if a key (keyboard or mouse) is held down, because of which it becomes larger and when released, the variable turns to 0.

if (buttons[2] && pressbutton == 1) {//то есть один раз нажали стала 1 можно начинать крутить
    StartRotate();
  }

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question