Ignore:
Timestamp:
2013-07-02 14:59:02 (10 years ago)
Author:
joarmuho
Message:

Talletus.

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

Legend:

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

    r4343 r4362  
    2020    Image pelaajanKuva = LoadImage("norsu"); 
    2121    Image tahtiKuva = LoadImage("tahti"); 
     22    Image WumpaFruit = LoadImage("Wumpa"); 
    2223 
    2324    IntMeter pisteLaskuri; 
     
    2526    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    2627 
     28    AssaultRifle pelaajan1Ase; 
     29 
    2730    public override void Begin() 
    2831    { 
    29         MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", "Aloita peli", "Lopeta"); 
     32        MultiSelectWindow alkuValikko = new MultiSelectWindow("Pelin alkuvalikko", "Aloita peli", "High Score", "Lopeta"); 
    3033        alkuValikko.AddItemHandler(0, StartGame); 
    31         alkuValikko.AddItemHandler(1, Exit); 
     34        alkuValikko.AddItemHandler(1, SeeHighScore); 
     35        alkuValikko.AddItemHandler(2, Exit); 
    3236        Add(alkuValikko); 
    3337    } 
     
    5256        StartingPlatform.Color = Color.Red; 
    5357        Add(StartingPlatform); 
    54  
     58        pisteLaskuri = new IntMeter(0); 
    5559        LisaaPelaaja(); 
    5660 
    57         Level.Background.CreateGradient(Color.White, Color.SkyBlue); 
     61        Level.Background.CreateGradient(RandomGen.NextColor(), RandomGen.NextColor()); 
    5862 
    5963        Timer Ajastin = new Timer(); 
     
    6973            if (pelaaja1.Y < -400) 
    7074            { 
    71                 ClearAll(); 
    72                 Begin(); 
     75                HighScore(); 
     76            } 
     77 
     78            if (pelaaja1.X < Camera.ScreenToWorld(new Vector(Screen.Left, 0)).X) 
     79            { 
     80                HighScore(); 
    7381            } 
    7482 
     
    7785 
    7886         
    79         pisteLaskuri = new IntMeter(0); 
     87         
    8088        Label pisteNaytto = new Label(); 
    8189        pisteNaytto.X = Screen.Right - 100; 
     
    8997    } 
    9098 
    91     void LisaaTaso() 
     99    void LisaaTaso(bool ensimmainenKerta = false) 
    92100    { 
    93101        PhysicsObject taso = PhysicsObject.CreateStaticObject(64, 20); 
    94         taso.X = RandomGen.NextInt(100, 300) + VanhaTaso; 
    95         taso.Y = RandomGen.NextInt(-100, 75); 
    96         taso.Color = Color.Green; 
     102        taso.X = RandomGen.NextInt(150, 325) + VanhaTaso; 
     103        taso.Y = RandomGen.NextInt(-200, 75); 
     104        taso.Color = RandomGen.NextColor(); 
    97105        taso.Oscillate(Vector.UnitY, RandomGen.NextInt(50, 200), 0.5); 
    98106        VanhaTaso = taso.X; 
    99107        Add(taso); 
     108 
     109        if (ensimmainenKerta == false) 
     110        { 
     111            if (RandomGen.NextInt(1, 7) == 1) 
     112            { 
     113                PhysicsObject vihu = PhysicsObject.CreateStaticObject(32, 32); 
     114                vihu.X = taso.X; 
     115                vihu.Y = RandomGen.NextInt(0, 10) + taso.Y; 
     116                vihu.Image = tahtiKuva; 
     117                vihu.Tag = "vihu"; 
     118                vihu.AngularVelocity = 10.0; 
     119                Add(vihu); 
     120            } 
     121        } 
     122        if (RandomGen.NextInt(1, 10) == 1) 
     123        { 
     124            PhysicsObject wumpaf = PhysicsObject.CreateStaticObject(32, 32); 
     125            wumpaf.X = (taso.X + RandomGen.NextInt(50,100)); 
     126            wumpaf.Y = taso.Y+ RandomGen.NextInt(50,200); 
     127            wumpaf.Image = WumpaFruit; 
     128            wumpaf.Tag = "wumpa"; 
     129            Add(wumpaf); 
     130        } 
    100131    } 
    101132 
     
    107138        pelaaja1.Image = pelaajanKuva; 
    108139        Add(pelaaja1); 
    109          
    110         LisaaTaso(); 
     140        pelaajan1Ase = new AssaultRifle(30, 10); 
     141        pelaaja1.Add(pelaajan1Ase); 
     142        AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.DestroyTarget); 
     143        AddCollisionHandler(pelaaja1, "wumpa", CollisionHandler.AddMeterValue(pisteLaskuri, 50)); 
     144        AddCollisionHandler(pelaaja1, "vihu", TormaysHighScore); 
     145        LisaaTaso(true); 
    111146    } 
    112147 
     
    115150        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    116151        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     152 
     153        Keyboard.Listen(Key.P, ButtonState.Pressed, Pause, "Pysäyttää pelin"); 
     154 
     155        Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", pelaajan1Ase); 
    117156 
    118157        Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     
    140179    } 
    141180 
     181    void AmmuAseella(AssaultRifle ase) 
     182    { 
     183        PhysicsObject ammus = ase.Shoot(); 
     184        if (ammus!=null) 
     185        { 
     186            AddCollisionHandler(ammus, "vihu", CollisionHandler.AddMeterValue(pisteLaskuri, 100)); 
     187            AddCollisionHandler(ammus, "vihu", CollisionHandler.ExplodeTarget(50, true)); 
     188            AddCollisionHandler(ammus, CollisionHandler.DestroyObject); 
     189        } 
     190    } 
     191 
     192 
     193    void TormaysHighScore(PhysicsObject Tormaaja, PhysicsObject Kohde) 
     194    { 
     195        HighScore(); 
     196    } 
     197 
    142198    void HighScore() 
    143199    { 
    144  
     200        ClearAll(); 
     201        EasyHighScore topLista = new EasyHighScore(); 
     202        topLista.EnterAndShow(pisteLaskuri.Value); 
     203        topLista.HighScoreWindow.Closed += delegate { Begin(); }; 
     204    } 
     205    void SeeHighScore() 
     206    { 
     207        EasyHighScore topLista = new EasyHighScore(); 
     208        topLista.Show(); 
     209        topLista.HighScoreWindow.Closed += delegate { Begin(); }; 
    145210    } 
    146211 
  • 2013/27/JoonasM/RnGPlatformShooter/RnGPlatformShooter/RnGPlatformShooterContent/RnGPlatformShooterContent.contentproj

    r4343 r4362  
    6161      <Processor>TextureProcessor</Processor> 
    6262    </Compile> 
    63     <Compile Include="kentta1.txt"> 
    64       <Name>kentta1</Name> 
    65       <Importer>TextFileImporter</Importer> 
    66       <Processor>TextFileContentProcessor</Processor> 
     63  </ItemGroup> 
     64  <ItemGroup> 
     65    <Compile Include="Wumpa.png"> 
     66      <Name>Wumpa</Name> 
     67      <Importer>TextureImporter</Importer> 
     68      <Processor>TextureProcessor</Processor> 
    6769    </Compile> 
    6870  </ItemGroup> 
Note: See TracChangeset for help on using the changeset viewer.