Changeset 1237 for 2010


Ignore:
Timestamp:
2010-07-09 13:07:37 (13 years ago)
Author:
jomiilri
Message:
 
Location:
2010/27/jomiilri/Duel
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2010/27/jomiilri/Duel/Content/Content.contentproj

    r1196 r1237  
    7474    </Compile> 
    7575  </ItemGroup> 
     76  <ItemGroup> 
     77    <Compile Include="Go on %28You can%29.mp3"> 
     78      <Name>Go on %28You can%29</Name> 
     79      <Importer>Mp3Importer</Importer> 
     80      <Processor>SongProcessor</Processor> 
     81    </Compile> 
     82  </ItemGroup> 
     83  <ItemGroup> 
     84    <Compile Include="scream_hyva.wav"> 
     85      <Name>scream_hyva</Name> 
     86      <Importer>WavImporter</Importer> 
     87      <Processor>SoundEffectProcessor</Processor> 
     88    </Compile> 
     89  </ItemGroup> 
     90  <ItemGroup> 
     91    <Compile Include="rifle_single_shot1.wav"> 
     92      <Name>rifle_single_shot1</Name> 
     93      <Importer>WavImporter</Importer> 
     94      <Processor>SoundEffectProcessor</Processor> 
     95    </Compile> 
     96  </ItemGroup> 
    7697</Project> 
  • 2010/27/jomiilri/Duel/Peli.cs

    r1196 r1237  
    2121    const int ruudunKorkeus = 32; 
    2222 
     23    SoundEffect ampumaAani; 
     24     
     25 
    2326    protected override void Begin() 
    2427    { 
     28        MediaPlayer.Play("Go on (You can)"); 
     29        ampumaAani = LoadSoundEffect("rifle_single_shot1");     
     30 
    2531        konekivaari1 = new AssaultRifle(20, 5); 
    2632        konekivaari2 = new AssaultRifle(20, 5); 
     
    3844        LuoAmmusLaskuri1(); 
    3945        LuoAmmusLaskuri2(); 
    40  
     46        LuoAmmusLaatikkoAjastin(); 
     47 
     48        Camera.ZoomToLevel(); 
    4149 
    4250        AloitaPeli(); 
    4351 
    44         IsFullScreen = true; 
     52        SetWindowSize(1024, 768, false); 
    4553 
    4654        p1 = LuoHahmo1(); 
    4755        p1.LinearDamping = 0.95; 
    4856        p1.Restitution = 0.05; 
    49         p1.X = Screen.Left + 975; 
    50         p1.Y = Screen.Top - 760; 
     57        p1.X = Level.Right - 115; 
     58        p1.Y = Level.Top - 600; 
    5159        Add(p1); 
    5260 
     
    5462        p2.LinearDamping = 0.95; 
    5563        p2.Restitution = 0.05; 
    56         p2.X = Screen.Left + 305; 
    57         p2.Y = Screen.Top - 260; 
     64        p2.X = Level.Left + 115; 
     65        p2.Y = Level.Top - 105; 
    5866        Add(p2); 
    5967 
     
    6573        GameObject alareuna = Level.CreateBottomBorder(); 
    6674        GameObject ylareuna = Level.CreateTopBorder(); 
     75        GameObject vasenreuna = Level.CreateLeftBorder(); 
     76        GameObject oikeareuna = Level.CreateRightBorder(); 
    6777        alareuna.Image = LoadImage("tausta1"); 
    6878        ylareuna.Image = LoadImage("tausta1"); 
     79        vasenreuna.Image = LoadImage("tausta1"); 
     80        oikeareuna.Image = LoadImage("tausta1"); 
    6981 
    7082        Level.Background.Image = LoadImage("taustakuva1"); 
    7183        Level.Background.FitToLevel(); 
    72  
    73         Camera.ZoomToLevel(); 
    7484    } 
    7585 
     
    125135    void LuoOhjaimet() 
    126136    { 
     137        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, null); 
     138        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, null); 
     139 
     140 
    127141        Keyboard.Listen(Key.Left, ButtonState.Down, KaannaPelaajaa, null, 3, p1); 
    128142        Keyboard.Listen(Key.Right, ButtonState.Down, KaannaPelaajaa, null, -3, p1); 
     
    137151        ControllerOne.Listen(Button.DPadUp, ButtonState.Released, PysaytaPelaaja, null, p1); 
    138152        ControllerOne.Listen(Button.DPadDown, ButtonState.Down, LiikutaPelaajaaTaakse, null, p1); 
    139         ControllerOne.Listen(Button.A, ButtonState.Down, Ammu, "Ammu", p1, konekivaari1); 
     153        ControllerOne.Listen(Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", p1, konekivaari1); 
    140154 
    141155        Keyboard.Listen(Key.A, ButtonState.Down, KaannaPelaajaa, null, 3, p2); 
     
    144158        Keyboard.Listen(Key.W, ButtonState.Released, PysaytaPelaaja, null, p2); 
    145159        Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaajaaTaakse, null, p2); 
    146         Keyboard.Listen(Key.F, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2); 
     160        Keyboard.Listen(Key.LeftControl, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2); 
    147161 
    148162        ControllerTwo.Listen(Button.DPadLeft, ButtonState.Down, KaannaPelaajaa, null, 3, p2); 
     
    151165        ControllerTwo.Listen(Button.DPadUp, ButtonState.Released, PysaytaPelaaja, null, p2); 
    152166        ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, LiikutaPelaajaaTaakse, null, p2); 
    153         ControllerTwo.Listen(Button.A, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2); 
     167        ControllerTwo.Listen(Button.RightTrigger, ButtonState.Down, Ammu, "Ammu", p2, konekivaari2); 
    154168    } 
    155169 
     
    157171    { 
    158172        PhysicsObject ammus = ase.Shoot(); 
    159         if (ammus != null) ammus.Tag = ampuja; 
     173        if (ammus != null) 
     174        { 
     175            ammus.Tag = ampuja; 
     176        } 
     177        //MediaPlayer.Play("rifle_single_shot");         
     178        ampumaAani.Play(); 
    160179    } 
    161180 
     
    178197                elamaLaskuri1.Value = elamaLaskuri1.Value - 4; 
    179198            } 
    180                 if (seina.Tag.ToString() == "p1") 
    181                 { 
     199            if (seina.Tag.ToString() == "p1") 
     200            { 
    182201                elamaLaskuri2.Value = elamaLaskuri2.Value - 4; 
    183                 } 
    184         luoti.Destroy(); 
     202            } 
     203            luoti.Destroy(); 
     204 
     205            if (elamaLaskuri1.Value <= 0) 
     206            { 
     207                PelaajaKuolee(1); 
     208            } 
     209 
     210            if (elamaLaskuri2.Value <= 0) 
     211            { 
     212                PelaajaKuolee(2); 
     213            } 
    185214        } 
    186215 
     
    192221 
    193222        Label elamaNaytto1 = new Label(); 
    194         elamaNaytto1.X = Screen.Left + 100; 
    195         elamaNaytto1.Y = Screen.Top - 980; 
     223        elamaNaytto1.X = Level.Left + 100; 
     224        elamaNaytto1.Y = Level.Bottom - 5; 
    196225        elamaNaytto1.TextColor = Color.Red; 
    197226 
     
    205234 
    206235        Label elamaNaytto2 = new Label(); 
    207         elamaNaytto2.X = Screen.Right - 100; 
    208         elamaNaytto2.Y = Screen.Top - 980; 
     236        elamaNaytto2.X = Level.Right - 100; 
     237        elamaNaytto2.Y = Level.Bottom - 5; 
    209238        elamaNaytto2.TextColor = Color.Red; 
    210239 
     
    216245    { 
    217246        Label ammusNaytto1 = new Label(); 
    218         ammusNaytto1.X = Screen.Left + 200; 
    219         ammusNaytto1.Y = Screen.Top - 980; 
     247        ammusNaytto1.X = Level.Left + 200; 
     248        ammusNaytto1.Y = Level.Bottom - 5; 
    220249        ammusNaytto1.TextColor = Color.Black; 
    221250 
     
    227256    { 
    228257        Label ammusNaytto2 = new Label(); 
    229         ammusNaytto2.X = Screen.Right - 200; 
    230         ammusNaytto2.Y = Screen.Top - 980; 
     258        ammusNaytto2.X = Level.Right - 200; 
     259        ammusNaytto2.Y = Level.Bottom - 5; 
    231260        ammusNaytto2.TextColor = Color.Black; 
    232261 
     
    239268        PhysicsObject ammusLaatikko = new PhysicsObject(18, 12); 
    240269        ammusLaatikko.Image = LoadImage("ammuslaatikko1"); 
    241         Add(ammusLaatikko); 
    242         AddCollisionHandler(ammusLaatikko, LisaaAmmuksia);        
     270        //Add(ammusLaatikko); 
     271        AddCollisionHandler(ammusLaatikko, LisaaAmmuksia); 
     272        ammusLaatikko.IgnoresCollisionResponse = true; 
    243273        return ammusLaatikko; 
    244274    } 
    245275 
    246     void LisaaAmmuksia(PhysicsObject ammusLaatikko, PhysicsObject pelaaja) 
    247     { 
    248         if (konekivaari1.Ammo.Value == 250) return; 
    249         else 
     276    void LisaaAmmuksia(PhysicsObject ammusLaatikko, PhysicsObject kohde) 
     277    { 
     278        if (kohde == p1 && konekivaari1.Ammo.Value < 250) 
    250279        { 
    251280            konekivaari1.Ammo.Value += 50; 
    252281            ammusLaatikko.Destroy(); 
    253282        } 
    254          
    255     } 
    256  
    257     void LuoAmmusLaatikkoAjastint() 
     283        if (kohde == p2 && konekivaari2.Ammo.Value < 250) 
     284        { 
     285            konekivaari2.Ammo.Value += 50; 
     286            ammusLaatikko.Destroy(); 
     287        } 
     288    } 
     289 
     290    void LuoAmmusLaatikkoAjastin() 
    258291    { 
    259292        ammusAjastin = new Timer(); 
    260         ammusAjastin.Interval = 40; 
     293        ammusAjastin.Interval = 10; 
    261294        ammusAjastin.Trigger += LisaaAmmusLaatikoita; 
    262295        Add(ammusAjastin); 
     
    268301    { 
    269302        PhysicsObject laatikko = LuoAmmusLaatikko(); 
    270         laatikko.X = RandomGen.NextDouble(Screen.Left + 100, Screen.Left - 900); 
    271         laatikko.Y = RandomGen.NextDouble(Screen.Top + 100, Screen.Top - 900); 
     303        laatikko.X = RandomGen.NextDouble(Level.Left + 50, Level.Right - 50); 
     304        laatikko.Y = RandomGen.NextDouble(Level.Top - 50, Level.Bottom + 50); 
     305        Add(laatikko); 
     306    } 
     307 
     308    void PelaajaKuolee(int kumpiPelaaja) 
     309    { 
     310        if (kumpiPelaaja == 1) 
     311        { 
     312            PlaySound("scream_hyva"); 
     313            Timer kuolemaAj = KuolemaAjastin(); 
     314            kuolemaAj.Trigger += SiirraPelaaja1Alkuun; 
     315            //p2.Destroy(); 
     316            p1.IsVisible = false; 
     317            NollaaLaskurit(); 
     318        } 
     319        else 
     320        { 
     321            PlaySound("scream_hyva"); 
     322            Remove(p1); 
     323        } 
     324 
     325        NollaaLaskurit(); 
     326    } 
     327 
     328    void SiirraPelaaja1Alkuun(Timer sender) 
     329    { 
     330        p1.IsVisible = true; 
     331        p1.X = Level.Left + 115; 
     332        p1.Y = Level.Top - 105; 
     333        sender.Stop(); 
     334 
     335    } 
     336 
     337    void SiirraPelaaja2Alkuun(Timer sender) 
     338    { 
     339        p2.IsVisible = true; 
     340        p2.X = Level.Left + 115; 
     341        p2.Y = Level.Top - 105; 
     342        //Add(p2); 
     343    } 
     344 
     345    void NollaaLaskurit() 
     346    { 
     347        elamaLaskuri1.Value = 100; 
     348        elamaLaskuri2.Value = 100; 
     349        // Aseitten Ammo myös täyteen... 
     350 
     351    } 
     352 
     353    Timer KuolemaAjastin() 
     354    { 
     355        Timer kuolemaAjastin = new Timer(); 
     356        kuolemaAjastin.Interval = 3; 
     357        //kuolemaAjastin.Trigger += SiirraPelaajaAlkuun; 
     358        Add(kuolemaAjastin); 
     359        kuolemaAjastin.Start(); 
     360        return kuolemaAjastin; 
    272361    } 
    273362} 
  • 2010/27/jomiilri/Duel/TextFile1.txt

    r1196 r1237  
    11IIIIIIIIIIIIIIIIIIIIIIIIIIII 
    22IIIIIIIIIIIIIIIIIIIIIIIIIIII 
    3 II R I                    II 
    4 II   I                    II 
     3II   I                I   II 
     4II   I                I   II 
     5II   IIIIIII     IIIIII   II 
     6II         I     I        II 
     7II         I     I        II 
     8II        I       I       II 
     9II    IIII         IIII   II 
     10II       I         I      II 
    511II                        II 
    612II                        II 
    7 II                        II 
    8 II                        II 
    9 II                        II 
    10 II                        II 
    11 II                        II 
    12 II                        II 
    13 II                        II 
    14 II                        II 
    15 II                        II 
    16 II                        II 
    17 II                        II 
    18 II                        II 
    19 II                    I   II 
    20 II               **   I P II 
     13II       I         I      II 
     14II    IIII         IIII   II 
     15II        I       I       II 
     16II         I     I        II 
     17II         I     I        II 
     18II   IIIIIII     IIIIII   II 
     19II   I                I   II 
     20II   I                I   II 
    2121IIIIIIIIIIIIIIIIIIIIIIIIIIII 
    2222IIIIIIIIIIIIIIIIIIIIIIIIIIII 
Note: See TracChangeset for help on using the changeset viewer.