Changeset 3742 for 2012/30


Ignore:
Timestamp:
2012-07-25 10:59:27 (11 years ago)
Author:
majusiro
Message:

Talletus.

Location:
2012/30/MatiasS/Oma_peli/Oma_peli
Files:
1 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2012/30/MatiasS/Oma_peli/Oma_peli/Oma_peli/Oma_peli.cs

    r3727 r3742  
    1 using System; 
     1using System.Collections.Generic; 
     2using System; 
    23using System.Collections.Generic; 
    34using Jypeli; 
     
    910public class Oma_peli : PhysicsGame 
    1011{ 
    11    
     12 
     13    Image TehtavaKuva = LoadImage( "tkuva" ); 
    1214    AssaultRifle pelaajan1Ase; 
    13     const double PALLON_MIN_NOPEUS = 500; 
    1415    PhysicsObject pelaaja; 
    1516    public override void Begin() 
     
    1718        LuoPelaaja(); 
    1819        LuoNappaimet(); 
    19          
    2020        LuoTaustavari(); 
    2121        LuoKentta(); 
    22         
    23     } 
    24     
    25     
    26     
    27         void LuoKentta() 
    28 { 
    29   TileMap ruudut = TileMap.FromLevelAsset("kentta"); 
    30    
    31   ruudut.SetTileMethod('x', LuoPunainenTalo); 
    32   ruudut.SetTileMethod('y', LuoKeltainenTalo); 
    33   ruudut.SetTileMethod('k', LuoHarmaaTalo); 
    34   ruudut.SetTileMethod('o', LuoTalo); 
    35   ruudut.Execute(250, 250); 
     22 
     23         
     24 
     25 
     26    } 
     27 
     28 
     29 
     30    void LuoKentta() 
     31    { 
     32        TileMap ruudut = TileMap.FromLevelAsset("kentta"); 
     33        ruudut.SetTileMethod('@', TehtavanAnto); 
     34        ruudut.SetTileMethod('#', LuoIhminen); 
     35        ruudut.SetTileMethod('x', LuoPunainenTalo); 
     36        ruudut.SetTileMethod('y', LuoKeltainenTalo); 
     37        ruudut.SetTileMethod('k', LuoHarmaaTalo); 
     38        ruudut.SetTileMethod('o', LuoTalo); 
     39        ruudut.Execute(250, 250); 
     40        Level.CreateBorders(); 
    3641 
    3742 
     
    133138    { 
    134139        pelaajan1Ase = new AssaultRifle(30, 10); 
    135         pelaajan1Ase.Angle = Angle.RightAngle; 
    136  
     140        //pelaajan1Ase.Angle = Angle.RightAngle; 
     141        pelaajan1Ase.Angle = pelaaja.Angle - Angle.FromDegrees(90); 
    137142        pelaajan1Ase.ProjectileCollision = AmmusOsui; 
    138  
    139        
    140  
    141  
    142143        pelaaja.Add(pelaajan1Ase); 
    143  
    144144        //Ammusten määrä aluksi: 
    145145        pelaajan1Ase.Ammo.Value = 1000; 
    146  
    147  
    148  
    149     } 
     146    } 
     147 
    150148    void AmmuAseella(AssaultRifle ase) 
    151149    { 
     
    154152        if (ammus != null) 
    155153        { 
    156             //ammus.Size *= 3; 
    157             //ammus.Image = ... 
    158             //ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
     154            ammus.MaximumLifetime = TimeSpan.FromSeconds(2.0); 
     155            AddCollisionHandler(ammus, "ihminen", CollisionHandler.DestroyBoth); 
    159156        } 
    160157    } 
    161158    void AmmusOsui(PhysicsObject ammus, PhysicsObject kohde) 
    162159    { 
    163         ammus.Destroy(); 
    164  
    165     } 
     160         
     161 
     162    } 
     163     
     164    void LuoIhminen(Vector paikka, double leveys, double korkeus) 
     165    { 
     166        PhysicsObject ihminen = new PhysicsObject(50, 50); 
     167        ihminen.Tag = "ihminen"; 
     168        ihminen.Position = paikka; 
     169        ihminen.Shape = Shape.Circle; 
     170        Add(ihminen); 
     171 
     172        List<Vector> polku = new List<Vector>(); 
     173        polku.Add(new Vector(-300, -350)); 
     174        polku.Add(new Vector(-350, 300)); 
     175        polku.Add(new Vector(-200, -210)); 
     176 
     177        PathFollowerBrain polkuAivot = new PathFollowerBrain(); 
     178        polkuAivot.Path = polku; 
     179        ihminen.Brain = polkuAivot; 
     180    } 
     181 
     182    void TehtavanAnto(Vector paikka, double leveys, double korkeus) 
     183    { 
     184        PhysicsObject tehtava = PhysicsObject.CreateStaticObject(80, 80); 
     185        tehtava.Tag = "tehtava"; 
     186        tehtava.Image = TehtavaKuva; 
     187        Add(tehtava); 
     188        AddCollisionHandler(pelaaja, "tehtava", TormaysTehtavaan); 
     189    } 
     190         
     191        void TormaysTehtavaan(PhysicsObject pelaaja, PhysicsObject tehtava) 
     192{ 
     193    MessageDisplay.Add("Tehtävä"); 
    166194 
    167195} 
     196 
     197 
     198 
     199     
     200 
     201 
     202} 
  • 2012/30/MatiasS/Oma_peli/Oma_peli/Oma_peliContent/Oma_peliContent.contentproj

    r3727 r3742  
    6666    </Compile> 
    6767  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="tkuva.png"> 
     70      <Name>tkuva</Name> 
     71      <Importer>TextureImporter</Importer> 
     72      <Processor>TextureProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
    6875  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    6976  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2012/30/MatiasS/Oma_peli/Oma_peli/Oma_peliContent/kentta.txt

    r3727 r3742  
    22 
    33o k y o y x y 
    4  
     4          # 
    55k y x k o k x 
    6  
     6          @ 
    77k x y x x o y 
    88 
Note: See TracChangeset for help on using the changeset viewer.