Changeset 7751 for 2016/27/OskariL


Ignore:
Timestamp:
2016-07-05 10:49:44 (3 years ago)
Author:
karkaite
Message:
 
Location:
2016/27/OskariL/Pong
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • 2016/27/OskariL/Pong/Pong/Pong/Pong.cs

    r7717 r7751  
    99public class Pong : PhysicsGame 
    1010{ 
    11     ExplosionSystem rajahtaa = new ExplosionSystem(LoadImage("Pulla"), 200); 
     11    ExplosionSystem rajahtaa = new ExplosionSystem(LoadImage("Pulla"), 400); 
     12    ExplosionSystem numminenRajahtaa = new ExplosionSystem(LoadImage("M_A_Numminen_2011"), 400); 
    1213 
    1314    Vector nopeusYlos = new Vector(0, 650); 
    1415    Vector nopeusAlas = new Vector(0, -650); 
     16    Vector impulssi; 
     17    Vector impulssi2; 
    1518 
    1619    PhysicsObject pallo; 
    1720    PhysicsObject maila1; 
    1821    PhysicsObject maila2; 
     22    PhysicsObject ammus; 
    1923 
    2024    PhysicsObject vasenReuna; 
     
    2630    Boolean hasGameEnded = false; 
    2731    Boolean hasRajahtanyt = false; 
     32    Boolean hasNumminenRajahtanyt = false; 
     33    Boolean isTimerRunning = false; 
    2834 
    2935    DoubleMeter alaspainLaskuri; 
     
    5561 
    5662        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     63        maila1.Tag = "maila"; 
     64        maila1.CollisionIgnoreGroup = 2; 
    5765        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     66        maila2.Tag = "maila"; 
     67        maila2.CollisionIgnoreGroup = 2; 
    5868 
    5969        //luodaan kenttä         
     
    6171        vasenReuna.Restitution = 1.0; 
    6272        vasenReuna.IsVisible = false; 
     73        vasenReuna.CollisionIgnoreGroup = 1; 
     74        vasenReuna.Tag = "seina"; 
    6375        oikeaReuna = Level.CreateRightBorder(); 
    6476        oikeaReuna.Restitution = 1.0; 
    6577        oikeaReuna.IsVisible = false; 
     78        oikeaReuna.CollisionIgnoreGroup = 1; 
     79        oikeaReuna.Tag = "seina"; 
    6680        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
    6781        alaReuna.Restitution = 1.0; 
    6882        alaReuna.IsVisible = false; 
     83        alaReuna.CollisionIgnoreGroup = 1; 
     84        alaReuna.Tag = "seina"; 
    6985        PhysicsObject ylaReuna = Level.CreateTopBorder(); 
    7086        ylaReuna.Restitution = 1.0; 
    7187        ylaReuna.IsVisible = false; 
     88        ylaReuna.CollisionIgnoreGroup = 1; 
     89        ylaReuna.Tag = "seina"; 
    7290 
    7391        Level.Background.Color = Color.Black; 
     
    7896    { 
    7997        //liikutetaan palloa 
    80         Vector impulssi = new Vector(500.0, 0.0); 
     98        impulssi = new Vector(500.0, 0.0); 
    8199        pallo.Hit(impulssi); 
    82  
     100        impulssi2 = new Vector(-500.0, 0.0); 
    83101    } 
    84102    PhysicsObject LuoMaila(double x, double y) 
     
    101119        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    102120 
     121        Keyboard.Listen(Key.X, ButtonState.Down, AmmuPalloa1, "Pelaaja 1: Ammu"); 
     122 
    103123        //pelaajan 2 napit 
    104124        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     
    106126        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
    107127        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     128 
     129        Keyboard.Listen(Key.Left, ButtonState.Down, AmmuPalloa2, "Pelaaja 2: Ammu"); 
    108130 
    109131        //yleiset napit 
     
    164186        { 
    165187            pelaajan2Pisteet.Value += 1; 
    166             Rajahdys(); 
    167             //TODO: tee erillinen räjähdys Putineista 
     188            RajahdysNumminen(); 
    168189        } 
    169190        if (pelaajan1Pisteet == 10) 
     
    177198            MessageDisplay.Add("Pelaaja 2 voittaa"); 
    178199            LuoAikaLaskuri(); 
    179             Rajahdys(); 
    180             //TODO: tee erillinen räjähdys Putineista 
    181  
     200            RajahdysNumminen(); 
    182201        } 
    183202    } 
    184203    void LuoAikaLaskuri() 
    185204    { 
     205        if (isTimerRunning == true) 
     206        { 
     207            return; 
     208        } 
     209 
    186210        alaspainLaskuri = new DoubleMeter(5); 
    187211 
     
    197221        aikaNaytto.BindTo(alaspainLaskuri); 
    198222        Add(aikaNaytto); 
     223        isTimerRunning = true; 
    199224    } 
    200225    void AikaLoppui() 
     
    224249        double x = 0; 
    225250        double y = 0; 
    226         int pMaara = 200; 
     251        int pMaara = 400; 
    227252        rajahtaa.AddEffect(x, y, pMaara); 
    228253    } 
     254    void RajahdysNumminen() 
     255    { 
     256        if (hasNumminenRajahtanyt == false) 
     257        { 
     258            hasNumminenRajahtanyt = true; 
     259            Add(numminenRajahtaa); 
     260        } 
     261        double x = 0; 
     262        double y = 0; 
     263        int pMaara = 400; 
     264        numminenRajahtaa.AddEffect(x, y, pMaara); 
     265 
     266 
     267    } 
     268    void AmmuPalloa1() 
     269    { 
     270        LuoAmmus(maila1.X + 10.0, maila1.Y); 
     271        ammus.Hit(impulssi); 
     272    } 
     273    void AmmuPalloa2() 
     274    { 
     275        LuoAmmus(maila2.X - 10.0, maila2.Y); 
     276        ammus.Hit(impulssi2); 
     277    } 
     278    void LuoAmmus(double x, double y) 
     279    { 
     280        ammus = new PhysicsObject(10.0, 10.0); 
     281        ammus.X = x; 
     282        ammus.Y = y; 
     283        ammus.Shape = Shape.Star; 
     284        Add(ammus); 
     285        AddCollisionHandler(ammus, "seina", CollisionHandler.DestroyObject); 
     286        ammus.CollisionIgnoreGroup = 2; 
     287    } 
    229288} 
  • 2016/27/OskariL/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{BFDFC922-70FE-421D-A674-E0C408BE6EAF}.xml

    r7717 r7751  
    1010      <Output>C:\MyTemp\OskariL\Pong\Pong\Pong\bin\x86\Debug\Content\Pulla.xnb</Output> 
    1111      <Time>2016-07-04T14:24:56.5987405+03:00</Time> 
     12    </Item> 
     13    <Item> 
     14      <Source>M_A_Numminen_2011.jpg</Source> 
     15      <Name>M_A_Numminen_2011</Name> 
     16      <Importer>TextureImporter</Importer> 
     17      <Processor>TextureProcessor</Processor> 
     18      <Options>None</Options> 
     19      <Output>C:\MyTemp\OskariL\Pong\Pong\Pong\bin\x86\Debug\Content\M_A_Numminen_2011.xnb</Output> 
     20      <Time>2016-07-05T10:01:41.3064143+03:00</Time> 
    1221    </Item> 
    1322    <BuildSuccessful>true</BuildSuccessful> 
  • 2016/27/OskariL/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt

    r7717 r7751  
    88C:\MyTemp\OskariL\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 
    99C:\MyTemp\OskariL\Pong\Pong\Pong\bin\x86\Debug\Content\Pulla.xnb 
     10C:\MyTemp\OskariL\Pong\Pong\Pong\bin\x86\Debug\Content\M_A_Numminen_2011.xnb 
  • 2016/27/OskariL/Pong/Pong/PongContent/PongContent.contentproj

    r7717 r7751  
    5252    </Compile> 
    5353  </ItemGroup> 
     54  <ItemGroup> 
     55    <Compile Include="M_A_Numminen_2011.jpg"> 
     56      <Name>M_A_Numminen_2011</Name> 
     57      <Importer>TextureImporter</Importer> 
     58      <Processor>TextureProcessor</Processor> 
     59    </Compile> 
     60  </ItemGroup> 
    5461  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    5562  <!--  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.