Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stage {
- backdrop White("gallery:General/White")
- let list = [ ];
- let odd = 0;
- let even = 0;
- function Draw(Actor) {
- for(let i = 1; i <= this.Math.randomBetween(5, 20); i++) {
- Actor.nextCostume();
- this.wait(0.05);
- }
- }
- function Sum() {
- this.odd = 0;
- this.even = 0;
- let i = 0;
- while(i < this.list.length) {
- if(this.list[i] % 2 == 0) {
- this.even += this.list[i];
- }
- else {
- this.odd += this.list[i];
- }
- i++;
- }
- }
- when keyPressed("space") {
- this.Draw(this.Number10);
- this.wait(0.5);
- this.Draw(this.Number1);
- let value = this.Number1.costumeId + 10 * this.Number10.costumeId;
- this.list.push(value);
- this.Sum();
- let text = "Sum of even: " + this.even + ", sum of odd: " + this.odd;
- this.Ring.say(text);
- }
- when started {
- this.list = [ ];
- }
- actor Number10 {
- costume One("gallery:Text/One")
- costume Two("gallery:Text/Two")
- costume Three("gallery:Text/Three")
- costume Four("gallery:Text/Four")
- costume Five("gallery:Text/Five")
- costume Six("gallery:Text/Six")
- costume Seven("gallery:Text/Seven")
- costume Eight("gallery:Text/Eight")
- costume Nine("gallery:Text/Nine")
- when stage.started {
- this.setPosition(0, 0);
- }
- }
- actor Number1 {
- costume One("gallery:Text/One")
- costume Two("gallery:Text/Two")
- costume Three("gallery:Text/Three")
- costume Four("gallery:Text/Four")
- costume Five("gallery:Text/Five")
- costume Six("gallery:Text/Six")
- costume Seven("gallery:Text/Seven")
- costume Eight("gallery:Text/Eight")
- costume Nine("gallery:Text/Nine")
- when stage.started {
- this.setPosition(55, 0);
- }
- }
- actor Ring {
- costume Red("gallery:Objects/Ring Red")
- costume Blue("gallery:Objects/Ring Blue")
- when stage.started {
- this.setPosition(-300, -100);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement