Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. stage {
  2. backdrop White("gallery:General/White")
  3. let list = [ ];
  4. let odd = 0;
  5. let even = 0;
  6. function Draw(Actor) {
  7. for(let i = 1; i <= this.Math.randomBetween(5, 20); i++) {
  8. Actor.nextCostume();
  9. this.wait(0.05);
  10. }
  11. }
  12. function Sum() {
  13. this.odd = 0;
  14. this.even = 0;
  15. let i = 0;
  16. while(i < this.list.length) {
  17. if(this.list[i] % 2 == 0) {
  18. this.even += this.list[i];
  19. }
  20. else {
  21. this.odd += this.list[i];
  22. }
  23. i++;
  24. }
  25. }
  26. when keyPressed("space") {
  27. this.Draw(this.Number10);
  28. this.wait(0.5);
  29. this.Draw(this.Number1);
  30. let value = this.Number1.costumeId + 10 * this.Number10.costumeId;
  31. this.list.push(value);
  32. this.Sum();
  33. let text = "Sum of even: " + this.even + ", sum of odd: " + this.odd;
  34. this.Ring.say(text);
  35. }
  36. when started {
  37. this.list = [ ];
  38. }
  39.  
  40. actor Number10 {
  41. costume One("gallery:Text/One")
  42. costume Two("gallery:Text/Two")
  43. costume Three("gallery:Text/Three")
  44. costume Four("gallery:Text/Four")
  45. costume Five("gallery:Text/Five")
  46. costume Six("gallery:Text/Six")
  47. costume Seven("gallery:Text/Seven")
  48. costume Eight("gallery:Text/Eight")
  49. costume Nine("gallery:Text/Nine")
  50. when stage.started {
  51. this.setPosition(0, 0);
  52. }
  53. }
  54.  
  55. actor Number1 {
  56. costume One("gallery:Text/One")
  57. costume Two("gallery:Text/Two")
  58. costume Three("gallery:Text/Three")
  59. costume Four("gallery:Text/Four")
  60. costume Five("gallery:Text/Five")
  61. costume Six("gallery:Text/Six")
  62. costume Seven("gallery:Text/Seven")
  63. costume Eight("gallery:Text/Eight")
  64. costume Nine("gallery:Text/Nine")
  65. when stage.started {
  66. this.setPosition(55, 0);
  67. }
  68. }
  69.  
  70. actor Ring {
  71. costume Red("gallery:Objects/Ring Red")
  72. costume Blue("gallery:Objects/Ring Blue")
  73. when stage.started {
  74. this.setPosition(-300, -100);
  75. }
  76. }
  77. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement