Changeset 2403 for 2011/26


Ignore:
Timestamp:
2011-07-01 11:43:56 (12 years ago)
Author:
jahebahu
Message:

Talletus.

Location:
2011/26/HenriH
Files:
2 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2011/26/HenriH/Alien Empire/Alien Empire/Alien Empire/Peli.cs

    r2369 r2403  
    2121    Image plasma_ammus1 = LoadImage("plasma"); 
    2222    Image plasma_ammus2 = LoadImage("plasma2"); 
     23 
    2324    AssaultRifle Plasma1; 
    2425    AssaultRifle Plasma2; 
     
    2829        // TODO: Kirjoita ohjelmakoodisi tähän 
    2930        Valikko(); 
    30         
     31        IsFullScreen = true; 
     32        Camera.ZoomToLevel(); 
     33        Level.Background.FitToLevel(); 
     34 
    3135    } 
    3236 
     
    3943        Level.Background.Image = taustakuva; 
    4044        Level.Background.FitToLevel(); 
    41         Camera.ZoomToLevel(); 
    42  
     45        Camera.StayInLevel = true; 
    4346        Label kohta1 = new Label("Aloita uusi peli"); 
    4447        kohta1.Position = new Vector(0, -80); 
     
    8285        ClearAll(); 
    8386        // Tähän tulee kaikki kentän luomiset ym. alustukset... 
    84         
     87 
    8588        Camera.ZoomToLevel(); 
     89        Level.Background.FitToLevel(); 
    8690        Level.Background.Image = taustakuva2; 
    87         Level.Background.FitToLevel(); 
    88         Level.CreateBorders(); 
     91        Level.CreateBorders(0.5, false); 
    8992        alus1 = new PhysicsObject(50.0, 50.0); 
    9093        alus1.Tag = "Alus1"; 
    91          
     94        MediaPlayer.Play("5am-tausta"); 
     95 
    9296        alus1.X = 300; 
    9397        alus1.Y = 150; 
    94         
     98 
    9599        alus1.Image = olionkuva; 
    96          
     100 
    97101        alus1.AngularDamping = 0.50; 
    98          
     102 
    99103        alus1.Restitution = 0.2; 
    100          
     104 
    101105        alus1.CollisionIgnoreGroup = 1; 
    102          
     106        laskuri3(); 
     107        laskuri4(); 
    103108        LuoLaskuri(); 
    104109        LuoLaskuri1(); 
     
    113118        Plasma2.ProjectileCollision = AmmusOsui2; 
    114119        rajahdys = new ExplosionSystem(LoadImage("special"), 150); 
    115     Add(rajahdys); 
    116  
    117          
     120        Add(rajahdys); 
     121 
     122 
    118123 
    119124        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Valikko, "Palaa valikkoon"); 
     
    126131        Keyboard.Listen(Key.W, ButtonState.Released, ajaalus2, null, alus2); 
    127132        Keyboard.Listen(Key.D, ButtonState.Down, kaannaalus4, "Käännä alusta Oikealle.", alus2); 
    128         Keyboard.Listen(Key.RightShift, ButtonState.Down, AmmuAseella, "Ammu pelaajan 1 asetta", Plasma1, alus1); 
    129         Keyboard.Listen(Key.LeftShift, ButtonState.Down, AmmuAseella2, "Ammu Pelaajan 2 asetta", Plasma2, alus2); 
    130  
    131  
    132          
     133        Keyboard.Listen(Key.RightControl, ButtonState.Down, AmmuAseella, "Ammu pelaajan 1 asetta", Plasma1, alus1); 
     134        Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella2, "Ammu Pelaajan 2 asetta", Plasma2, alus2); 
     135 
     136 
     137 
    133138    } 
    134139    void kiihdytaalus(PhysicsObject alus) 
     
    146151    { 
    147152        alus.Angle += Angle.FromDegrees(5); 
    148       
     153 
    149154    } 
    150155    void kaannaalus2(PhysicsObject alus) 
     
    157162    } 
    158163 
    159         void kaannaalus4(PhysicsObject alus2) 
     164    void kaannaalus4(PhysicsObject alus2) 
    160165    { 
    161166        alus2.Angle -= Angle.FromDegrees(5); 
     
    175180        PhysicsObject ammus = Plasma1.Shoot(); 
    176181 
    177          
     182 
    178183 
    179184        if (ammus != null) 
     
    187192    } 
    188193 
     194 
     195 
    189196    void AmmusOsui(PhysicsObject Ammus, PhysicsObject kohde) 
    190197    { 
    191198        if (kohde.Tag.ToString() == "Alus2") 
    192199        { 
    193           rajahdys.AddEffect(Ammus.Position, 20); 
    194           elamalaskuri2.Value -= 10; 
    195         } 
    196  
    197         if (elamalaskuri2.Value<=0) 
     200            rajahdys.AddEffect(Ammus.Position, 20); 
     201            elamalaskuri1.Value -= 10; 
     202        } 
     203 
     204        if (elamalaskuri1.Value <= 0) 
    198205        { 
    199206 
    200207            Remove(alus2); 
    201             elamalaskuri2.Value = 100; 
    202             //LuoAlus2(); 
     208            elamalaskuri1.Value = 100; 
     209            //Add(alus2); 
    203210            Timer.SingleShot(3.0, ajastinlaukesi); 
    204             kuolemalaskuri.Value -= 1; 
     211            kuolemalaskuri1.Value -= 1; 
     212            if (kuolemalaskuri1.Value <= 0) 
     213            { 
     214                Lopputeksti1(); 
     215            } 
    205216        } 
    206217 
     
    229240        { 
    230241            rajahdys.AddEffect(Ammus.Position, 20); 
    231             elamalaskuri1.Value -= 10; 
    232         } 
    233  
    234         if (elamalaskuri1.Value <= 0) 
     242            elamalaskuri2.Value -= 10; 
     243        } 
     244 
     245        if (elamalaskuri2.Value <= 0) 
    235246        { 
    236247 
    237248            Remove(alus1); 
    238             elamalaskuri1.Value = 100; 
     249            elamalaskuri2.Value = 100; 
     250            //Add(alus2); 
    239251            Timer.SingleShot(3.0, ajastinlaukesi2); 
     252            kuolemalaskuri2.Value -= 1; 
     253            if (kuolemalaskuri2.Value <= 0) 
     254            { 
     255                Lopputeksti2(); 
     256            } 
    240257        } 
    241258 
    242259        Ammus.Destroy(); 
    243260    } 
    244      
    245      
     261 
     262 
    246263    IntMeter elamalaskuri2; 
    247264 
     
    255272        pisteNaytto.TextColor = Color.White; 
    256273 
    257         
     274 
    258275        pisteNaytto.BindTo(elamalaskuri2); 
    259276        Add(pisteNaytto); 
     
    262279    { 
    263280        alus2 = new PhysicsObject(50.0, 50.0); 
    264         alus2.Tag = "Alus2";  
     281        alus2.Tag = "Alus2"; 
    265282        alus2.X = 150; 
    266283        alus2.Y = 300; 
     
    307324        Add(alus1); 
    308325    } 
    309  
    310     IntMeter kuolemalaskuri; 
     326    IntMeter kuolemalaskuri1; 
    311327 
    312328    void laskuri3() 
    313329    { 
    314         kuolemalaskuri = new IntMeter(5); 
     330        kuolemalaskuri1 = new IntMeter(5); 
    315331 
    316332        Label pisteNaytto = new Label(); 
     
    318334        pisteNaytto.Y = Screen.Top - 100; 
    319335        pisteNaytto.TextColor = Color.White; 
    320  
    321         pisteNaytto.BindTo(kuolemalaskuri); 
     336        pisteNaytto.BindTo(kuolemalaskuri1); 
    322337        Add(pisteNaytto); 
    323  
    324         if (kuolemalaskuri.Value <= 0) 
    325         { 
    326             Lopputeksti1(); 
    327         }} 
    328         void Lopputeksti1() 
    329             { 
    330                 Level.Background.Image = taustakuva; 
    331                 Label tekstikentta = new Label(50.0, 20.0, "Pelaaja 1, sinä voitit! Pelaaja 2, hävisit, olet surkea."); 
     338    } 
     339    IntMeter kuolemalaskuri2; 
     340 
     341    void laskuri4() 
     342    { 
     343        kuolemalaskuri2 = new IntMeter(5); 
     344 
     345        Label pisteNaytto = new Label(); 
     346        pisteNaytto.X = Screen.Right - 50; 
     347        pisteNaytto.Y = Screen.Top - 100; 
     348        pisteNaytto.TextColor = Color.White; 
     349        pisteNaytto.BindTo(kuolemalaskuri2); 
     350        Add(pisteNaytto); 
     351 
     352 
     353 
     354    } 
     355    void Lopputeksti1() 
     356    { 
     357        ClearAll(); 
     358 
     359        IsFullScreen = true; 
     360        Level.Background.Image = taustakuva; 
     361        Level.Background.FitToLevel(); 
     362        Camera.StayInLevel = true; 
     363        Camera.ZoomToLevel(); 
     364        Label tekstikentta = new Label("Pelaaja 1, sinä voitit! Pelaaja 2, hävisit, olet surkea."); 
     365        tekstikentta.Color = Color.Transparent; 
     366        tekstikentta.TextColor = Color.White; 
     367        tekstikentta.BorderColor = Color.Transparent; 
     368        tekstikentta.Font = Font.DefaultLargeBold; 
     369 
     370        Label kohta1 = new Label("Aloita uusi peli"); 
     371        kohta1.Position = new Vector(0, -80); 
     372        Add(kohta1); 
     373 
     374        Label kohta2 = new Label("Lopeta"); 
     375        kohta2.Position = new Vector(0, -160); 
     376        Add(kohta2); 
     377 
     378        Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 
     379        Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
     380 
     381        if (Mouse.IsCursorOn(kohta1)) 
     382        { 
     383            kohta1.TextColor = Color.Red; 
     384        } 
     385        else 
     386        { 
     387            kohta1.TextColor = Color.White; 
     388            kohta1.Font = Font.DefaultLargeBold; 
     389 
     390            if (Mouse.IsCursorOn(kohta2)) 
     391            { 
     392                kohta2.TextColor = Color.Red; 
     393            } 
     394            else 
     395            { 
     396                kohta2.TextColor = Color.White; 
     397                kohta2.Font = Font.DefaultLargeBold; 
    332398                Add(tekstikentta); 
    333399            } 
    334         } 
     400 
     401        } 
     402    } 
     403 
     404    void Lopputeksti2() 
     405    { 
     406        ClearAll(); 
     407 
     408 
     409         
     410        Level.Background.Image = taustakuva; 
     411        Camera.ZoomToLevel(); 
     412        Camera.StayInLevel = true; 
     413        Label tekstikentta = new Label("Pelaaja 2, sinä voitit! Pelaaja 1, hävisit, olet surkea."); 
     414        tekstikentta.Color = Color.Transparent; 
     415        tekstikentta.TextColor = Color.White; 
     416        tekstikentta.BorderColor = Color.Transparent; 
     417        tekstikentta.Font = Font.DefaultLargeBold; 
     418 
     419        Label kohta1 = new Label("Aloita uusi peli"); 
     420        kohta1.Position = new Vector(0, -80); 
     421        Add(kohta1); 
     422 
     423        Label kohta2 = new Label("Lopeta"); 
     424        kohta2.Position = new Vector(0, -160); 
     425        Add(kohta2); 
     426 
     427        Mouse.ListenOn(kohta1, MouseButton.Left, ButtonState.Pressed, AloitaPeli, null); 
     428        Mouse.ListenOn(kohta2, MouseButton.Left, ButtonState.Pressed, Exit, null); 
     429 
     430 
     431        if (Mouse.IsCursorOn(kohta1)) 
     432        { 
     433            kohta1.TextColor = Color.Red; 
     434        } 
     435        else 
     436        { 
     437            kohta1.TextColor = Color.White; 
     438            kohta1.Font = Font.DefaultLargeBold; 
     439 
     440            if (Mouse.IsCursorOn(kohta2)) 
     441            { 
     442                kohta2.TextColor = Color.Red; 
     443            } 
     444            else 
     445            { 
     446                kohta2.TextColor = Color.White; 
     447                kohta2.Font = Font.DefaultLargeBold; 
     448                Add(tekstikentta); 
     449 
     450            } 
     451        } 
     452    } 
     453} 
     454 
     455             
     456         
     457         
    335458     
  • 2011/26/HenriH/Alien Empire/Alien Empire/Alien EmpireContent/Alien EmpireContent.contentproj

    r2302 r2403  
    195195    </Compile> 
    196196  </ItemGroup> 
     197  <ItemGroup> 
     198    <Compile Include="5am-tausta.mp3"> 
     199      <Name>5am-tausta</Name> 
     200      <Importer>Mp3Importer</Importer> 
     201      <Processor>SongProcessor</Processor> 
     202    </Compile> 
     203  </ItemGroup> 
    197204  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    198205  <!--  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.