const Note *getPreviousNote(const Voice &voice, int position, int string, const Voice *prevVoice) { const Position *prevPos = getPreviousPosition(voice, position); if (!prevPos && prevVoice) prevPos = getPreviousPosition(*prevVoice, std::numeric_limits<int>::max()); return prevPos ? Utils::findByString(*prevPos, string) : nullptr; }
// the move function for the whole snake inline void snake_head::move(float dy, float dx){ if(dx == 0 && dy == 0){ return; } //update the snake head position vec3 pp = getCurrentPosition(); setPreviousPosition(pp); vec3 cp = vec3(pp[0] + dx, pp[1] + dy, pp[2]); setCurrentPosition(cp); //update the first body position pp = body[0].getCurrentPosition(); body[0].setPreviousPosition(pp); cp = getPreviousPosition(); body[0].setCurrentPosition(cp); //update the rest of body position if exist for(int i = 1; i < numberOfBody; i++){ vec3 old_cp = body[i].getCurrentPosition(); body[i].setPreviousPosition(old_cp); vec3 new_cp = body[i-1].getPreviousPosition(); body[i].setCurrentPosition(new_cp); } }