Задать вопрос
  • Как сделать чтобы был максимум один кусок круга?

    @roma333l Автор вопроса
    у меня получился такой код немного кривой
    .OneReal {
       opacity: 0;
    }

    let swithTrue = true
    const keys = {};
    let Cdswith = 200
    
    window.addEventListener('keydown', event => {
      keys[event.key] = true;
    });
    
    window.addEventListener('keyup', (event) => {
        keys[event.key] = false;
    });
    
    const RightUP = document.querySelector("#RightUP");
    const Down = document.querySelector("#Down");
    const Up = document.querySelector("#Up");
    const Right = document.querySelector("#Right");
    const Left = document.querySelector("#Left");
    const LeftUp = document.querySelector("#LeftUp");
    const RightDown = document.querySelector("#RightDown");
    const LeftDown = document.querySelector("#LeftDown");
    
    // let funcHide = () =>{
    //   kRight.classList.toggle('OneReal')
    //   kUpLeft.classList.toggle('OneReal')
    //   kUpRight.classList.toggle('OneReal')
    //   kLeft.classList.toggle('OneReal')
    //   kLeftDown.classList.toggle('OneReal')
    //   kDown.classList.toggle('OneReal')
    //   kRightDown.classList.toggle('OneReal')
    //   kUp.classList.toggle('OneReal')
    // }
    let lastMemory, memory;
    let NumberReset = 1;
    let funkOnetriger = (NumberReset, memory, lastMemory) => {
    while (NumberReset  >= 1){
      NumberReset = NumberReset - 1
      masivkeys.push(memory)
      if  (memory == lastMemory){
        // console.log('Done')
      masivkeys[0].classList.toggle('OneReal')
      lastMemory = memory
      return lastMemory
    }
    // console.log('a')  
    }}
       let masivkeys = [Up, Down, RightUP, Right, Left, LeftUp, RightDown, LeftDown]
    let kUp = masivkeys[0]
    let kDown = masivkeys[1]
    let kUpRight = masivkeys[2]
    let kUpLeft = masivkeys[5]
    let kLeftDown = masivkeys[7]
    let kRightDown = masivkeys[6]
    let kLeft = masivkeys[4]
    let kRight = masivkeys[3]
    let masiv_masiv = [kUp, kDown, kUpRight, kUpLeft, kLeftDown, kRightDown, kLeft, kRight,]
    let numMas = masivkeys.length
    // funcHide()
       setInterval(() =>{
        if (keys['i'] ) {
          funkOnetriger(2, Up, lastMemory)
        }
          //Up
       if (keys['k'] ) {
        funkOnetriger(2, Down, lastMemory)
        //Down
      }
        if (keys['l'] ) {
        funkOnetriger(2, Right, lastMemory)
          //Right
      }
        if (keys['j'] ) {
          funkOnetriger(2, Left, lastMemory)
      //Left
      }
       if(keys['i'] && keys['j']) {
        funkOnetriger(2, LeftUp, lastMemory)
      //LeftUp
      }
      if(keys['i'] && keys['l']) {
        funkOnetriger(2, RightUP, lastMemory)
        //RightUP
      } 
      if (keys['k'] && keys['l']) {
            funkOnetriger(2, RightDown, lastMemory)
        //RightDown
      }
      if (keys['k'] && keys['j']) {
        funkOnetriger(2, LeftDown, lastMemory)   
      //LeftDown
      }if (masivkeys.length >= 2){
      // console.log(masivkeys)
      masivkeys[0].classList.toggle('OneReal')
    masivkeys.shift()
    }
    }, Cdswith);
    Ответ написан
    Комментировать