- Timestamp:
- 2016-07-29 11:35:54 (6 years ago)
- Location:
- 2016/30/JoonasL/Arrow
- Files:
-
- 2 added
- 2 deleted
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/30/JoonasL/Arrow/Arrow/Arrow/Arrow.cs
r8218 r8245 2 2 using System.Collections.Generic; 3 3 using Jypeli; 4 using Jypeli.Assets;5 4 using Jypeli.Controls; 6 5 using Jypeli.Effects; … … 16 15 private ExplosionSystem redEffect = new ExplosionSystem(LoadImage("particle_2"), 250); 17 16 17 private SoundEffect explosionSound = LoadSoundEffect("explosion"); 18 18 19 private Label[] menuLabels = new Label[4]; 19 20 20 private bool down_1 = true, down_2 = true, dead_1 = true, dead_2 = true, singlePlayer , launched = false;21 private bool down_1 = true, down_2 = true, dead_1 = true, dead_2 = true, singlePlayer = true, launched = false; 21 22 22 23 private float MOVEMENT_SPEED = 0, multiplier = 1000, difficulty = 1, seconds_1 = 0, seconds_2 = 0; … … 26 27 27 28 public override void Begin() 28 { 29 { 29 30 Window.Fullscreen = true; 30 31 … … 61 62 Mouse.ListenOn(menuLabels[1], MouseButton.Left, ButtonState.Pressed, Menu_Second, null, false); 62 63 Add(menuLabels[1]); 63 64 menuLabels[2] = new Label(" Lopeta Peli");64 65 menuLabels[2] = new Label("Näppäimet"); 65 66 menuLabels[2].X = Screen.Left * 0.885; 66 67 menuLabels[2].Y = Screen.Top * 0.76; 67 68 menuLabels[2].TextScale = new Vector(1.5, 1.5); 68 Mouse.ListenOn(menuLabels[2], MouseButton.Left, ButtonState.Pressed, Exit, null);69 Mouse.ListenOn(menuLabels[2], MouseButton.Left, ButtonState.Pressed, ShowControls, null); 69 70 Add(menuLabels[2]); 70 71 71 menuLabels[3] = null; 72 menuLabels[3] = new Label("Lopeta Peli"); 73 menuLabels[3].X = Screen.Left * 0.885; 74 menuLabels[3].Y = Screen.Top * 0.675; 75 menuLabels[3].TextScale = new Vector(1.5, 1.5); 76 Mouse.ListenOn(menuLabels[3], MouseButton.Left, ButtonState.Pressed, Exit, null); 77 Add(menuLabels[3]); 72 78 } 73 79 … … 116 122 } 117 123 124 private void ShowControls () 125 { 126 ClearAll(); 127 128 Level.Background.Color = Color.Black; 129 130 Level.Background.Image = LoadImage("background"); 131 132 Mouse.IsCursorVisible = true; 133 134 Label label = new Label("R - Aloita peli alusta \n\nVasen hiiren painike - Nosta punaista pelaajaa \n\nVälilyönti - Nosta sinistä pelaajaa \n\nEscape - Peruuta"); 135 label.X = Screen.Left * 0.73; 136 label.Y = Screen.Top * 0.8; 137 Add(label); 138 139 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Menu_First, null); 140 } 141 118 142 private void Start (float i) 119 143 { … … 128 152 129 153 ball_1 = new PhysicsObject(50, 50, Shape.Circle); 154 ball_1.X = Screen.Left * 1.5; 155 ball_1.Tag = "Obstacle"; 156 ball_1.Width *= 5; 157 ball_1.Height *= 5; 130 158 ball_1.Color = Color.Black; 131 ball_2 = new PhysicsObject(50, 50, Shape.Circle);132 159 ball_1.IsVisible = false; 133 ball_2.IsVisible = false;134 160 135 161 Add(ball_1); 136 Add(ball_2);137 162 138 163 difficulty = i; … … 173 198 174 199 player_1 = new PhysicsObject(50, 50, Shape.Triangle); 175 player_1. Image = LoadImage("arrow");176 player_1.Angle = Angle.FromDegrees( 325);200 player_1.Color = Color.Black; 201 player_1.Angle = Angle.FromDegrees(225); 177 202 Add(player_1); 178 203 179 204 if (!singlePlayer) 180 205 { 206 ball_2 = new PhysicsObject(50, 50, Shape.Circle); 207 ball_2.X = Screen.Left * 1.5; 208 ball_2.Tag = "Obstacle"; 209 ball_2.Width *= 2.5; 210 ball_2.Height *= 2.5; 211 ball_2.Color = Color.Black; 212 ball_2.IsVisible = false; 213 214 Add(ball_2); 215 216 ball_1.Width = ball_2.Width; 217 ball_1.Height = ball_2.Height; 218 181 219 label_2.Y = Screen.Top - label_1.Width * 2 - label_1.Height * 2; 182 220 label_2.TextScale = new Vector(1.25, 1.25); … … 185 223 186 224 player_2 = new PhysicsObject(50, 50, Shape.Triangle); 187 player_2. Image = LoadImage("arrow");188 player_2.Angle = Angle.FromDegrees( 325);225 player_2.Color = Color.Black; 226 player_2.Angle = Angle.FromDegrees(225); 189 227 Add(player_2); 190 228 191 AddCollisionHandler(player_2, " Percent", Die_2);192 } 193 194 AddCollisionHandler(player_1, " Percent", Die_1);229 AddCollisionHandler(player_2, "Obstacle", Die_2); 230 } 231 232 AddCollisionHandler(player_1, "Obstacle", Die_1); 195 233 } 196 234 … … 199 237 Mouse.Listen(MouseButton.Left, ButtonState.Down, MoveUp_1, null); 200 238 Mouse.Listen(MouseButton.Left, ButtonState.Up, MoveDown_1, null); 239 201 240 Keyboard.Listen(Key.R, ButtonState.Pressed, Restart, null); 241 202 242 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Menu_First, null); 203 243 … … 213 253 player_1.IsVisible = true; 214 254 player_1.Y = 0; 255 215 256 points_1 = new List<Vector>(); 216 257 points_1.Add(new Vector(Screen.Left * 1.5, 0)); 258 217 259 dead_1 = false; 260 261 ball_1.X = Screen.Left * 1.5; 218 262 219 263 if (!singlePlayer) … … 221 265 player_2.IsVisible = true; 222 266 player_2.Y = 0; 267 223 268 points_2 = new List<Vector>(); 224 269 points_2.Add(new Vector(Screen.Left * 1.5, 0)); 270 225 271 dead_2 = false; 272 273 ball_2.X = Screen.Left * 1.5; 226 274 } 227 275 … … 388 436 } 389 437 390 double value = 0.75;438 double value = RandomGen.NextInt(0, 500); 391 439 392 440 if (!launched) 393 441 { 394 if (value == 0.75)442 if (value == 250) 395 443 { 396 444 launched = true; 397 ball_1.X = 4000; 445 446 ball_1.X = Screen.Left * 1.5; 447 ball_1.Y = player_1.Y; 398 448 ball_1.IsVisible = true; 399 ball_2.IsVisible = true; 449 450 if (!singlePlayer) 451 { 452 ball_2.X = Screen.Left * 1.5; 453 ball_2.Y = player_2.Y; 454 ball_2.IsVisible = true; 455 } 400 456 } 401 457 } 402 458 else 403 459 { 404 Vector direction = ball_1.Position - player_1.Position; 405 float length = (float) Math.Sqrt(Math.Pow(direction.X, 2) + Math.Pow(direction.Y, 2)); 406 direction.X /= length; 407 direction.Y /= length; 408 ball_1.Position -= direction * 10; 409 } 410 } 411 } 412 413 private void RandomPercentPosition (PhysicsObject physicsObject, int index) 414 { 460 if (!singlePlayer) 461 { 462 ball_1.X += 1500 * difficulty * time.SinceLastUpdate.TotalSeconds; 463 464 ball_2.X += 1500 * difficulty * time.SinceLastUpdate.TotalSeconds; 465 466 if (ball_1.X >= Screen.Right * 1.5 && ball_2.X >= Screen.Right * 1.5) 467 { 468 launched = false; 469 ball_1.IsVisible = false; 470 ball_2.IsVisible = false; 471 } 472 } 473 else if (!dead_1) 474 { 475 ball_1.X += 1500 * difficulty * time.SinceLastUpdate.TotalSeconds; 476 477 if (ball_1.X >= Screen.Right * 1.5) 478 { 479 launched = false; 480 ball_1.IsVisible = false; 481 } 482 } 483 } 484 } 485 } 486 487 private void RandomPercentPosition (PhysicsObject physicsObject, int index) 488 { 415 489 physicsObject.X = RandomGen.NextDouble(Level.Right * 2.5, Level.Right * 6.5); 416 490 … … 430 504 break; 431 505 } 432 433 } 434 435 private void Die_1 (PhysicsObject a, PhysicsObject percent) 436 { 506 } 507 508 private void Die_1 (PhysicsObject a, PhysicsObject percent) 509 { 437 510 if (dead_1) { return; } 511 512 explosionSound.Play(); 438 513 439 514 player_1.IsVisible = false; … … 447 522 if (dead_2) { return; } 448 523 524 explosionSound.Play(); 525 449 526 player_2.IsVisible = false; 450 527 dead_2 = true; … … 454 531 455 532 private void MoveUp_1() 456 {533 { 457 534 if (dead_1) { return; } 458 535 459 536 points_1.Add(player_1.Position - new Vector(5, 0)); 460 player_1.Angle = Angle.FromDegrees( 45);537 player_1.Angle = Angle.FromDegrees(315); 461 538 down_1 = false; 462 }539 } 463 540 464 541 private void MoveDown_1() … … 467 544 468 545 points_1.Add(player_1.Position - new Vector(5, 0)); 469 player_1.Angle = Angle.FromDegrees( 325);546 player_1.Angle = Angle.FromDegrees(225); 470 547 down_1 = true; 471 548 } … … 476 553 477 554 points_2.Add(player_2.Position - new Vector(5, 0)); 478 player_2.Angle = Angle.FromDegrees( 45);555 player_2.Angle = Angle.FromDegrees(315); 479 556 down_2 = false; 480 557 } … … 485 562 486 563 points_2.Add(player_2.Position - new Vector(5, 0)); 487 player_2.Angle = Angle.FromDegrees( 325);564 player_2.Angle = Angle.FromDegrees(225); 488 565 down_2 = true; 489 566 } … … 493 570 PhysicsObject physicsObject = new PhysicsObject(100, 100); 494 571 physicsObject.Color = new Color(RandomGen.NextInt(0, 225), RandomGen.NextInt(0, 225), RandomGen.NextInt(0, 225)); 495 physicsObject.Tag = " Percent";572 physicsObject.Tag = "Obstacle"; 496 573 obstacles[index] = physicsObject; 497 574 RandomPercentPosition(physicsObject, index); -
2016/30/JoonasL/Arrow/Arrow/Arrow/Arrow.csproj.Debug.cachefile
r8218 r8245 1 Content\note.xnb2 Content\coin.xnb3 1 Content\background.xnb 4 Content\arrow.xnb5 2 Content\particle_2.xnb 6 3 Content\particle_1.xnb 4 Content\explosion.xnb -
2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/Arrow.csproj.FileListAbsolute.txt
r8218 r8245 8 8 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\obj\x86\Debug\Arrow.pdb 9 9 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\background.xnb 10 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\arrow.xnb11 10 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\particle_2.xnb 12 11 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\particle_1.xnb 12 C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\explosion.xnb -
2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/ContentPipeline-{2DF1C49F-6BF7-4BA9-9FE6-D0E53C97361E}.xml
r8218 r8245 10 10 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\background.xnb</Output> 11 11 <Time>2016-07-27T13:30:15.3441023+03:00</Time> 12 </Item>13 <Item>14 <Source>arrow.png</Source>15 <Name>arrow</Name>16 <Importer>TextureImporter</Importer>17 <Processor>TextureProcessor</Processor>18 <Options>None</Options>19 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\arrow.xnb</Output>20 <Time>2016-07-27T14:39:40.043614+03:00</Time>21 12 </Item> 22 13 <Item> … … 37 28 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\particle_1.xnb</Output> 38 29 <Time>2016-07-28T13:16:20.4270486+03:00</Time> 30 </Item> 31 <Item> 32 <Source>explosion.wav</Source> 33 <Name>explosion</Name> 34 <Importer>WavImporter</Importer> 35 <Processor>SoundEffectProcessor</Processor> 36 <Options>None</Options> 37 <Output>C:\MyTemp\JoonasL\Arrow\Arrow\Arrow\bin\x86\Debug\Content\explosion.xnb</Output> 38 <Time>2016-07-29T10:57:19.8262212+03:00</Time> 39 39 </Item> 40 40 <BuildSuccessful>true</BuildSuccessful> -
2016/30/JoonasL/Arrow/Arrow/Arrow/obj/x86/Debug/cachefile-{2DF1C49F-6BF7-4BA9-9FE6-D0E53C97361E}-targetpath.txt
r8218 r8245 1 1 Content\background.xnb 2 Content\arrow.xnb3 2 Content\particle_2.xnb 4 3 Content\particle_1.xnb 4 Content\explosion.xnb -
2016/30/JoonasL/Arrow/Arrow/ArrowContent/ArrowContent.contentproj
r8218 r8245 53 53 </ItemGroup> 54 54 <ItemGroup> 55 <Compile Include="arrow.png">56 <Name>arrow</Name>57 <Importer>TextureImporter</Importer>58 <Processor>TextureProcessor</Processor>59 </Compile>60 </ItemGroup>61 <ItemGroup>62 55 <Compile Include="particle_2.png"> 63 56 <Name>particle_2</Name> … … 73 66 </Compile> 74 67 </ItemGroup> 68 <ItemGroup> 69 <Compile Include="explosion.wav"> 70 <Name>explosion</Name> 71 <Importer>WavImporter</Importer> 72 <Processor>SoundEffectProcessor</Processor> 73 </Compile> 74 </ItemGroup> 75 75 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 76 76 <!-- 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.