Advertisement
Guest User

Untitled

a guest
Dec 15th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.38 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. using Microsoft.Xna.Framework.Content;
  7. using Microsoft.Xna.Framework;
  8. using Microsoft.Xna.Framework.Graphics;
  9. using Microsoft.Xna.Framework.Input;
  10.  
  11. namespace screenchange
  12. {
  13. class Screentwo
  14. {
  15. ContentManager Content;
  16. Vector2 ScreenSize;
  17.  
  18. Texture2D background2,mousearrow,left,main;
  19. Rectangle leftRectangle;
  20. Vector2 spriteOrigin;
  21. Vector2 spritePosition;
  22.  
  23. Texture2D fruit1, fruit2, fruit3, fruit4, fruit5;
  24. int MainPosX = 100,MainPosY = 600;
  25. int fallPosX = 800, fallPosY = 50;
  26. bool DoneRunning = false;
  27. bool FallingSeed = false;
  28. bool Bloom1 = false;
  29. bool Bloom2 = false;
  30. bool Bloom3 = false;
  31. bool Bloom4 = false;
  32. bool Bloom5 = false;
  33. Rectangle rectFruit1, rectFruit2, rectFruit3, rectFruit4, rectFruit5;
  34.  
  35. float rotation;
  36.  
  37. public bool change = false;
  38.  
  39. public Screentwo(ContentManager content, Vector2 screensize)
  40. {
  41. Content = content;
  42. ScreenSize = screensize;
  43. LoadContent();
  44. }
  45. public void LoadContent()
  46. {
  47. background2 = Content.Load<Texture2D>("background2");
  48. mousearrow = Content.Load<Texture2D>("mousearrow");
  49. main = Content.Load<Texture2D>("main");
  50. fruit1 = Content.Load<Texture2D>("fruit");
  51. fruit2 = Content.Load<Texture2D>("fruit");
  52. fruit3 = Content.Load<Texture2D>("fruit");
  53. fruit4 = Content.Load<Texture2D>("fruit");
  54. fruit5 = Content.Load<Texture2D>("fruit");
  55.  
  56. spritePosition = new Vector2(300, 250);
  57. }
  58.  
  59.  
  60.  
  61.  
  62.  
  63.  
  64. public void Update(GameTime gametime)
  65. {
  66. //leftRectangle = new Rectangle((int)spritePosition.X, (int)spritePosition.Y, left.Width, left.Height);
  67. //spriteOrigin = new Vector2(leftRectangle.Width/2, leftRectangle.Height/2);
  68.  
  69.  
  70.  
  71. if(MainPosX < 600)
  72. {
  73. MainPosX += 3;
  74. } //Scene2 opening
  75. else
  76. {
  77. MainPosX = 600;
  78. DoneRunning = true;
  79.  
  80. }
  81.  
  82. Rectangle mouseRec = new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 50, 50);//size+position
  83. rectFruit1 = new Rectangle( 911, 300, 111, 120);
  84. rectFruit2 = new Rectangle( 1000, 250, 111, 120);
  85. rectFruit3 = new Rectangle( 700, 200, 111, 120);
  86. rectFruit4 = new Rectangle( 780, 150, 111, 120);
  87. rectFruit5 = new Rectangle( 800, 100, 111, 120);
  88. if (Mouse.GetState().LeftButton == ButtonState.Pressed)
  89. {
  90. if (mouseRec.Intersects(rectFruit1))
  91. {
  92. System.Threading.Thread.Sleep(100);
  93. Bloom1 = true;
  94. }
  95. if (mouseRec.Intersects(rectFruit2))
  96. {
  97. System.Threading.Thread.Sleep(100);
  98. Bloom2 = true;
  99. }
  100. if (mouseRec.Intersects(rectFruit3))
  101. {
  102. System.Threading.Thread.Sleep(100);
  103. Bloom3 = true;
  104. }
  105. if (mouseRec.Intersects(rectFruit4))
  106. {
  107. System.Threading.Thread.Sleep(100);
  108. Bloom4 = true;
  109. }
  110. if (mouseRec.Intersects(rectFruit5))
  111. {
  112. System.Threading.Thread.Sleep(100);
  113. Bloom5 = true;
  114. }
  115. if(Bloom1 && Bloom2 && Bloom3 && Bloom4 && Bloom5)
  116. {
  117. FallingSeed = true;
  118. }
  119.  
  120. } //Condition before Seed falling
  121.  
  122.  
  123. if (DoneRunning && FallingSeed)
  124. {
  125. if (fallPosY < 600)
  126. {
  127. fallPosY += 10;
  128. }
  129. else
  130. {
  131. fallPosY = 600;
  132. }
  133. } //Seed Falling
  134.  
  135. }
  136.  
  137.  
  138.  
  139.  
  140. public void Draw(SpriteBatch spriteBatch)
  141. {
  142. spriteBatch.Draw(background2, new Rectangle(0, 0, 1420, 780), Color.White);
  143. //spriteBatch.Draw(left, spritePosition, null, Color.White,rotation,spriteOrigin,1f,SpriteEffects.None,0);
  144.  
  145. spriteBatch.Draw(main, new Rectangle(MainPosX, MainPosY, 100, 102), Color.White);
  146.  
  147. if (DoneRunning && FallingSeed)
  148. {
  149. spriteBatch.Draw(main, new Rectangle(fallPosX, fallPosY, 100, 102), Color.White);
  150. }
  151. spriteBatch.Draw(fruit1, new Rectangle(911, 300, 111, 120), Color.White);
  152. spriteBatch.Draw(fruit2, new Rectangle(1000, 250, 111, 120), Color.White);
  153. spriteBatch.Draw(fruit3, new Rectangle(700, 200, 111, 120), Color.White);
  154. spriteBatch.Draw(fruit4, new Rectangle(780, 150, 111, 120), Color.White);
  155. spriteBatch.Draw(fruit5, new Rectangle(800, 100, 111, 120), Color.White);
  156.  
  157. spriteBatch.Draw(mousearrow, new Rectangle(Mouse.GetState().X, Mouse.GetState().Y, 50, 50), Color.White);
  158.  
  159. }
  160.  
  161. }
  162. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement