Changeset 1194


Ignore:
Timestamp:
2010-07-08 14:56:36 (13 years ago)
Author:
akrauhan
Message:

Kuvia piirrelty, pommeja lisäilty jne.

Location:
2010/27/akrauhan
Files:
14 added
3 edited

Legend:

Unmodified
Added
Removed
  • 2010/27/akrauhan/Wooden Warfare/Content/Content.contentproj

    r1144 r1194  
    3939      <Importer>TextureImporter</Importer> 
    4040      <Processor>TextureProcessor</Processor> 
     41      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
     42    </Compile> 
     43  </ItemGroup> 
     44  <ItemGroup> 
     45    <Compile Include="jousi1.png"> 
     46      <Name>jousi1</Name> 
     47      <Importer>TextureImporter</Importer> 
     48      <Processor>TextureProcessor</Processor> 
     49      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
     50    </Compile> 
     51  </ItemGroup> 
     52  <ItemGroup> 
     53    <Compile Include="pommi.png"> 
     54      <Name>pommi</Name> 
     55      <Importer>TextureImporter</Importer> 
     56      <Processor>TextureProcessor</Processor> 
     57    </Compile> 
     58  </ItemGroup> 
     59  <ItemGroup> 
     60    <Compile Include="pommi2.png"> 
     61      <Name>pommi2</Name> 
     62      <Importer>TextureImporter</Importer> 
     63      <Processor>TextureProcessor</Processor> 
     64    </Compile> 
     65  </ItemGroup> 
     66  <ItemGroup> 
     67    <Compile Include="pommi3.png"> 
     68      <Name>pommi3</Name> 
     69      <Importer>TextureImporter</Importer> 
     70      <Processor>TextureProcessor</Processor> 
     71    </Compile> 
     72  </ItemGroup> 
     73  <ItemGroup> 
     74    <Compile Include="Red.png"> 
     75      <Name>Red</Name> 
     76      <Importer>TextureImporter</Importer> 
     77      <Processor>TextureProcessor</Processor> 
     78    </Compile> 
     79  </ItemGroup> 
     80  <ItemGroup> 
     81    <Compile Include="nuoli.png"> 
     82      <Name>nuoli</Name> 
     83      <Importer>TextureImporter</Importer> 
     84      <Processor>TextureProcessor</Processor> 
    4185    </Compile> 
    4286  </ItemGroup> 
  • 2010/27/akrauhan/Wooden Warfare/Peli.cs

    r1144 r1194  
    22using Jypeli; 
    33using Jypeli.Widgets; 
     4using Physics2DDotNet.Ignorers; 
    45using Jypeli.Assets; 
     6using Jypeli.Effects; 
    57using System.Collections.Generic; 
    68 
     
    1214    const int ruudunLeveys = 50; 
    1315    const int ruudunKorkeus = 50; 
    14  
     16    IntMeter pisteLaskuri; 
     17    ExplosionSystem rajahdys; 
     18    PhysicsObject PistePalikka; 
     19    Timer powerup; 
    1520    Timer pomminPudotusAjastin; 
     21    ObjectIgnorer ignorer = new ObjectIgnorer(); 
     22 
    1623 
    1724    protected override void Begin() 
    18     { 
    19         pomminPudotusAjastin = new Timer(); 
    20  
     25    {     
    2126        LuoKentta(); 
     27        pomminPudotusAjastin = new Timer();        
    2228        KaynnistaPomminpudotusAjastin(); 
    2329        Ohjaimet(); 
     30        // aikaLaskuri.Start();       
     31        LataaRajahdykset(); 
     32        LuoAikaLaskuri(); 
     33        LuoPisteLaskuri(); 
     34 
     35    } 
     36 
     37    private void LataaRajahdykset() 
     38    { 
     39        Image expl = LoadImage("Red"); 
     40        rajahdys = new ExplosionSystem(expl, 1000); 
     41        Add(rajahdys); 
    2442    } 
    2543 
    2644    void KaynnistaPomminpudotusAjastin() 
    27     {         
    28         pomminPudotusAjastin.Interval = 3; 
     45    { 
     46        pomminPudotusAjastin.Interval = 2; 
    2947        pomminPudotusAjastin.Trigger += Pommeja; 
    3048        Add(pomminPudotusAjastin); 
     49        pomminPudotusAjastin.Start(); 
    3150    } 
    3251 
    3352    void NopeutaPommienPutoamista() 
    3453    { 
    35         pomminPudotusAjastin.Interval /= 2; 
    36     } 
    37  
    38     void HidastaPommienPutoamista() 
    39     { 
    40         // Jaa intervalli ykköstä pienemmällä 
    41     } 
    42  
     54        pomminPudotusAjastin.Interval /= 1.5; 
     55    } 
    4356 
    4457    void Pommeja(Timer ajastin) 
    4558    { 
    46  
    47         // Arvotan luku väliltä [Level.Left, Level.Right] 
    48         double x = RandomGen.NextDouble(Level.Left, Level.Right); 
    49         double y = 600.0; 
    50  
    51         // Pommit putoilevat.. Tee uusi fysiikkaolio ja lisää sille törmäyksenkäsittelijä 
    52     } 
     59        Add(LuoPommi(20, 40, new Vector(0, -200), "pommi")); 
     60        Add(LuoPommi(30, 50, new Vector(0, -100), "pommi2")); 
     61        Add(LuoPommi(50, 70, new Vector(0, -50), "pommi3")); 
     62    } 
     63    void PowerUp(Timer powerup) 
     64    { 
     65        //Add(KerattavaEsine); 
     66    } 
     67     
     68 
     69     
    5370 
    5471    void LuoKentta() 
    5572    { 
    56         varsijousi = new Automobile(75, 30); 
     73        varsijousi = new PhysicsObject(75, 30); 
     74        varsijousi.CollisionIgnorer = ignorer; 
    5775        varsijousi.Shape = Shapes.Rectangle; 
    5876        varsijousi.X = 0; 
    5977        varsijousi.Y = -200; 
    60         varsijousi.IgnoresCollisionResponse = true;        
     78        varsijousi.IgnoresCollisionResponse = true; 
     79        varsijousi.Image = LoadImage("jousi1"); 
    6180        Add(varsijousi); 
     81 
     82        PhysicsObject KerattavaEsine = new PhysicsObject(40,40); 
     83 
     84        pyssy = new LaserGun(20, 5); 
    6285         
    63         
     86        varsijousi.Add(pyssy); 
     87 
     88        powerup = new Timer(); 
     89        powerup.Interval = 30; 
     90        powerup.Trigger += PowerUp; 
    6491        kuormaauto = new PhysicsObject(200.0, 100.0); 
    6592        kuormaauto.X = -550.0; 
    66         kuormaauto.Y = -250.0;  
     93        kuormaauto.Y = -250.0; 
    6794        Add(kuormaauto); 
    68         pyssy = new LaserGun(20, 5); 
    69         varsijousi.Add(pyssy); 
    7095        PathFollowerBrain tietaseuraavatAivot = new PathFollowerBrain(); 
    7196        kuormaauto.Brain = tietaseuraavatAivot; 
    7297        List<Vector> polku = new List<Vector>(); 
    73         polku.Add( new Vector(-800.0,-250.0)); 
    74         polku.Add( new Vector(800.0,-250.0)); 
     98        polku.Add(new Vector(-800.0, -250.0)); 
     99        polku.Add(new Vector(800.0, -250.0)); 
    75100        tietaseuraavatAivot.Path = polku; 
    76101        tietaseuraavatAivot.Speed = 100; 
     
    79104        ruudut['-'] = LuoPalikKaksi; 
    80105        ruudut['='] = LuoPalikka; 
    81         varsijousi.Image = LoadImage 
    82          
     106        PistePalikka = new PhysicsObject(30, 30); 
     107        PistePalikka.X = -800.0; 
     108        PistePalikka.Y = -250.0; 
     109        Add(PistePalikka); 
    83110        ruudut.Insert(40.0, 40.0); 
    84111        Level.Background.Image = LoadImage("Winter"); 
    85112        Level.Background.FitToLevel(); 
    86  
    87  
    88  
    89  
    90     } 
     113        AddCollisionHandler(kuormaauto, KasitteleTormays4); 
     114        AddCollisionHandler(varsijousi, KasitteleTormays5); 
     115 
     116    } 
     117    void KasitteleTormays5(PhysicsObject varsijousi, PhysicsObject kohde) 
     118    { 
     119       // if (kohde == //KerattavaEsine) 
     120         
     121 
     122         
     123    } 
     124    void KasitteleTormays4(PhysicsObject kuormaauto, PhysicsObject kohde) 
     125    { 
     126        if (kohde == PistePalikka) 
     127        { 
     128            pisteLaskuri.Value += 100; 
     129        } 
     130    } 
     131 
    91132    void Ohjaimet() 
    92133    { 
    93134        Keyboard.Listen(Key.Up, ButtonState.Down, LiikuEteen, "Liiku eteenpäin"); 
    94         Keyboard.Listen(Key.Up, ButtonState.Released, Pysahdy, "Pysayta"); 
     135        Keyboard.Listen(Key.Up, ButtonState.Up, Pysahdy, "Pysayta"); 
    95136        Keyboard.Listen(Key.Down, ButtonState.Pressed, LiikuTaakse, "Liiku taaksepäin"); 
    96137        Keyboard.Listen(Key.Down, ButtonState.Released, Pysahdy, "Pysayta"); 
     
    99140        Keyboard.Listen(Key.Right, ButtonState.Down, KaannyVastapaivaan, "Käänny Vasemmalle"); 
    100141        Keyboard.Listen(Key.Right, ButtonState.Released, Pysahdy2, "Käänny Vasemmalle"); 
    101         Keyboard.Listen(Key.Space, ButtonState.Down, pyssy.Use, "Käytä"); 
    102     } 
    103          
    104         void LiikuEteen() 
     142        Keyboard.Listen(Key.Space, ButtonState.Down, Ammu, "Käytä asetta"); 
     143    } 
     144 
     145    void Ammu() 
     146    { 
     147        PhysicsObject ammus = pyssy.Shoot(); 
     148        if (ammus != null) 
     149        { 
     150            ammus.Color = Color.Brown; 
     151            ammus.Width *= 4; 
     152            ammus.Height *= 4; 
     153            ammus.CollisionIgnorer = new ObjectIgnorer(); 
     154            ammus.Image = LoadImage("nuoli"); 
     155        } 
     156    } 
     157 
     158    void LiikuEteen() 
    105159    { 
    106160        Vector suunta = Vector.FromLengthAndAngle(1.0, varsijousi.Angle); 
     
    135189 
    136190    void Pysahdy2() 
    137     {         
     191    { 
    138192    } 
    139193 
     
    155209    } 
    156210 
    157  
    158   
     211    PhysicsObject LuoPommi(double leveys, double korkeus, Vector tippumisvoima, String kuva) 
     212    { 
     213        PhysicsObject pommi = new PhysicsObject(leveys, korkeus); 
     214        pommi.CollisionIgnorer = ignorer; 
     215        AddCollisionHandler(pommi, KasitteleTormays); 
     216        pommi.Image = LoadImage(kuva); 
     217        double x = RandomGen.NextDouble(Level.Left, Level.Right); 
     218        double y = 600.0; 
     219        pommi.X = x; 
     220        pommi.Y = y; 
     221        pommi.Hit(tippumisvoima); 
     222        return pommi; 
     223    } 
     224 
     225 
     226 
     227    void Rajayta(double x, double y) 
     228    { 
     229        rajahdys.AddEffect(x, y, 30); 
     230    } 
     231 
     232 
     233    void KasitteleTormays(PhysicsObject heikkopommi, PhysicsObject kohde) 
     234    { 
     235        Rajayta(heikkopommi.X, heikkopommi.Y); 
     236        heikkopommi.Destroy(); 
     237    } 
     238 
     239 
     240 
     241    void KasitteleTormays2(PhysicsObject normaalipommi, PhysicsObject kohde) 
     242    { 
     243        normaalipommi.Destroy(); 
     244        Explosion rajahdys = new Explosion(70); 
     245        rajahdys.Position = normaalipommi.Position; 
     246        Add(rajahdys); 
     247    } 
     248 
     249     
     250    void KasitteleTormays3(PhysicsObject vahvapommi, PhysicsObject kohde) 
     251    { 
     252        vahvapommi.Destroy(); 
     253        Explosion rajahdys = new Explosion(100); 
     254        rajahdys.Position = vahvapommi.Position; 
     255        Add(rajahdys); 
     256    } 
     257 
     258    Timer aikaLaskuri; 
     259 
     260    void LuoAikaLaskuri() 
     261    { 
     262        aikaLaskuri = new Timer(); 
     263        Add(aikaLaskuri); 
     264        aikaLaskuri.Start(); 
     265 
     266        Label aikaNaytto = new Label("Aikaa kulunut:"); 
     267        aikaNaytto.TextColor = Color.Red; 
     268        aikaNaytto.DecimalPlaces = 1; 
     269        aikaNaytto.BindTo(aikaLaskuri.SecondCounter); 
     270        aikaNaytto.X = 400; 
     271        aikaNaytto.Y = 400; 
     272 
     273        Add(aikaNaytto); 
     274    } 
     275 
     276     
     277 
     278    void LuoPisteLaskuri() 
     279    { 
     280        pisteLaskuri = new IntMeter(0); 
     281 
     282        Label pisteNaytto = new Label(); 
     283        pisteNaytto.X = Screen.Left + 100; 
     284        pisteNaytto.Y = Screen.Top - 100; 
     285        pisteNaytto.TextColor = Color.Red; 
     286 
     287        pisteNaytto.BindTo(pisteLaskuri); 
     288        Add(pisteNaytto); 
     289 
     290        Label pisteTeksti = new Label("Pisteitä:"); 
     291        pisteTeksti.X = Screen.Left + 50; 
     292        pisteTeksti.Y = Screen.Top - 100; 
     293        pisteTeksti.TextColor = Color.Red; 
     294        Add(pisteTeksti); 
     295 
     296        if (pisteLaskuri.Value >= 300) 
     297        { 
     298            NopeutaPommienPutoamista(); 
     299        } 
     300        if (pisteLaskuri.Value >= 600) 
     301        { 
     302            NopeutaPommienPutoamista(); 
     303        } 
     304        if (pisteLaskuri.Value >= 1000) 
     305        { 
     306            NopeutaPommienPutoamista(); 
     307        } 
     308    } 
     309 
     310 
     311    void LuoEnergia() 
     312    { 
     313        Energiamittari = new IntMeter(100); 
     314 
     315        Label EnergiaNaytto = new Label(); 
     316        EnergiaNaytto.X = 0.0; 
     317        EnergiaNaytto.Y = Screen.Bottom + 100; 
     318        EnergiaNaytto.TextColor = Color.Green; 
     319 
     320        EnergiaNaytto.BindTo(Energiamittari); 
     321        Add(EnergiaNaytto); 
     322 
     323        if (LuoEnergia.Value <= 1) 
     324        { 
     325            kuormaauto.Destroy; 
     326        } 
     327    } 
     328     
     329 
     330     
     331 
     332     
    159333} 
    160334 
    161  
  • 2010/27/akrauhan/Wooden Warfare/Wooden Warfare.csproj

    r1144 r1194  
    9191    <Content Include="Game.ico" /> 
    9292    <Content Include="GameThumbnail.png" /> 
     93    <Content Include="pommi.png" /> 
    9394    <None Include="kenttä"> 
    9495      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory> 
Note: See TracChangeset for help on using the changeset viewer.