Changeset 6989


Ignore:
Timestamp:
2015-07-23 15:00:07 (8 years ago)
Author:
raemvele
Message:

Kaikkee

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  
    11using System; 
     2using System.Linq; 
    23using System.Collections.Generic; 
    34using Jypeli; 
     
    1314    const int RUUDUN_KOKO = 40; 
    1415 
    15     int kenttänumero = 1; 
     16    int kenttänumero = 4; 
     17 
     18   List< Vector> Hyppypaikka =new List<Vector> (); 
    1619 
    1720    PlatformCharacter pelaaja1; 
     
    2427    Image KiviKuva = LoadImage("Kivi"); 
    2528    Image taustaKuva = LoadImage("Taustakuva"); 
     29    Image WindowsKuva = LoadImage("Windows"); 
     30    Image HaamuKuva = LoadImage("Haamu"); 
     31    Image RäjähdysKuva = LoadImage("Räjähdys"); 
    2632    SoundEffect maaliAani = LoadSoundEffect("KeräysÄäni"); 
     33    SoundEffect RäjähdysÄäni = LoadSoundEffect("Explosion31"); 
    2734    IntMeter pisteLaskuri; 
    2835 
    2936    public override void Begin() 
    3037    { 
     38        SmoothTextures = false; 
    3139        Aloitapeli(); 
    3240    } 
     
    5159    void LuoKentta() 
    5260    { 
    53  
     61        Hyppypaikka.Clear(); 
    5462        //1. Luetaan kuva uuteen ColorTileMappiin, kuvan nimen perässä ei .png-päätettä. 
    5563        ColorTileMap ruudut = ColorTileMap.FromLevelAsset("Kenttä"+kenttänumero); 
     
    6573        ruudut.SetTileMethod(Color.FromHexCode("4CFF00"), LisaaRuoho); 
    6674        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); 
    6778        //3. Execute luo kentän 
    6879        //   Parametreina leveys ja korkeus 
     
    95106        pelaaja.Position = paikka; 
    96107        pelaaja.Mass = 50.0; 
     108        pelaaja.Tag = "pelaaja"; 
    97109        pelaaja.Image = pelaajanKuva; 
    98110        AddCollisionHandler(pelaaja, "Euronjuusto", TormaaJuustohampurilaiseen); 
     
    123135        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja2, -nopeus); 
    124136        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); 
    126138 
    127139        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
     
    152164    void LisaaVihollinen(Vector paikka, double leveys, double korkeus) 
    153165    { 
    154         PlatformCharacter Vihollinen = new PlatformCharacter(leveys, korkeus); 
     166        PlatformCharacter Vihollinen = new PlatformCharacter(leveys-5, korkeus-5); 
    155167        Vihollinen.Position = paikka; 
    156168        Vihollinen.Mass = 4.0; 
     
    223235 
    224236         Label pisteNaytto = new Label(); 
    225          pisteNaytto.X = Screen.Left + 100; 
     237         pisteNaytto.X = Screen.Right  -100; 
    226238         pisteNaytto.Y = Screen.Top - 100; 
    227          pisteNaytto.TextColor = Color.Black; 
    228          pisteNaytto.Color = Color.White; 
    229  
     239         pisteNaytto.TextColor = Color.Red; 
     240          
    230241         pisteNaytto.BindTo(pisteLaskuri); 
    231242         Add(pisteNaytto); 
    232243     } 
     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 
    233392 
    234393} 
  • 2015/30/EmilL/KariO/KariO/KariO/KariO.csproj.Debug.cachefile

    r6940 r6989  
    1010Content\Kivi.xnb 
    1111Content\Taustakuva.xnb 
     12Content\KenttÀ3.xnb 
     13Content\Windows.xnb 
     14Content\BigMac.xnb 
     15Content\KenttÀ4.xnb 
     16Content\Haamu.xnb 
     17Content\RÀjÀhdys.xnb 
     18Content\Explosion31.xnb 
    1219Content\tausta biisi.wma 
  • 2015/30/EmilL/KariO/KariO/KariO/obj/x86/Debug/KariO.csproj.FileListAbsolute.txt

    r6940 r6989  
    1919C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kivi.xnb 
    2020C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Taustakuva.xnb 
     21C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\KenttÀ3.xnb 
     22C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Windows.xnb 
     23C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\BigMac.xnb 
     24C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\KenttÀ4.xnb 
     25C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Haamu.xnb 
     26C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\RÀjÀhdys.xnb 
     27C:\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  
    1111Content\Kivi.xnb 
    1212Content\Taustakuva.xnb 
     13Content\KenttÀ3.xnb 
     14Content\Windows.xnb 
     15Content\BigMac.xnb 
     16Content\KenttÀ4.xnb 
     17Content\Haamu.xnb 
     18Content\RÀjÀhdys.xnb 
     19Content\Explosion31.xnb 
  • 2015/30/EmilL/KariO/KariO/KariOContent/KariOContent.contentproj

    r6940 r6989  
    122122    </Compile> 
    123123  </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> 
    124173  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    125174  <!--  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  
    3737      <Options>None</Options> 
    3838      <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Piikki.xnb</Output> 
    39       <Time>2015-07-21T14:49:06.9585739+03:00</Time> 
     39      <Time>2015-07-23T09:45:44.7611448+03:00</Time> 
    4040    </Item> 
    4141    <Item> 
     
    7373      <Options>None</Options> 
    7474      <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kenttä1.xnb</Output> 
    75       <Time>2015-07-22T14:44:33.5485592+03:00</Time> 
     75      <Time>2015-07-23T10:16:12.0443448+03:00</Time> 
    7676    </Item> 
    7777    <Item> 
     
    8282      <Options>None</Options> 
    8383      <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Kenttä2.xnb</Output> 
    84       <Time>2015-07-22T13:53:41.0909525+03:00</Time> 
     84      <Time>2015-07-23T10:32:46.0765448+03:00</Time> 
    8585    </Item> 
    8686    <Item> 
     
    101101      <Output>C:\MyTemp\EmilL\KariO\KariO\KariO\bin\x86\Debug\Content\Taustakuva.xnb</Output> 
    102102      <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> 
    103166    </Item> 
    104167    <BuildSuccessful>true</BuildSuccessful> 
Note: See TracChangeset for help on using the changeset viewer.