Changeset 6989
- Timestamp:
- 2015-07-23 15:00:07 (8 years ago)
- Location:
- 2015/30/EmilL/KariO/KariO
- Files:
-
- 14 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
2015/30/EmilL/KariO/KariO/KariO/KariO.cs
r6940 r6989 1 1 using System; 2 using System.Linq; 2 3 using System.Collections.Generic; 3 4 using Jypeli; … … 13 14 const int RUUDUN_KOKO = 40; 14 15 15 int kenttänumero = 1; 16 int kenttänumero = 4; 17 18 List< Vector> Hyppypaikka =new List<Vector> (); 16 19 17 20 PlatformCharacter pelaaja1; … … 24 27 Image KiviKuva = LoadImage("Kivi"); 25 28 Image taustaKuva = LoadImage("Taustakuva"); 29 Image WindowsKuva = LoadImage("Windows"); 30 Image HaamuKuva = LoadImage("Haamu"); 31 Image RäjähdysKuva = LoadImage("Räjähdys"); 26 32 SoundEffect maaliAani = LoadSoundEffect("KeräysÄäni"); 33 SoundEffect RäjähdysÄäni = LoadSoundEffect("Explosion31"); 27 34 IntMeter pisteLaskuri; 28 35 29 36 public override void Begin() 30 37 { 38 SmoothTextures = false; 31 39 Aloitapeli(); 32 40 } … … 51 59 void LuoKentta() 52 60 { 53 61 Hyppypaikka.Clear(); 54 62 //1. Luetaan kuva uuteen ColorTileMappiin, kuvan nimen perässä ei .png-päätettä. 55 63 ColorTileMap ruudut = ColorTileMap.FromLevelAsset("Kenttä"+kenttänumero); … … 65 73 ruudut.SetTileMethod(Color.FromHexCode("4CFF00"), LisaaRuoho); 66 74 ruudut.SetTileMethod(Color.FromHexCode("7F0037"), LisaaKivi); 75 ruudut.SetTileMethod(Color.FromHexCode("FF7FB4"), LisaaWindows); 76 ruudut.SetTileMethod(Color.FromHexCode("FF05D9"), LisaaHyppypaikka); 77 ruudut.SetTileMethod(Color.FromHexCode("FF5000"), LisaaHaamu); 67 78 //3. Execute luo kentän 68 79 // Parametreina leveys ja korkeus … … 95 106 pelaaja.Position = paikka; 96 107 pelaaja.Mass = 50.0; 108 pelaaja.Tag = "pelaaja"; 97 109 pelaaja.Image = pelaajanKuva; 98 110 AddCollisionHandler(pelaaja, "Euronjuusto", TormaaJuustohampurilaiseen); … … 123 135 Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, -nopeus); 124 136 Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, nopeus); 125 Keyboard.Listen(Key. Space, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja2, hyppyNopeus);137 Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja2, hyppyNopeus); 126 138 127 139 ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); … … 152 164 void LisaaVihollinen(Vector paikka, double leveys, double korkeus) 153 165 { 154 PlatformCharacter Vihollinen = new PlatformCharacter(leveys , korkeus);166 PlatformCharacter Vihollinen = new PlatformCharacter(leveys-5, korkeus-5); 155 167 Vihollinen.Position = paikka; 156 168 Vihollinen.Mass = 4.0; … … 223 235 224 236 Label pisteNaytto = new Label(); 225 pisteNaytto.X = Screen. Left +100;237 pisteNaytto.X = Screen.Right -100; 226 238 pisteNaytto.Y = Screen.Top - 100; 227 pisteNaytto.TextColor = Color.Black; 228 pisteNaytto.Color = Color.White; 229 239 pisteNaytto.TextColor = Color.Red; 240 230 241 pisteNaytto.BindTo(pisteLaskuri); 231 242 Add(pisteNaytto); 232 243 } 244 void LisaaWindows(Vector paikka, double leveys, double korkeus) 245 { 246 PlatformCharacter Windows = new PlatformCharacter(leveys, korkeus); 247 Windows.Position = paikka; 248 Windows.Mass = 4.0; 249 Windows.Image = WindowsKuva; 250 Add(Windows); 251 Windows.Tag = "Windows"; 252 Windows.Weapon = new AssaultRifle(30, 10); 253 Windows.Weapon.InfiniteAmmo = true; 254 Windows.Weapon.FireRate = 0.2; 255 Windows.Weapon.ProjectileCollision = AmmusOsui; 256 257 IntMeter Elämät = new IntMeter(4, 0, 4); 258 ProgressBar elamaPalkki = new ProgressBar(20, 5); 259 elamaPalkki.Y = 20; 260 elamaPalkki.BindTo(Elämät); 261 Windows.Add(elamaPalkki); 262 263 AddCollisionHandler(Windows, "pelaaja", delegate(PhysicsObject W, PhysicsObject pelaaja) 264 { 265 double etäisyys = double.MaxValue; 266 Vector lähin = Vector.Zero; 267 foreach (Vector p in Hyppypaikka) 268 { 269 double e = Vector.Distance(pelaaja.Position, p); 270 if (e < etäisyys) 271 { 272 lähin = p; 273 etäisyys = e; 274 } 275 } 276 pelaaja.Position = lähin; 277 Elämät.Value--; 278 }); 279 280 Timer ajastin = new Timer(); 281 ajastin.Interval = 0.01; 282 ajastin.Timeout += delegate 283 { 284 AmmuAseella(Windows); 285 }; 286 ajastin.Start(); 287 288 Elämät.LowerLimit += delegate 289 { 290 Windows.Destroy(); 291 ajastin.Stop(); 292 }; 293 } 294 295 void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 296 { 297 ammus.Destroy(); 298 } 299 300 void AmmuAseella(PlatformCharacter Boss) 301 { 302 PlatformCharacter kohde = pelaaja1; 303 if (Vector.Distance(Boss.Position, pelaaja2.Position) < Vector.Distance(Boss.Position, pelaaja1.Position)) 304 { 305 kohde = pelaaja2; 306 } 307 308 Boss.Weapon.AbsoluteAngle = (kohde.Position - Boss.Position).Angle; 309 PhysicsObject ammus = Boss.Weapon.Shoot(); 310 311 if (ammus != null) 312 { 313 ammus.Velocity *= 0.2; 314 ammus.Size *= 1; 315 //ammus.Width *= 2; 316 ammus.Image = null; 317 ammus.Color = Color.Blue; 318 ammus.Tag = "Vihollinen"; 319 ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 320 } 321 } 322 void LisaaHyppypaikka(Vector paikka, double leveys, double korkeus) 323 { 324 Hyppypaikka.Add (paikka); 325 } 326 void LisaaHaamu(Vector paikka, double leveys, double korkeus) 327 { 328 PlatformCharacter Vihollinen = new PlatformCharacter(leveys*6, korkeus*6); 329 Vihollinen.Position = paikka; 330 Vihollinen.Y += korkeus*2; 331 Vihollinen.Mass = 4.0; 332 Vihollinen.Image = HaamuKuva; 333 Vihollinen.CollisionIgnoreGroup = 1; 334 Add(Vihollinen); 335 336 IntMeter Elämät = new IntMeter(1, 0, 10); 337 ProgressBar elamaPalkki = new ProgressBar(40, 10); 338 elamaPalkki.Y = 80; 339 elamaPalkki.BindTo(Elämät); 340 Vihollinen.Add(elamaPalkki); 341 342 Timer ajastin = new Timer(); 343 ajastin.Interval = 1.5; 344 ajastin.Timeout += delegate 345 { 346 PhysicsObject Ammus = new PhysicsObject(30, 30); 347 Ammus.Position = Vihollinen.Position; 348 Ammus.Bottom = Vihollinen.Bottom; 349 Ammus.Shape = Shape.Circle; 350 Ammus.CollisionIgnoreGroup = 1; 351 Ammus.KineticFriction = 0; 352 Ammus.StaticFriction = 0; 353 Ammus.Hit(new Vector(-500, 0)); 354 Ammus.LifetimeLeft = TimeSpan.FromSeconds(3); 355 Add(Ammus); 356 Ammus.Tag = "Vihollinen"; 357 }; 358 ajastin.Start(); 359 360 AddCollisionHandler(Vihollinen, "pelaaja", delegate(PhysicsObject W, PhysicsObject pelaaja) 361 { 362 Elämät.Value--; 363 if (Elämät.Value > 0) 364 { 365 double etäisyys = double.MaxValue; 366 Vector lähin = Vector.Zero; 367 foreach (Vector p in Hyppypaikka) 368 { 369 double e = Vector.Distance(pelaaja.Position, p); 370 if (e < etäisyys) 371 { 372 lähin = p; 373 etäisyys = e; 374 } 375 } 376 pelaaja.Position = lähin; 377 } 378 }); 379 380 Elämät.LowerLimit += delegate 381 { 382 Vihollinen.Destroy(); 383 ajastin.Stop(); 384 385 ExplosionSystem rajahdys = new ExplosionSystem(RäjähdysKuva, 1000); 386 Add(rajahdys); 387 rajahdys.AddEffect(Vihollinen.X, Vihollinen.Y, 200); 388 RäjähdysÄäni.Play(); 389 }; 390 } 391 233 392 234 393 } -
2015/30/EmilL/KariO/KariO/KariO/KariO.csproj.Debug.cachefile
r6940 r6989 10 10 Content\Kivi.xnb 11 11 Content\Taustakuva.xnb 12 Content\KenttÀ3.xnb 13 Content\Windows.xnb 14 Content\BigMac.xnb 15 Content\KenttÀ4.xnb 16 Content\Haamu.xnb 17 Content\RÀjÀhdys.xnb 18 Content\Explosion31.xnb 12 19 Content\tausta biisi.wma -
2015/30/EmilL/KariO/KariO/KariO/obj/x86/Debug/KariO.csproj.FileListAbsolute.txt
r6940 r6989 19 19 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kivi.xnb 20 20 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Taustakuva.xnb 21 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\KenttÀ3.xnb 22 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Windows.xnb 23 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\BigMac.xnb 24 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\KenttÀ4.xnb 25 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Haamu.xnb 26 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\RÀjÀhdys.xnb 27 C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Explosion31.xnb -
2015/30/EmilL/KariO/KariO/KariO/obj/x86/Debug/cachefile-{7A892C53-F6DC-4F86-A6EF-8724FB49CB87}-targetpath.txt
r6940 r6989 11 11 Content\Kivi.xnb 12 12 Content\Taustakuva.xnb 13 Content\KenttÀ3.xnb 14 Content\Windows.xnb 15 Content\BigMac.xnb 16 Content\KenttÀ4.xnb 17 Content\Haamu.xnb 18 Content\RÀjÀhdys.xnb 19 Content\Explosion31.xnb -
2015/30/EmilL/KariO/KariO/KariOContent/KariOContent.contentproj
r6940 r6989 122 122 </Compile> 123 123 </ItemGroup> 124 <ItemGroup> 125 <Compile Include="Kenttä3.png"> 126 <Name>Kenttä3</Name> 127 <Importer>TextureImporter</Importer> 128 <Processor>TextureProcessor</Processor> 129 </Compile> 130 </ItemGroup> 131 <ItemGroup> 132 <Compile Include="Windows.png"> 133 <Name>Windows</Name> 134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 </Compile> 137 </ItemGroup> 138 <ItemGroup> 139 <Compile Include="BigMac.png"> 140 <Name>BigMac</Name> 141 <Importer>TextureImporter</Importer> 142 <Processor>TextureProcessor</Processor> 143 </Compile> 144 </ItemGroup> 145 <ItemGroup> 146 <Compile Include="Kenttä4.png"> 147 <Name>Kenttä4</Name> 148 <Importer>TextureImporter</Importer> 149 <Processor>TextureProcessor</Processor> 150 </Compile> 151 </ItemGroup> 152 <ItemGroup> 153 <Compile Include="Haamu.png"> 154 <Name>Haamu</Name> 155 <Importer>TextureImporter</Importer> 156 <Processor>TextureProcessor</Processor> 157 </Compile> 158 </ItemGroup> 159 <ItemGroup> 160 <Compile Include="Räjähdys.png"> 161 <Name>Räjähdys</Name> 162 <Importer>TextureImporter</Importer> 163 <Processor>TextureProcessor</Processor> 164 </Compile> 165 </ItemGroup> 166 <ItemGroup> 167 <Compile Include="Explosion31.wav"> 168 <Name>Explosion31</Name> 169 <Importer>WavImporter</Importer> 170 <Processor>SoundEffectProcessor</Processor> 171 </Compile> 172 </ItemGroup> 124 173 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 125 174 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2015/30/EmilL/KariO/KariO/KariOContent/obj/x86/Debug/ContentPipeline.xml
r6940 r6989 37 37 <Options>None</Options> 38 38 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Piikki.xnb</Output> 39 <Time>2015-07-2 1T14:49:06.9585739+03:00</Time>39 <Time>2015-07-23T09:45:44.7611448+03:00</Time> 40 40 </Item> 41 41 <Item> … … 73 73 <Options>None</Options> 74 74 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kenttä1.xnb</Output> 75 <Time>2015-07-2 2T14:44:33.5485592+03:00</Time>75 <Time>2015-07-23T10:16:12.0443448+03:00</Time> 76 76 </Item> 77 77 <Item> … … 82 82 <Options>None</Options> 83 83 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kenttä2.xnb</Output> 84 <Time>2015-07-2 2T13:53:41.0909525+03:00</Time>84 <Time>2015-07-23T10:32:46.0765448+03:00</Time> 85 85 </Item> 86 86 <Item> … … 101 101 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Taustakuva.xnb</Output> 102 102 <Time>2015-07-22T14:32:55.0696525+03:00</Time> 103 </Item> 104 <Item> 105 <Source>Kenttä3.png</Source> 106 <Name>Kenttä3</Name> 107 <Importer>TextureImporter</Importer> 108 <Processor>TextureProcessor</Processor> 109 <Options>None</Options> 110 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kenttä3.xnb</Output> 111 <Time>2015-07-23T12:31:51.7570794+03:00</Time> 112 </Item> 113 <Item> 114 <Source>Windows.png</Source> 115 <Name>Windows</Name> 116 <Importer>TextureImporter</Importer> 117 <Processor>TextureProcessor</Processor> 118 <Options>None</Options> 119 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Windows.xnb</Output> 120 <Time>2015-07-23T10:39:05.2301448+03:00</Time> 121 </Item> 122 <Item> 123 <Source>BigMac.png</Source> 124 <Name>BigMac</Name> 125 <Importer>TextureImporter</Importer> 126 <Processor>TextureProcessor</Processor> 127 <Options>None</Options> 128 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\BigMac.xnb</Output> 129 <Time>2015-07-23T12:22:08.616761+03:00</Time> 130 </Item> 131 <Item> 132 <Source>Kenttä4.png</Source> 133 <Name>Kenttä4</Name> 134 <Importer>TextureImporter</Importer> 135 <Processor>TextureProcessor</Processor> 136 <Options>None</Options> 137 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kenttä4.xnb</Output> 138 <Time>2015-07-23T14:06:53.9881882+03:00</Time> 139 </Item> 140 <Item> 141 <Source>Haamu.png</Source> 142 <Name>Haamu</Name> 143 <Importer>TextureImporter</Importer> 144 <Processor>TextureProcessor</Processor> 145 <Options>None</Options> 146 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Haamu.xnb</Output> 147 <Time>2015-07-23T13:50:49.8793882+03:00</Time> 148 </Item> 149 <Item> 150 <Source>Räjähdys.png</Source> 151 <Name>Räjähdys</Name> 152 <Importer>TextureImporter</Importer> 153 <Processor>TextureProcessor</Processor> 154 <Options>None</Options> 155 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Räjähdys.xnb</Output> 156 <Time>2015-07-23T14:41:42.8001882+03:00</Time> 157 </Item> 158 <Item> 159 <Source>Explosion31.wav</Source> 160 <Name>Explosion31</Name> 161 <Importer>WavImporter</Importer> 162 <Processor>SoundEffectProcessor</Processor> 163 <Options>None</Options> 164 <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Explosion31.xnb</Output> 165 <Time>2015-07-23T14:53:18.3855882+03:00</Time> 103 166 </Item> 104 167 <BuildSuccessful>true</BuildSuccessful>
Note: See TracChangeset
for help on using the changeset viewer.