Changeset 8174 for 2016/30/JoonasL
- Timestamp:
- 2016-07-27 15:04:27 (6 years ago)
- Location:
- 2016/30/JoonasL/Arrow
- Files:
-
- 4 added
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/30/JoonasL/Arrow/Arrow/Arrow/Arrow.cs
r8142 r8174 16 16 private ExplosionSystem coinEffect = new ExplosionSystem(LoadImage("coin"), 250); 17 17 18 private double labelLeft;18 private Label[] menuLabels = new Label[4]; 19 19 20 20 private bool down = true, dead = true; 21 private float MOVEMENT_SPEED = 0, multiplier = 1000; 21 22 private float MOVEMENT_SPEED = 0, multiplier = 1000, difficulty = 1; 22 23 private List<Vector> points = new List<Vector>(); 23 24 private Image redPercent, greenPercent; … … 28 29 public override void Begin() 29 30 { 30 labelLeft = Screen.Left * 0.965;31 MultiSelectWindow multiSelectWindow = new MultiSelectWindow("Arrow", "Alota peli", "Lopeta peli");32 multiSelectWindow.AddItemHandler(0, Start);33 multiSelectWindow.AddItemHandler(1, Exit);34 31 Window.Fullscreen = true; 35 32 SmoothTextures = false; 36 Add(multiSelectWindow); 37 SetListeners(); 38 } 39 40 private void Start () 41 { 42 dead = false; 33 34 Level.Background.Image = LoadImage("background"); 35 36 Timer.SingleShot(0.5, Menu_First); 37 43 38 redPercent = LoadImage("percent"); 44 39 greenPercent = LoadImage("percent_1"); 40 } 41 42 private void Menu_First () 43 { 44 ClearAll(); 45 46 Level.Background.Image = LoadImage("background"); 47 48 Mouse.IsCursorVisible = true; 49 Mouse.ListenMovement(1.0, OnMenuMouseMove, null); 50 51 menuLabels[0] = new Label("Aloita peli"); 52 menuLabels[0].X = Screen.Left * 0.89; 53 menuLabels[0].Y = Screen.Top * 0.93; 54 menuLabels[0].TextScale = new Vector(1.5, 1.5); 55 Mouse.ListenOn(menuLabels[0], MouseButton.Left, ButtonState.Pressed, Menu_Second, null); 56 Add(menuLabels[0]); 57 58 menuLabels[1] = new Label("Lopeta Peli"); 59 menuLabels[1].X = Screen.Left * 0.885; 60 menuLabels[1].Y = Screen.Top * 0.845; 61 menuLabels[1].TextScale = new Vector(1.5, 1.5); 62 Mouse.ListenOn(menuLabels[1], MouseButton.Left, ButtonState.Pressed, Exit, null); 63 Add(menuLabels[1]); 64 65 menuLabels[2] = null; 66 menuLabels[3] = null; 67 } 68 69 private void Menu_Second () 70 { 71 ClearAll(); 72 73 Level.Background.Image = LoadImage("background"); 74 75 Mouse.IsCursorVisible = true; 76 Mouse.ListenMovement(1.0, OnMenuMouseMove, null); 77 78 menuLabels[0] = new Label("Helppo"); 79 menuLabels[0].X = Screen.Left * 0.91; 80 menuLabels[0].Y = Screen.Top * 0.92; 81 menuLabels[0].TextScale = new Vector(1.5, 1.5); 82 Mouse.ListenOn(menuLabels[0], MouseButton.Left, ButtonState.Pressed, Start, null, 1f); 83 Add(menuLabels[0]); 84 85 menuLabels[1] = new Label("Keskivaikea"); 86 menuLabels[1].X = Screen.Left * 0.872; 87 menuLabels[1].Y = Screen.Top * 0.835; 88 menuLabels[1].TextScale = new Vector(1.5, 1.5); 89 Mouse.ListenOn(menuLabels[1], MouseButton.Left, ButtonState.Pressed, Start, null, 1.25f); 90 Add(menuLabels[1]); 91 92 menuLabels[2] = new Label("Vaikea"); 93 menuLabels[2].X = Screen.Left * 0.91; 94 menuLabels[2].Y = Screen.Top * 0.75; 95 menuLabels[2].TextScale = new Vector(1.5, 1.5); 96 Mouse.ListenOn(menuLabels[2], MouseButton.Left, ButtonState.Pressed, Start, null, 1.5f); 97 Add(menuLabels[2]); 98 99 menuLabels[3] = new Label("Hullu"); 100 menuLabels[3].X = Screen.Left * 0.92; 101 menuLabels[3].Y = Screen.Top * 0.665; 102 menuLabels[3].TextScale = new Vector(1.5, 1.5); 103 Mouse.ListenOn(menuLabels[3], MouseButton.Left, ButtonState.Pressed, Start, null, 2f); 104 Add(menuLabels[3]); 105 106 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Menu_First, null); 107 } 108 109 private void Start (float i) 110 { 111 ClearAll(); 112 113 difficulty = i; 114 45 115 Level.Background.Color = Color.White; 116 117 SetListeners(); 118 119 dead = false; 120 121 noteEffect.MinRotationSpeed = 20; 122 noteEffect.MaxRotationSpeed = 20; 123 coinEffect.MinRotationSpeed = 20; 124 coinEffect.MaxRotationSpeed = 20; 46 125 47 126 Add(noteEffect); … … 53 132 CreatePercent(3); 54 133 55 labelYearsLeft = new Label( yearsLeft + " years left");134 labelYearsLeft = new Label(); 56 135 labelYearsLeft.X = -880; 57 136 labelYearsLeft.Y = 500; … … 59 138 60 139 player = new PhysicsObject(50, 50, Shape.Triangle); 61 player.Color = Color.Black; 62 player.Angle = Angle.FromDegrees(225); 63 player.Restitution = 10; 140 player.Image = LoadImage("arrow"); 141 player.Angle = Angle.FromDegrees(325); 64 142 Add(player); 65 143 … … 69 147 private void SetListeners() 70 148 { 71 Keyboard.Listen(Key.Space, ButtonState.Down, MoveUp, ""); 72 Keyboard.Listen(Key.Space, ButtonState.Up, MoveDown, ""); 149 Mouse.Listen(MouseButton.Left, ButtonState.Down, MoveUp, null); 150 Mouse.Listen(MouseButton.Left, ButtonState.Up, MoveDown, null); 151 Keyboard.Listen(Key.R, ButtonState.Pressed, Start, null, difficulty); 73 152 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, ""); 74 153 } … … 76 155 protected override void Paint(Canvas canvas) 77 156 { 78 if (!down) 79 { 80 canvas.BrushColor = new Color(0, 255, 0, 255); 81 } 82 else 83 { 84 canvas.BrushColor = Color.Red; 85 } 86 87 double x = canvas.Left + 100; 88 double y = canvas.Top - 100; 157 if (!down) { canvas.BrushColor = new Color(0, 255, 0, 255); } else { canvas.BrushColor = Color.Red; } 89 158 90 159 for (int i = 0; i < points.Count; i++) … … 123 192 if (!dead) 124 193 { 125 MOVEMENT_SPEED = multiplier * (float)time.SinceLastUpdate.TotalSeconds ;194 MOVEMENT_SPEED = multiplier * (float)time.SinceLastUpdate.TotalSeconds * difficulty; 126 195 multiplier += (float) time.SinceLastUpdate.TotalMilliseconds / 60; 127 196 … … 137 206 } 138 207 139 labelYearsLeft.Text = (int) yearsLeft + " vuotta jäljellä en emmin maailman konkurssia";140 141 labelYearsLeft.Left = labelLeft;208 labelYearsLeft.Text = (int) yearsLeft + " vuotta jäljellä ennen maailman konkurssia"; 209 210 labelYearsLeft.Left = Screen.Left * 0.965; 142 211 143 212 for (int i = 0; i < 4; i++) 144 213 { 145 214 percents[i].X -= MOVEMENT_SPEED; 146 if (percents[i].X < Screen.Left * 1.2) { RandomPercentPosition(percents[i], i); } 215 216 if (percents[i].X < Screen.Left * 1.2) 217 { 218 RandomPercentPosition(percents[i], i); 219 percents[i].Image = greenOrRed(); 220 } 147 221 } 148 222 … … 178 252 double value = RandomGen.NextDouble(0, 1); 179 253 180 if (value < 0. 9)254 if (value < 0.5) 181 255 { 182 256 return redPercent; … … 192 266 if (percent.Image.Equals(greenPercent)) 193 267 { 194 yearsLeft += 1;268 yearsLeft += 5; 195 269 } 196 270 else … … 198 272 player.Destroy(); 199 273 dead = true; 200 noteEffect.AddEffect(player.Position + new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-100, 100)), 150);201 coinEffect.AddEffect(player.Position + new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-100, 100)), 150);274 noteEffect.AddEffect(player.Position + new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-100, 100)), 25); 275 coinEffect.AddEffect(player.Position + new Vector(RandomGen.NextDouble(-100, 100), RandomGen.NextDouble(-100, 100)), 25); 202 276 } 203 277 } … … 208 282 209 283 points.Add(player.Position - new Vector(10, 0)); 210 player.Angle = Angle.FromDegrees( 315);284 player.Angle = Angle.FromDegrees(45); 211 285 down = false; 212 286 } … … 217 291 218 292 points.Add(player.Position - new Vector(10, 0)); 219 player.Angle = Angle.FromDegrees( 225);293 player.Angle = Angle.FromDegrees(325); 220 294 down = true; 221 295 } … … 231 305 return physicsObject; 232 306 } 307 308 private void OnMenuMouseMove (AnalogState analogState) 309 { 310 foreach (Label label in menuLabels) 311 { 312 if (label != null) 313 { 314 if (Mouse.IsCursorOn(label)) 315 { 316 label.TextColor = Color.Red; 317 } 318 else 319 { 320 label.TextColor = Color.Black; 321 } 322 } 323 } 324 } 233 325 } -
2016/30/JoonasL/Arrow/Arrow/Arrow/Arrow.csproj.Debug.cachefile
r8142 r8174 4 4 Content\note.xnb 5 5 Content\coin.xnb 6 Content\background.xnb 7 Content\arrow.xnb -
2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/Arrow.csproj.FileListAbsolute.txt
r8142 r8174 12 12 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\note.xnb 13 13 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\coin.xnb 14 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\background.xnb 15 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\arrow.xnb -
2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/ContentPipeline-{2DF1C49F-6BF7-4BA9-9FE6-D0E53C97361E}.xml
r8142 r8174 46 46 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\coin.xnb</Output> 47 47 <Time>2016-07-27T10:30:39.3061092+03:00</Time> 48 </Item> 49 <Item> 50 <Source>background.png</Source> 51 <Name>background</Name> 52 <Importer>TextureImporter</Importer> 53 <Processor>TextureProcessor</Processor> 54 <Options>None</Options> 55 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\background.xnb</Output> 56 <Time>2016-07-27T13:30:15.3441023+03:00</Time> 57 </Item> 58 <Item> 59 <Source>arrow.png</Source> 60 <Name>arrow</Name> 61 <Importer>TextureImporter</Importer> 62 <Processor>TextureProcessor</Processor> 63 <Options>None</Options> 64 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\arrow.xnb</Output> 65 <Time>2016-07-27T14:39:40.043614+03:00</Time> 48 66 </Item> 49 67 <BuildSuccessful>true</BuildSuccessful> -
2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/cachefile-{2DF1C49F-6BF7-4BA9-9FE6-D0E53C97361E}-targetpath.txt
r8142 r8174 4 4 Content\note.xnb 5 5 Content\coin.xnb 6 Content\background.xnb 7 Content\arrow.xnb -
2016/30/JoonasL/Arrow/Arrow/ArrowContent/ArrowContent.contentproj
r8142 r8174 80 80 </Compile> 81 81 </ItemGroup> 82 <ItemGroup> 83 <Compile Include="background.png"> 84 <Name>background</Name> 85 <Importer>TextureImporter</Importer> 86 <Processor>TextureProcessor</Processor> 87 </Compile> 88 </ItemGroup> 89 <ItemGroup> 90 <Compile Include="arrow.png"> 91 <Name>arrow</Name> 92 <Importer>TextureImporter</Importer> 93 <Processor>TextureProcessor</Processor> 94 </Compile> 95 </ItemGroup> 82 96 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 83 97 <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Note: See TracChangeset
for help on using the changeset viewer.