Changeset 4120


Ignore:
Timestamp:
2013-06-13 15:01:10 (6 years ago)
Author:
juiitamm
Message:

Talletus.

Location:
2013/24/AamosR
Files:
24 added
4 edited

Legend:

Unmodified
Added
Removed
  • 2013/24/AamosR/GeneerinenAvaruuslentely/GeneerinenAvaruuslentely.sln

    r4075 r4120  
    44Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneerinenAvaruuslentely", "GeneerinenAvaruuslentely\GeneerinenAvaruuslentely\GeneerinenAvaruuslentely.csproj", "{2C05EB48-B643-4F4F-8810-D53371ECEEA1}" 
    55EndProject 
    6 Project("{96E2B04D-8817-42C6-938A-82C39BA4D311}") = "GeneerinenAvaruuslentelyContent", "GeneerinenAvaruuslentely\GeneerinenAvaruuslentelyContent\GeneerinenAvaruuslentelyContent.contentproj", "{80FE5423-0FC6-4261-A58D-2043799A9493}" 
     6Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GeneerinenAvaruuslentelyContent", "GeneerinenAvaruuslentely\GeneerinenAvaruuslentelyContent\GeneerinenAvaruuslentelyContent.contentproj", "{80FE5423-0FC6-4261-A58D-2043799A9493}" 
    77EndProject 
    88Global 
    99        GlobalSection(SolutionConfigurationPlatforms) = preSolution 
     10                Debug|Mixed Platforms = Debug|Mixed Platforms 
     11                Debug|Windows Phone = Debug|Windows Phone 
    1012                Debug|x86 = Debug|x86 
     13                Release|Mixed Platforms = Release|Mixed Platforms 
     14                Release|Windows Phone = Release|Windows Phone 
    1115                Release|x86 = Release|x86 
    1216        EndGlobalSection 
    1317        GlobalSection(ProjectConfigurationPlatforms) = postSolution 
     18                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 
     19                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Debug|Mixed Platforms.Build.0 = Debug|x86 
     20                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Debug|Windows Phone.ActiveCfg = Debug|x86 
     21                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Debug|Windows Phone.Build.0 = Debug|x86 
    1422                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Debug|x86.ActiveCfg = Debug|x86 
    1523                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Debug|x86.Build.0 = Debug|x86 
     24                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Release|Mixed Platforms.ActiveCfg = Release|x86 
     25                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Release|Mixed Platforms.Build.0 = Release|x86 
     26                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Release|Windows Phone.ActiveCfg = Release|x86 
     27                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Release|Windows Phone.Build.0 = Release|x86 
    1628                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Release|x86.ActiveCfg = Release|x86 
    1729                {2C05EB48-B643-4F4F-8810-D53371ECEEA1}.Release|x86.Build.0 = Release|x86 
     30                {80FE5423-0FC6-4261-A58D-2043799A9493}.Debug|Mixed Platforms.ActiveCfg = Debug|x86 
     31                {80FE5423-0FC6-4261-A58D-2043799A9493}.Debug|Windows Phone.ActiveCfg = Debug|x86 
    1832                {80FE5423-0FC6-4261-A58D-2043799A9493}.Debug|x86.ActiveCfg = Debug|x86 
     33                {80FE5423-0FC6-4261-A58D-2043799A9493}.Release|Mixed Platforms.ActiveCfg = Release|x86 
     34                {80FE5423-0FC6-4261-A58D-2043799A9493}.Release|Windows Phone.ActiveCfg = Release|x86 
    1935                {80FE5423-0FC6-4261-A58D-2043799A9493}.Release|x86.ActiveCfg = Release|x86 
    2036        EndGlobalSection 
  • 2013/24/AamosR/GeneerinenAvaruuslentely/GeneerinenAvaruuslentely/GeneerinenAvaruuslentely/GeneerinenAvaruuslentely.cs

    r4094 r4120  
    77using Jypeli.Widgets; 
    88 
    9 //TO DO-list: Tee health packit 
     9 
    1010 
    1111 
     
    2929    Image tausta = LoadImage("tausta"); 
    3030    Image vihollinenkuva = LoadImage("vihollinen"); 
     31    Image hp = LoadImage("hp"); 
     32    Image rajahdys = LoadImage("explosion0"); 
     33    Image liekkikuva = LoadImage("liekki"); 
    3134    SoundEffect hurt = LoadSoundEffect("hit"); 
    3235    SoundEffect shoot = LoadSoundEffect("shoot"); 
    3336    SoundEffect explosion = LoadSoundEffect("explosion"); 
     37    SoundEffect powerup = LoadSoundEffect("powerup"); 
    3438 
    3539 
    3640    alus alus; 
    3741    PhysicsObject asteroidi; 
     42    PhysicsObject HP; 
    3843    //PhysicsObject vihollinen; 
    3944    IntMeter pisteLaskuri; 
    4045    IntMeter ElamaLaskuri; 
    41      
    42  
     46 
     47    bool SaaAmpua = true; 
    4348     
    4449     
     
    4954        //IsFullScreen = true; 
    5055        ClearAll(); 
    51         Level.BackgroundColor = Color.Black; 
     56        Level.Background.Image = tausta; 
    5257 
    5358        SetWindowSize(1920, 1080, true); 
    54         MultiSelectWindow valikko = new MultiSelectWindow("Generic Space Game", "Start Game", "High Score", "Quit"); 
     59        MultiSelectWindow valikko = new MultiSelectWindow("Generic Space Game", "Start Game", "How to play", "High Score", "Quit"); 
    5560        //valikko.ItemSelected += PainettiinValikonNappia; 
    5661         
     
    5964        valikko.BorderColor = Color.Black; 
    6065        valikko.AddItemHandler(0, AloitaPeli); 
    61         valikko.AddItemHandler(1, ParhaatPisteet); 
    62         valikko.AddItemHandler(2, ConfirmExit); 
     66        valikko.AddItemHandler(1, Ohjeet); 
     67        valikko.AddItemHandler(2, ParhaatPisteet); 
     68        valikko.AddItemHandler(3, ConfirmExit); 
    6369         
    6470        Add(valikko); 
     
    7783 
    7884        MediaPlayer.Play("8bit Dungeon Boss"); 
     85        MediaPlayer.IsRepeating = true; 
    7986        LuoKentta(); 
    8087        AsteroidiAjastin(); 
    8188        VihollisAjastin(); 
     89        HPAjastin(); 
    8290        AsetaOhjaimet(); 
    8391        LuoPisteLaskuri(); 
     
    110118        alus.Destroy(); 
    111119        explosion.Play(); 
     120        ControllerOne.Vibrate(10.0, 10.0, 10.0, 10.0, 1.5); 
    112121        //Begin(); 
     122        Explosion rajahdys = new Explosion(1000); 
     123        rajahdys.Position = alus.Position; 
     124        rajahdys.Force = 0; 
     125        Add(rajahdys); 
    113126        topLista.EnterAndShow(pisteLaskuri.Value); 
    114127        topLista.HighScoreWindow.Closed += delegate { Begin(); }; 
    115128         
    116129         
     130    } 
     131 
     132    void Ohjeet() 
     133    { 
     134        MessageWindow ikkuna = new MessageWindow("The goal of this game is to survive. You get points when time passes and from destroying enemies. Health Packs give you 2 HP. \n \n \n Controls (Keyboard): \n \n WASD: move \n \n rCtrl: shoot \n \n Press Enter to continue \n"); 
     135        ikkuna.Closed += delegate { Begin(); }; 
     136        ikkuna.Message.SizeMode = TextSizeMode.AutoSize; 
     137        Add(ikkuna); 
     138        //Window ikkuna = new Window(); 
     139        //ikkuna. 
     140        //ikkuna.Title.Text = "How to play:"; 
     141        //Label teksti = new Label("The goal of this game is to survive. You get points when time passes and from destroying enemies. Controls: WASD: move rCtrl: shoot Press Enter to continue"); 
     142        //teksti.Width = 300; 
     143        //teksti.SizeMode = TextSizeMode.Wrapped; 
     144        //ikkuna.Add(teksti); 
     145        //Add(ikkuna); 
     146        //Add(teksti); 
     147        //Keyboard.Listen(Key.Enter, ButtonState.Pressed, Begin, null); 
    117148    } 
    118149 
     
    154185        alus.LinearDamping = 0.95; 
    155186        alus.ElamaLaskuri.Value--; 
     187        Vector pelaajanSuunta = Vector.FromLengthAndAngle(2500.0, alus.Angle); 
     188        Flame liekki = new Flame(liekkikuva); 
     189        //liekki.RotateImage = true; 
     190        //liekki. = Angle.RightAngle; 
     191        liekki.IgnoreWind = false; 
     192        Wind = new Vector(0, -100); 
     193        Add(liekki, -1); 
    156194 
    157195        Level.Background.Image = tausta; 
     
    160198 
    161199        AddCollisionHandler(alus, "vihollinen", kuolema); 
    162  
    163          
    164  
    165  
     200        AddCollisionHandler(alus, "hp", LisaaTerveys); 
    166201    } 
    167202 
     
    176211        Keyboard.Listen(Key.W, ButtonState.Down, TyonnaAlusta, null); 
    177212        Keyboard.Listen(Key.S, ButtonState.Down, VedaAlusta, null); 
    178         Keyboard.Listen(Key.RightControl, ButtonState.Pressed, Ammu, null); 
     213        Keyboard.Listen(Key.RightControl, ButtonState.Down, Ammu, null); 
     214        Keyboard.Listen(Key.P, ButtonState.Pressed, Pause, null); 
     215        ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, KaannaTatilla, null); 
     216        ControllerOne.Listen(Button.Back, ButtonState.Pressed, ConfirmExit, null); 
     217        ControllerOne.Listen(Button.Start, ButtonState.Pressed, Pause, null); 
     218        ControllerOne.ListenAnalog(AnalogControl.LeftTrigger, 0.1, AmmuLiipasin, null); 
     219 
     220         
     221         
     222         
     223    } 
     224 
     225    void AmmuLiipasin(AnalogState liipasimenTila) 
     226    { 
     227        Ammu(); 
     228    } 
     229 
     230 
     231    void KaannaTatilla(AnalogState tatinTila) 
     232    { 
     233        Vector tatinAsento = tatinTila.StateVector; 
     234        alus.AngularVelocity = tatinAsento.X * -10; 
     235        Vector pelaajanSuunta = Vector.FromLengthAndAngle(tatinAsento.Y * 2500, alus.Angle); 
     236        alus.Push(pelaajanSuunta); 
    179237    } 
    180238 
     
    182240    { 
    183241        alus.AngularVelocity = kulma; 
     242    } 
     243 
     244    void LisaaTerveys(PhysicsObject alus, PhysicsObject HP) 
     245    { 
     246        ElamaLaskuri.Value += 2; 
     247        HP.Destroy(); 
     248        powerup.Play(); 
    184249    } 
    185250 
     
    201266    { 
    202267        hurt.Play(); 
     268        Explosion rajahdys = new Explosion(100); 
     269        rajahdys.Position = vihollinen.Position; 
     270        rajahdys.Force = 0; 
     271        //rajahdys.Image = rajahdys; 
     272        Add(rajahdys); 
     273        ControllerOne.Vibrate(0.25, 0.25, 1.0, 1.0, 0.25); 
    203274        ElamaLaskuri.Value -= 1; 
    204275        vihollinen.Destroy(); 
    205276    } 
    206277 
    207          
    208      
     278 
     279    void HPAjastin() 
     280    { 
     281        Timer ajastin = new Timer(); 
     282        ajastin.Interval = 20; 
     283        ajastin.Timeout += LisaaHP; 
     284        ajastin.Start(); 
     285    } 
     286 
     287    void LisaaHP() 
     288    { 
     289        Vector kentanPiste = Level.GetRandomPosition(); 
     290        HP = new PhysicsObject(50, 50); 
     291        HP.IgnoresCollisionResponse = true; 
     292        HP.Tag = "hp"; 
     293        HP.Image = hp; 
     294        HP.Position = kentanPiste; 
     295        HP.LifetimeLeft = TimeSpan.FromSeconds(10); 
     296        Add(HP); 
     297    } 
    209298 
    210299    void LisaaAsteroidi() 
     
    220309        asteroidi.Image = asteroidikuva; 
    221310        asteroidi.Tag = "vihollinen"; 
     311        asteroidi.LifetimeLeft = TimeSpan.FromSeconds(10); 
    222312        asteroidi.IgnoresCollisionResponse = true; 
    223313        Add(asteroidi); 
     
    230320    { 
    231321        Timer ajastin = new Timer(); 
    232         ajastin.Interval = 0.5; 
     322        ajastin.Interval = 0.25; 
    233323        ajastin.Timeout += LisaaAsteroidi; 
    234324        ajastin.Start(); 
     
    238328    { 
    239329        Timer ajastin = new Timer(); 
    240         ajastin.Interval = 7; 
     330        ajastin.Interval = 5; 
    241331        ajastin.Timeout += LisaaVihollinen; 
    242332        ajastin.Start(); 
     
    254344        //vihollinen.Tag = "vihu"; 
    255345        vihollinen.IgnoresCollisionResponse = true; 
    256         vihollinen.MaximumLifetime = TimeSpan.FromSeconds(10); 
     346        vihollinen.LifetimeLeft = TimeSpan.FromSeconds(10); 
    257347 
    258348        AssaultRifle pelaajan1Ase = new AssaultRifle(30, 10); 
    259349        pelaajan1Ase.IsVisible = false; 
    260          
     350        pelaajan1Ase.FireRate = 9001; 
    261351        pelaajan1Ase.InfiniteAmmo = true; 
    262         pelaajan1Ase.Power.DefaultValue = 200; 
    263         pelaajan1Ase.Power.Value = 200; 
     352        pelaajan1Ase.Power.DefaultValue = 100; 
     353        pelaajan1Ase.Power.Value = 100; 
    264354        pelaajan1Ase.ProjectileCollision = AmmusOsui; 
    265355        vihollinen.Add(pelaajan1Ase); 
     
    284374            ElamaLaskuri.Value -= 1; 
    285375            hurt.Play(); 
     376            Explosion rajahdys = new Explosion(100); 
     377            ControllerOne.Vibrate(0.25, 0.25, 1.0, 1.0, 0.25); 
     378            rajahdys.Position = ammus.Position; 
     379            rajahdys.Force = 0; 
     380            Add(rajahdys); 
    286381             
    287382        } 
     
    295390        { 
    296391            ajastin.Stop(); 
     392            return; 
    297393        } 
    298394        Vector suunta = (alus.Position - vihollinen.Position).Normalize(); 
     
    308404    void Ammu() 
    309405    { 
    310         shoot.Play(); 
    311         PhysicsObject ammus = new PhysicsObject(10, 10); 
    312          
    313         Vector pelaajanSuunta = Vector.FromLengthAndAngle(2500.0, alus.Angle); 
    314          
    315  
    316         ammus.Position = alus.Position + Vector.FromLengthAndAngle(80.0, alus.Angle); 
    317         ammus.Shape = Shape.Circle; 
    318         ammus.Color = Color.Yellow; 
    319         ammus.Hit(pelaajanSuunta); 
    320  
    321         Add(ammus, -1); 
    322          
    323          
    324         ammus.CanRotate = false; 
    325         ammus.IgnoresCollisionResponse = true; 
    326         AddCollisionHandler(ammus, "vihollinen", vihollisenKuolema); 
    327          
    328         Timer poistumisAjastin = new Timer(); 
    329         poistumisAjastin.Interval = 1; 
    330         poistumisAjastin.Timeout += delegate { ammusPoistuu(ammus); }; 
    331         poistumisAjastin.Start(); 
    332          
     406        if (SaaAmpua == true) 
     407        { 
     408            SaaAmpua = false; 
     409            shoot.Play(); 
     410            PhysicsObject ammus = new PhysicsObject(10, 10); 
     411 
     412            Vector pelaajanSuunta = Vector.FromLengthAndAngle(2500.0, alus.Angle); 
     413 
     414 
     415            ammus.Position = alus.Position + Vector.FromLengthAndAngle(80.0, alus.Angle); 
     416            ammus.Shape = Shape.Circle; 
     417            ammus.Color = Color.Yellow; 
     418            ammus.Hit(pelaajanSuunta); 
     419 
     420            Add(ammus, -1); 
     421 
     422 
     423            ammus.CanRotate = false; 
     424            ammus.IgnoresCollisionResponse = true; 
     425            AddCollisionHandler(ammus, "vihollinen", vihollisenKuolema); 
     426 
     427            Timer poistumisAjastin = new Timer(); 
     428            poistumisAjastin.Interval = 1; 
     429            poistumisAjastin.Timeout += delegate { ammusPoistuu(ammus); }; 
     430            poistumisAjastin.Start(); 
     431 
     432            Timer.SingleShot(0.002, 
     433                delegate { SaaAmpua = true; } 
     434            ); 
     435        } 
    333436    } 
    334437 
     
    350453        vihollinen.Destroy(); 
    351454        hurt.Play(); 
     455        Explosion rajahdys = new Explosion(100); 
     456        rajahdys.Position = vihollinen.Position; 
     457        rajahdys.Force = 0; 
     458        Add(rajahdys); 
    352459        ammus.Destroy(); 
    353460 
  • 2013/24/AamosR/GeneerinenAvaruuslentely/GeneerinenAvaruuslentely/GeneerinenAvaruuslentelyContent/GeneerinenAvaruuslentelyContent.contentproj

    r4094 r4120  
    101101    </Compile> 
    102102  </ItemGroup> 
     103  <ItemGroup> 
     104    <Compile Include="hp.png"> 
     105      <Name>hp</Name> 
     106      <Importer>TextureImporter</Importer> 
     107      <Processor>TextureProcessor</Processor> 
     108    </Compile> 
     109  </ItemGroup> 
     110  <ItemGroup> 
     111    <Compile Include="powerup.wav"> 
     112      <Name>powerup</Name> 
     113      <Importer>WavImporter</Importer> 
     114      <Processor>SoundEffectProcessor</Processor> 
     115    </Compile> 
     116  </ItemGroup> 
     117  <ItemGroup> 
     118    <Compile Include="explosion0.png"> 
     119      <Name>explosion0</Name> 
     120      <Importer>TextureImporter</Importer> 
     121      <Processor>TextureProcessor</Processor> 
     122    </Compile> 
     123  </ItemGroup> 
     124  <ItemGroup> 
     125    <Compile Include="liekki.png"> 
     126      <Name>liekki</Name> 
     127      <Importer>TextureImporter</Importer> 
     128      <Processor>TextureProcessor</Processor> 
     129    </Compile> 
     130  </ItemGroup> 
    103131  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    104132  <!--  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.