is there anybody who can convert this code into construct 3?

0 favourites
  • 9 posts
From the Asset Store
Casino? money? who knows? but the target is the same!
  • if you play this game. then check the dropdown which showing number of pieces of image.

    Try to use a custom img. you'll notice that it number of pieces are different on different image sizes. it calculates more than 5 possible number of pieces that can be done for that image. I want to know how they did calculation for that. I did inspect that page and found that particular code which does that task but problem is I'm not a programmer and don't know programming language. if anybody knows then can you please convert this into construct 3?

    Thanks in advance.

    Util.calcPieces = function(options) {
     var w = options.image.width,
     h = options.image.height,
     select = document.getElementById('set-parts'),
     selectedIndex = 0,
     option,
     size,
     cols,
     rows,
     parts;
     select.innerHTML = '';
     for (var i = 0; i < options.options.length; i += 1) {
     var size = ~~Math.sqrt(w * h / options.options[i]),
     cols = ~~(w / size),
     rows = ~~(h / size);
     while (cols * rows < options.options[i]) {
     size--;
     cols = ~~(w / size);
     rows = ~~(h / size);
     }
     if (parts != cols * rows) {
     parts = cols * rows;
     option = document.createElement('option');
     option.value = options.options[i];
     option.innerHTML = options.template.replace('%d', parts);
     select.appendChild(option);
     if (options.options[i] === options.selected)
     option.selected = true;
     }
     }
    };
  • How far did you get trying to convert it yourself? Anything you get stuck on? I’m not interested in doing that kind of thing but can help here and there. For example the ~~ is the same as int().

  • this is what I did and I got this result 1,6,8,15,28,40,45,66,84

  • Write your discord, I'll try to help.

  • Write your discord

    what it means?

  • If you have a discord account, write your nickname and I will contact you.

  • why don't you answer here so other people can also know

    luckyrawatlucky#2106

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Because I don't have an answer to your question.

  • btw I got that code extracted. and I got what I was wanted.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)