Changeset 2097 for 2011/24


Ignore:
Timestamp:
2011-06-17 12:23:29 (12 years ago)
Author:
paaaanro
Message:
 
Location:
2011/24/PauliN
Files:
5 added
8 edited

Legend:

Unmodified
Added
Removed
  • 2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli.csproj

    r2048 r2097  
    121121    <Content Include="ground.png" /> 
    122122    <Content Include="imagesCA9N94Z4.jpg" /> 
     123    <Content Include="pelaaja1.png" /> 
    123124    <Content Include="pelaaja1oik.png" /> 
    124125    <Content Include="pelaaja2.png" /> 
  • 2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/Jalkapallopeli/Peli.cs

    r2048 r2097  
    1515    Image pelaaja2vasKuva = LoadImage("pelaaja2vas"); 
    1616    Image tausta = LoadImage("tausta"); 
     17    Image maali1Kuva = LoadImage("maali1"); 
     18    Image maali2Kuva = LoadImage("maali2"); 
    1719 
    1820    PhysicsObject pallo; 
     
    2224    PhysicsObject pelaaja1; 
    2325    PhysicsObject pelaaja2; 
     26    PhysicsObject raja1; 
     27    PhysicsObject raja2; 
     28 
     29     
    2430 
    2531    IntMeter Pelaajan1Pisteet; 
     
    2733 
    2834     
    29  
    3035    Vector NopeusVasemmalle = new Vector(-150, 0); 
    3136    Vector NopeusOikealle = new Vector(150, 0); 
    32     Vector HyppyVoima = new Vector(0, 400); 
     37    Vector HyppyVoima = new Vector(0, 400);     
    3338        
    3439    public override void Begin() 
     
    4348    void LuoKentta() 
    4449    { 
     50        PhysicsObject raja1 = PhysicsObject.CreateStaticObject(10, 1000); 
     51        raja1.X = Level.Left + 50; 
     52        raja1.Y = 0; 
     53        raja1.IsVisible = false; 
     54        Add(raja1); 
     55 
     56        PhysicsObject raja2 = PhysicsObject.CreateStaticObject(10, 1000); 
     57        raja2.X = Level.Right - 50; 
     58        raja2.Y = 0; 
     59        raja2.IsVisible = false; 
     60        Add(raja2); 
     61 
    4562        pallo = new PhysicsObject(45, 45); 
    4663        pallo.Image = pallonKuva; 
    4764        pallo.X = 0; 
    4865        pallo.Y = 300; 
    49         pallo.Mass = 1; 
     66        pallo.Mass = 0.2; 
     67        pallo.Restitution = 1; 
    5068        Add(pallo); 
     69 
     70        
     71 
    5172 
    5273        Level.Background.Image = tausta; 
     
    6182 
    6283         
    63         maali1 = PhysicsObject.CreateStaticObject(20, 120); 
    64         maali1.Shape = Shape.Rectangle; 
     84        maali1 = PhysicsObject.CreateStaticObject(100, 180); 
     85        maali1.Image = maali1Kuva;        
    6586        maali1.X = Level.Left + 20; 
    6687        maali1.Y = Level.Bottom + 75; 
    6788        Add(maali1); 
    6889 
    69         maali2 = PhysicsObject.CreateStaticObject(20, 120); 
    70         maali2.Shape = Shape.Rectangle; 
     90        maali2 = PhysicsObject.CreateStaticObject(100, 180); 
     91        maali2.Image = maali2Kuva; 
    7192        maali2.X = Level.Right - 20; 
    7293        maali2.Y = Level.Bottom + 75; 
     
    79100 
    80101        Camera.ZoomToLevel(); 
    81         Camera.Follow(pallo);         
     102        //Camera.Follow(pallo);         
    82103 
    83104        pelaaja1 = LuoPelaaja(Level.Left + 200, 0); 
     
    96117    void AloitaPeli() 
    97118    { 
    98         Gravity = new Vector(0.0, -400); 
     119        Gravity = new Vector(0.0, -600); 
    99120    } 
    100121 
     
    153174 
    154175        Keyboard.Listen(Key.Up, ButtonState.Pressed, AsetaHyppy, "Pelaaja2: Hyppaa", pelaaja2, HyppyVoima); 
    155          
    156  
    157  
    158  
    159  
    160  
     176 
     177        Keyboard.Listen(Key.LeftControl, ButtonState.Released, Potkaise, "Pelaaja1: Potkaise", pelaaja1); 
     178        Keyboard.Listen(Key.RightControl, ButtonState.Released, Potkaise, "Pelaaja2: Potkaise", pelaaja2); 
     179         
    161180 
    162181    } 
     
    164183    void AsetaNopeus(PhysicsObject pelaaja, Vector nopeus) 
    165184    {                
    166         pelaaja.Velocity = nopeus; 
     185        pelaaja.Velocity = nopeus + new Vector(0, pelaaja.Velocity.Y); 
    167186        if (nopeus.X > 0) 
    168187        { 
     
    188207    void AsetaHyppy(PhysicsObject pelaaja, Vector voima) 
    189208    { 
    190         pelaaja.Hit (voima); 
     209         
     210 
     211        if (pelaaja.Y < -350) 
     212        { 
     213            pelaaja.Hit (voima); 
     214        } 
    191215 
    192216    } 
     
    201225            pelaaja1.X = -200; 
    202226            pelaaja2.X = 200; 
     227            pallo.Stop(); 
    203228        } 
    204229        else if (kohde == maali1) 
     
    209234            pelaaja2.X = 200; 
    210235            Pelaajan2Pisteet.Value += 1; 
    211         } 
    212  
    213          
     236            pallo.Stop(); 
     237        } 
     238 
     239         
     240         
     241 
     242    } 
     243    void Potkaise(PhysicsObject pelaaja) 
     244    { 
     245 
     246          
     247        Vector suunta = (pallo.Position - pelaaja.Position); 
     248        if (suunta.Magnitude < 60) 
     249        { 
     250            Vector potku = suunta + new Vector(0, 80); 
     251            if ((pelaaja.Image == pelaaja1oikKuva) || (pelaaja.Image == pelaaja2Kuva)) 
     252            { 
     253                if (pelaaja.X < pallo.X) 
     254                {  
     255                    pallo.Hit(potku * 0.8); 
     256                } 
     257            } 
     258            else 
     259            { 
     260                if (pelaaja.X > pallo.X) 
     261                { 
     262                    pallo.Hit(potku * 0.8); 
     263                } 
     264            } 
     265 
     266             
     267        }    
     268      
    214269 
    215270 
  • 2011/24/PauliN/Jalkapallopeli/Jalkapallopeli/JalkapallopeliContent/JalkapallopeliContent.contentproj

    r2048 r2097  
    5757  </ItemGroup> 
    5858  <ItemGroup> 
    59     <Compile Include="pelaaja1.png"> 
    60       <Name>pelaaja1</Name> 
    61       <Importer>TextureImporter</Importer> 
    62       <Processor>TextureProcessor</Processor> 
    63     </Compile> 
    64   </ItemGroup> 
    65   <ItemGroup> 
    66     <Compile Include="pelaaja1oik.png"> 
    67       <Name>pelaaja1oik</Name> 
    68       <Importer>TextureImporter</Importer> 
    69       <Processor>TextureProcessor</Processor> 
    70     </Compile> 
    71   </ItemGroup> 
    72   <ItemGroup> 
    7359    <Compile Include="pelaaja2.png"> 
    7460      <Name>pelaaja2</Name> 
     
    9177    </Compile> 
    9278  </ItemGroup> 
     79  <ItemGroup> 
     80    <Compile Include="pelaaja1.png"> 
     81      <Name>pelaaja1</Name> 
     82      <Importer>TextureImporter</Importer> 
     83      <Processor>TextureProcessor</Processor> 
     84    </Compile> 
     85  </ItemGroup> 
     86  <ItemGroup> 
     87    <Compile Include="pelaaja1oik.png"> 
     88      <Name>pelaaja1oik</Name> 
     89      <Importer>TextureImporter</Importer> 
     90      <Processor>TextureProcessor</Processor> 
     91    </Compile> 
     92  </ItemGroup> 
     93  <ItemGroup> 
     94    <Compile Include="maali1.png"> 
     95      <Name>maali1</Name> 
     96      <Importer>TextureImporter</Importer> 
     97      <Processor>TextureProcessor</Processor> 
     98    </Compile> 
     99  </ItemGroup> 
     100  <ItemGroup> 
     101    <Compile Include="maali2.png"> 
     102      <Name>maali2</Name> 
     103      <Importer>TextureImporter</Importer> 
     104      <Processor>TextureProcessor</Processor> 
     105    </Compile> 
     106  </ItemGroup> 
    93107  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    94108  <!--  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.