Ignore:
Timestamp:
2013-07-04 15:01:23 (10 years ago)
Author:
joarmuho
Message:

Talletus.

Location:
2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter
Files:
3 added
2 edited

Legend:

Unmodified
Added
Removed
  • 2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooter.cs

    r4409 r4437  
    2323    Image HeliChapter = LoadImage("Helipad"); 
    2424    Image FireLava = LoadImage("Fireball"); 
     25    Image Solar = LoadImage("Sun"); 
     26    Image Sydan = LoadImage("Heart"); 
     27    Image Lintu = LoadImage("Pigeon"); 
    2528 
    2629    IntMeter pisteLaskuri; 
     30    IntMeter Enu; 
     31    IntMeter Wumpat; 
    2732 
    2833    SoundEffect maaliAani = LoadSoundEffect("maali"); 
     
    3237    public override void Begin() 
    3338    { 
     39        Label tekstikentta = new Label("RnGPlatformShooter"); 
     40        tekstikentta.Font = Font.DefaultLarge; 
     41        tekstikentta.X = 0; 
     42        tekstikentta.Y = Level.Top - 50; 
     43        Add(tekstikentta); 
     44 
    3445        MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", "Aloita peli", "High Score", "Lopeta"); 
    3546        alkuValikko.AddItemHandler(0, StartGame); 
     
    4152    void StartGame() 
    4253    { 
     54        ClearAll(); 
    4355        Gravity = new Vector(0, -1500); 
    4456 
     
    5365    void LuoKentta() 
    5466    { 
     67        PhysicsObject SolarS = PhysicsObject.CreateStaticObject(64, 64); 
     68        SolarS.X = 790; 
     69        SolarS.Y = 300; 
     70        SolarS.Image = Solar; 
     71        SolarS.IgnoresCollisionResponse = true; 
     72        SolarS.Velocity = new Vector(CameraSpeed, 0); 
     73        Add(SolarS); 
    5574        VanhaTaso = 0; 
    5675        PhysicsObject StartingPlatform = PhysicsObject.CreateStaticObject(80, 20); 
     
    5978        Add(StartingPlatform); 
    6079        pisteLaskuri = new IntMeter(0); 
     80        Enu = new IntMeter(1); 
     81        Wumpat = new IntMeter(0); 
     82         
    6183        LisaaPelaaja(); 
    6284 
     
    6991            pisteLaskuri.Value += 1; 
    7092 
    71             if (Camera.Velocity.X < 210) 
     93            if (Camera.Velocity.X < 190) 
    7294            { 
    7395                Camera.Velocity *= 1.05; 
     96                SolarS.Velocity *= 1.05; 
    7497            } 
    7598             
     
    83106                HighScore(); 
    84107            } 
     108            if (Wumpat > 10) 
     109            { 
     110                Wumpat.Value -= 10; 
     111                Enu.Value += 2; 
     112            } 
    85113 
    86114        }; 
    87115        Ajastin.Start(); 
    88116 
    89          
    90          
    91117        Label pisteNaytto = new Label(); 
    92         pisteNaytto.X = Screen.Right - 100; 
     118        pisteNaytto.X = Screen.Left + 100; 
    93119        pisteNaytto.Y = Screen.Top - 100; 
    94120        pisteNaytto.TextColor = Color.Black; 
    95121        pisteNaytto.Color = Color.White; 
    96122        pisteNaytto.Title = "Pisteet"; 
    97  
    98123        pisteNaytto.BindTo(pisteLaskuri); 
    99124        Add(pisteNaytto); 
     125 
     126        Label ElamaMeter = new Label(); 
     127        ElamaMeter.X = Screen.Left + 100; 
     128        ElamaMeter.Y = Screen.Top - 150; 
     129        ElamaMeter.TextColor = Color.Black; 
     130        ElamaMeter.Color = Color.White; 
     131        ElamaMeter.Title = "Elämät"; 
     132        ElamaMeter.BindTo(Enu); 
     133        Add(ElamaMeter); 
     134         
     135        Label WumpaMeter = new Label(); 
     136        WumpaMeter.X = Screen.Left + 100; 
     137        WumpaMeter.Y = Screen.Top - 200; 
     138        WumpaMeter.TextColor = Color.Black; 
     139        WumpaMeter.Color = Color.White; 
     140        WumpaMeter.Title = "Wumpat"; 
     141        WumpaMeter.BindTo(Wumpat); 
     142        Add(WumpaMeter); 
    100143    } 
    101144 
     
    104147        if (RandomGen.NextInt(1, 10) != 1) 
    105148        { 
    106             PhysicsObject taso = PhysicsObject.CreateStaticObject(64, 20); 
    107             taso.X = RandomGen.NextInt(150, 325) + VanhaTaso; 
     149            PhysicsObject taso = PhysicsObject.CreateStaticObject(RandomGen.NextInt(62, 82), 20); 
     150            taso.X = RandomGen.NextInt(150, 280) + VanhaTaso; 
    108151            taso.Y = RandomGen.NextInt(-200, 75); 
    109152            taso.Color = RandomGen.NextColor(); 
    110             taso.Oscillate(Vector.UnitY, RandomGen.NextInt(75, 250), 0.5); 
     153            taso.Oscillate(Vector.UnitY, RandomGen.NextInt(85, 250), 0.5); 
    111154            VanhaTaso = taso.X; 
     155            taso.MakeOneWay(); 
    112156            Add(taso); 
    113157 
    114158            if (ensimmainenKerta == false) 
    115159            { 
    116                 if (RandomGen.NextInt(1, 7) == 1) 
     160                if (RandomGen.NextInt(1, 6) == 1) 
    117161                { 
    118162                    PhysicsObject vihu = PhysicsObject.CreateStaticObject(32, 32); 
     
    159203                    LaavaPallo.IgnoresCollisionResponse = true; 
    160204                    Add(LaavaPallo); 
    161                     LaavaPallo.Hit(new Vector(RandomGen.NextInt(-100,300), RandomGen.NextInt(800,1800))); 
     205                    LaavaPallo.Hit(new Vector(RandomGen.NextInt(-100,400), RandomGen.NextInt(800,1600))); 
    162206                } 
    163             } 
    164  
    165             if (RandomGen.NextInt(1, 10) == 1) 
     207 
     208                if (RandomGen.NextInt(1, 15) == 1) 
     209                { 
     210                    PhysicsObject Pigeon = PhysicsObject.CreateStaticObject(49, 35); 
     211                    Pigeon.X = Camera.ScreenToWorld(new Vector(Screen.Left, 0)).X; 
     212                    Pigeon.Y = pelaaja1.Y + 50; 
     213                    Pigeon.LifetimeLeft = TimeSpan.FromSeconds(5); 
     214                    Pigeon.Image = Lintu; 
     215                    Pigeon.IgnoresCollisionResponse = true; 
     216                    Pigeon.Tag = "vihu"; 
     217                    Pigeon.Velocity = new Vector(500, 0); 
     218                    Add(Pigeon); 
     219                } 
     220            } 
     221 
     222            if (RandomGen.NextInt(1, 3) == 1) 
    166223            { 
    167224                PhysicsObject wumpaf = PhysicsObject.CreateStaticObject(32, 32); 
     
    172229                wumpaf.IgnoresCollisionResponse = true; 
    173230                Add(wumpaf); 
     231            } 
     232 
     233            if (RandomGen.NextInt(1, 25) == 1) 
     234            { 
     235                PhysicsObject Health = PhysicsObject.CreateStaticObject(32, 32); 
     236                Health.X = (taso.X + RandomGen.NextInt(50, 100)); 
     237                Health.Y = taso.Y + RandomGen.NextInt(50, 200); 
     238                Health.IgnoresCollisionResponse = true; 
     239                Health.Image = Sydan; 
     240                Health.Tag = "Heal"; 
     241                Add(Health); 
    174242            } 
    175243 
     
    198266        pelaaja1.Add(pelaajan1Ase); 
    199267        AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.DestroyTarget); 
    200         AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(pisteLaskuri, 50)); 
     268        AddCollisionHandler(pelaaja1, "Heal", CollisionHandler.DestroyTarget); 
     269        AddCollisionHandler(pelaaja1, "Heal", CollisionHandler.AddMeterValue(Enu, 1)); 
     270        AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(pisteLaskuri, 10)); 
     271        AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(Wumpat, 1)); 
    201272        AddCollisionHandler(pelaaja1, "vihu", TormaysHighScore); 
    202273        AddCollisionHandler(pelaaja1, "TTaso", TuhoaTaso); 
     
    206277    void TuhoaTaso(PhysicsObject tormaaja, PhysicsObject objekti) 
    207278    { 
    208         //Timer TasoAjastin = new Timer(); 
    209279        Timer.SingleShot(1.5, delegate { 
    210280            if (!objekti.IsDestroyed) 
     
    216286            } 
    217287        }); 
    218         //TasoAjastin.Start(); 
    219288    } 
    220289 
     
    267336    void TormaysHighScore(PhysicsObject Tormaaja, PhysicsObject Kohde) 
    268337    { 
    269         HighScore(); 
     338        if (Enu < 1) 
     339        { 
     340            HighScore(); 
     341        } 
     342        else 
     343        { 
     344            Enu.Value -= 1; 
     345            CollisionHandler.DestroyTarget(Tormaaja, Kohde); 
     346        } 
    270347    } 
    271348 
  • 2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooterContent/RnGPlatformShooterContent.contentproj

    r4409 r4437  
    8383    </Compile> 
    8484  </ItemGroup> 
     85  <ItemGroup> 
     86    <Compile Include="Sun.png"> 
     87      <Name>Sun</Name> 
     88      <Importer>TextureImporter</Importer> 
     89      <Processor>TextureProcessor</Processor> 
     90    </Compile> 
     91  </ItemGroup> 
     92  <ItemGroup> 
     93    <Compile Include="Heart.png"> 
     94      <Name>Heart</Name> 
     95      <Importer>TextureImporter</Importer> 
     96      <Processor>TextureProcessor</Processor> 
     97    </Compile> 
     98  </ItemGroup> 
     99  <ItemGroup> 
     100    <Compile Include="Pigeon.png"> 
     101      <Name>Pigeon</Name> 
     102      <Importer>TextureImporter</Importer> 
     103      <Processor>TextureProcessor</Processor> 
     104    </Compile> 
     105  </ItemGroup> 
    85106  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    86107  <!--  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.