Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
2.7 kB
3
Indexable
Never
stage {
    backdrop White("gallery:General/White")
    let list = [];
    let correct = 0;
    let difficulty = 0;
    let canWin = true;
    
    actor Čísla {
        costume Nula("gallery:Text/Zero")
        costume Jedna("gallery:Text/One")
        costume Dva("gallery:Text/Two")
        costume Tři("gallery:Text/Three")
        costume Čtyři("gallery:Text/Four")
        costume Pět("gallery:Text/Five")
        costume Šest("gallery:Text/Six")
        costume Sedm("gallery:Text/Seven")
        costume Osm("gallery:Text/Eight")
        costume Děvět("gallery:Text/Nine")
        default costume Čtverec_modrý("gallery:Objects/Square Blue")

        function rePosition() {
            do {
                this.setPosition(-200 + Math.randomBetween(0, 10) * 50,-150 + Math.randomBetween(0, 6) * 50);
                this.wait(0.1);
            } while (this.touchingActorOrClone(Čísla));
        }

        when stage.started {
            this.setCostume(11);
            this.hide();
            canWin = true;
            correct = 0;
            list = [];
            showVariable(ref correct);
            difficulty = this.ask("Jakou obtížnost si přeješ (1-10)?");
            for (let i = 1; i <= difficulty; i++) {
                createClone(this);
                list.push(i);
                this.wait(0.1);
            }
        }

        when cloned {
            this.physics.collisionShape = "polygon";
            this.opacity = 0;
            this.show();
            this.setCostume(this.cloneId);
            this.size = 80;
            this.rePosition();
            this.wait(1);
            if(this.cloneId == difficulty){
                broadcast("showLevel");
            }
        }

        when stage.signalReceived("showLevel") {
            if (this.isClone) {
                this.setCostume(this.cloneId);
                this.size = 80;
                this.opacity = 100;
                this.wait(2);
                this.setCostume(11);
                this.size = 150;
                this.opacity = 80;
            }
        }

        when clicked {
            if (this.costumeId == 11) {
                if (this.cloneId != list[0]) {
                    canWin = false;
                }
                list.removeAt(0);
                this.hide();
                this.opacity = 0;
                this.size = 80;
                this.wait(0.1);
                if(list.length == 0){
                    if(canWin) {correct++;}
                    broadcast("restart");
                }
            }
        }
    }
}