Changeset 1993 for 2011


Ignore:
Timestamp:
2011-06-14 14:59:01 (12 years ago)
Author:
lesejuku
Message:
 
Location:
2011/24/LeeviK/Pong/Pong
Files:
8 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2011/24/LeeviK/Pong/Pong/Pong/Peli.cs

    r1969 r1993  
    1313    Vector nopeusYlos = new Vector(0, 200); 
    1414    Vector nopeusAlas = new Vector(0, -200); 
    15     Image taustaKuva = LoadImage("tausta"); 
    1615 
    17  
    18     PhysicsObject pelaaja1; 
    19      
    20  
    21      
    22      
     16    PhysicsObject pelaaja; 
     17    AssaultRifle pelaajanAse; 
     18    AssaultRifle pelaajanAse1; 
     19    AssaultRifle pelaajanAse2; 
     20    Label ammoNaytto; 
     21    Animation animaatio1; 
     22    Animation animaatio2; 
    2323 
    2424    public override void Begin() 
     
    2626        LuoKentta(); 
    2727        AsetaOhjaimet(); 
     28        ammoNaytto = LuoNaytto(Screen.Left + 60, Screen.Top - 60, pelaajanAse.Ammo); 
    2829        AloitaPeli(); 
    2930        Mouse.IsCursorVisible = true; 
    3031        Mouse.ListenMovement(0.1, KuunteleLiiketta, null); 
    31  
     32        Image[] pelaajankuvat = LoadImages("jenkki lataus1", "jenkki lataus2", "jenkki lataus3", "jenkki lataus4", "jenkki lataus3", "jenkki lataus2", "jenkki lataus1", "jenkki lataus5", "jenkki lataus6", "jenkki lataus5"); 
     33        Image[] pelaajankuvat2 = LoadImages("jenkki2"); 
     34        animaatio1 = new Animation(pelaajankuvat); 
     35        animaatio2 = new Animation(pelaajankuvat2); 
     36        pelaaja.Animation = animaatio1; 
     37        pelaaja.Animation.FPS = 10; 
     38        PhysicsObject natsi = new PhysicsObject(40, 40); 
     39        natsi.Shape = Shape.Circle; 
     40        Add(natsi); 
     41        Image natsinKuva = LoadImage("NATSI"); 
     42        natsi.Image = natsinKuva; 
     43        natsi.Width = 155; 
     44        natsi.Height = 120; 
     45        FollowerBrain natsinAivot = new FollowerBrain(); 
     46        natsinAivot.Target = pelaaja; 
     47        natsinAivot.TargetFollowDistance = 100; 
     48        natsinAivot.Speed = 300; 
     49        natsinAivot.TargetClose += mitaTapahtuuKunOllaanLahella; 
     50        natsinAivot.FollowAlways = true; 
     51  
    3252         
    33         //                                                                                                         x, y 
    34         Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaa, "Liikuta pelaajaa vasemmalle", new Vector(-1000, 0)); 
    35         Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaa, null, new Vector(1000, 0)); 
    36         Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 1000)); 
    37         Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -1000)); 
     53                                                                                                 
     54        Keyboard.Listen(Key.A, ButtonState.Down, LiikutaPelaajaa, "Liikuta pelaajaa vasemmalle", new Vector(-1000, 0)); 
     55        Keyboard.Listen(Key.D, ButtonState.Down, LiikutaPelaajaa, null, new Vector(1000, 0)); 
     56        Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, 1000)); 
     57        Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaajaa, null, new Vector(0, -1000)); 
     58        Mouse.Listen(MouseButton.Left, ButtonState.Down, AmmuAseella, "Ammu", pelaaja, pelaajanAse); 
     59        Keyboard.Listen(Key.D1, ButtonState.Down, VaihdaAse, "VaihdaAse", pelaaja, pelaajanAse1); 
     60        Keyboard.Listen(Key.D2, ButtonState.Down, VaihdaAse, "VaihdaAse", pelaaja, pelaajanAse2); 
    3861    } 
    3962 
    4063    void LiikutaPelaajaa(Vector kakkakasa) 
    4164    { 
    42         pelaaja1.Push(kakkakasa); 
    43     }    
    44    
     65        pelaaja.Push(kakkakasa); 
     66    } 
     67 
    4568    void LuoKentta() 
    4669    { 
    47         pelaaja1 = new PhysicsObject(200.0, 200.0); 
    48         pelaaja1.Shape = Shape.Circle; 
    49         pelaaja1.X = -200.0; 
    50         pelaaja1.Y = 0.0; 
    51         pelaaja1.Restitution = 1.0; 
    52         pelaaja1.KineticFriction = 0.0; 
    53         Add(pelaaja1); 
    54         pelaaja1.Image = LoadImage("jenkki"); 
     70        pelaaja = new PhysicsObject(200.0, 200.0); 
     71        pelaaja.Shape = Shape.Circle; 
     72        pelaaja.X = -200.0; 
     73        pelaaja.Y = 0.0; 
     74        pelaaja.Restitution = 0.7; 
     75        pelaaja.AngularDamping = 0.7; 
     76        pelaaja.LinearDamping = 0.9; 
     77        pelaaja.KineticFriction = 0.0; 
     78        Add(pelaaja); 
     79        pelaaja.Image = LoadImage("jenkki"); 
     80        pelaajanAse1 = new AssaultRifle(20, 0); 
     81        pelaajanAse = pelaajanAse1; 
     82        pelaaja.Add(pelaajanAse); 
     83        pelaajanAse.Ammo.Value = 30; 
     84        pelaajanAse.Ammo.MinValue = 0; 
     85        pelaajanAse.Ammo.LowerLimit += LataaAse; 
     86        pelaajanAse.ProjectileCollision = AmmusOsui; 
    5587 
    56         Level.Background.Image = taustaKuva; 
    57         Camera.Follow(pelaaja1); 
     88        pelaajanAse2 = new AssaultRifle(20, 0); 
     89        pelaaja.Add(pelaajanAse2); 
     90        pelaajanAse2.Ammo.Value = 100; 
     91        pelaajanAse2.Ammo.MinValue = 0; 
     92        pelaajanAse2.Ammo.LowerLimit += LataaAse; 
     93        pelaajanAse2.ProjectileCollision = AmmusOsui; 
     94 
     95 
     96        Level.BackgroundColor = Color.Green; 
     97        Level.CreateBorders(); 
     98        Camera.Follow(pelaaja); 
    5899    } 
    59100 
    60      
     101    void LataaAse(int arvo) 
     102    { 
     103        Timer.SingleShot(1, LisaaAmmuksia); 
     104        pelaaja.Animation.Start(); 
    61105 
    62        
     106    } 
    63107 
    64     IntMeter LuoPisteLaskuri(double x, double y) 
     108    void LisaaAmmuksia() 
    65109    { 
    66         IntMeter laskuri = new IntMeter(0); 
    67         laskuri.MaxValue = 10; 
     110        pelaajanAse.Ammo.Value += 30; 
     111        pelaaja.Animation.Stop(); 
     112 
     113    } 
     114 
     115    Label LuoNaytto(double x, double y, IntMeter sidottavaLaskuri) 
     116    { 
    68117        Label naytto = new Label(); 
    69         naytto.BindTo(laskuri); 
     118        naytto.BindTo(sidottavaLaskuri); 
    70119        naytto.X = x; 
    71120        naytto.Y = y; 
     
    74123        naytto.Color = Level.BackgroundColor; 
    75124        Add(naytto); 
    76         return laskuri; 
     125        return naytto; 
    77126    } 
    78      
    79     
    80      
    81127 
    82      
    83128 
    84129    void AloitaPeli() 
    85130    { 
    86          
    87          
     131 
    88132    } 
    89133 
     
    92136        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
    93137        //Keyboard.Listen(Key.Left, ButtonState.Down, 
    94      
    95138    } 
    96139 
     
    98141    void KuunteleLiiketta(AnalogState hiirenTila) 
    99142    { 
    100  
     143        Vector suunta = (pelaaja.Position - Mouse.PositionOnWorld).Normalize(); 
    101144        Mouse.IsCursorVisible = true; 
    102145        Vector hiirenLiike = hiirenTila.MouseMovement; 
    103         pelaaja1.Angle = hiirenLiike.Angle; 
     146        pelaaja.Angle = suunta.Angle + Angle.FromDegrees(180); 
     147 
    104148    } 
    105149 
     150    void AmmuAseella(PhysicsObject pelaaja, Weapon pelaajanAse) 
     151    { 
     152        PhysicsObject ammus = pelaajanAse.Shoot(); 
     153         
     154        if (ammus != null) 
     155        { 
     156            ammus.Size = new Vector(ammus.Width*5, ammus.Height * 2); 
     157        } 
    106158 
     159    } 
    107160 
     161    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
     162    { 
     163        ammus.Destroy(); 
     164        Explosion rajahdys = new Explosion(10); 
     165        rajahdys.Position = ammus.Position; 
     166        Add(rajahdys); 
     167    } 
     168    void mitaTapahtuuKunOllaanLahella(object lahettajaAivot, EventArgs e) 
     169    { 
     170         
     171    } 
     172    void VaihdaAse(PhysicsObject pelaaja, Weapon ase) 
     173    { 
     174        pelaajanAse = (AssaultRifle)ase; 
     175    } 
    108176} 
  • 2011/24/LeeviK/Pong/Pong/PongContent/PongContent.contentproj

    r1969 r1993  
    6363    </Compile> 
    6464  </ItemGroup> 
     65  <ItemGroup> 
     66    <Compile Include="jenkki lataus1.png"> 
     67      <Name>jenkki lataus1</Name> 
     68      <Importer>TextureImporter</Importer> 
     69      <Processor>TextureProcessor</Processor> 
     70    </Compile> 
     71    <Compile Include="jenkki lataus2.png"> 
     72      <Name>jenkki lataus2</Name> 
     73      <Importer>TextureImporter</Importer> 
     74      <Processor>TextureProcessor</Processor> 
     75    </Compile> 
     76    <Compile Include="jenkki lataus3.png"> 
     77      <Name>jenkki lataus3</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81    <Compile Include="jenkki lataus4.png"> 
     82      <Name>jenkki lataus4</Name> 
     83      <Importer>TextureImporter</Importer> 
     84      <Processor>TextureProcessor</Processor> 
     85    </Compile> 
     86    <Compile Include="jenkki lataus5.png"> 
     87      <Name>jenkki lataus5</Name> 
     88      <Importer>TextureImporter</Importer> 
     89      <Processor>TextureProcessor</Processor> 
     90    </Compile> 
     91    <Compile Include="jenkki lataus6.png"> 
     92      <Name>jenkki lataus6</Name> 
     93      <Importer>TextureImporter</Importer> 
     94      <Processor>TextureProcessor</Processor> 
     95    </Compile> 
     96  </ItemGroup> 
     97  <ItemGroup> 
     98    <Compile Include="NATSI.png"> 
     99      <Name>NATSI</Name> 
     100      <Importer>TextureImporter</Importer> 
     101      <Processor>TextureProcessor</Processor> 
     102    </Compile> 
     103  </ItemGroup> 
     104  <ItemGroup> 
     105    <Compile Include="jenkki2.png"> 
     106      <Name>jenkki2</Name> 
     107      <Importer>TextureImporter</Importer> 
     108      <Processor>TextureProcessor</Processor> 
     109    </Compile> 
     110  </ItemGroup> 
    65111  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    66112  <!--  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.