Changeset 5827 for 2014/koodauskerho


Ignore:
Timestamp:
2015-04-18 14:55:10 (8 years ago)
Author:
sieerinn
Message:
 
Location:
2014/koodauskerho/38/EetuR
Files:
6 added
18 edited

Legend:

Unmodified
Added
Removed
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip.cs

    r5815 r5827  
    1414 
    1515    PlatformCharacter pelaaja1; 
    16  
     16    DoubleMeter elamaLaskuri; 
     17 
     18    Image[] pelaajaliikuKuvat = LoadImages("Pelaaja_hahmo_tykki_kasi_move","Pelaaja_hahmo_tykki_kasi"); 
    1719    Image pelaajanKuva = LoadImage("Pelaaja_hahmo_tykki_kasi"); 
    1820    Image tahtiKuva = LoadImage("tahti"); 
    1921    Image vihukuva = LoadImage("Vihu1"); 
     22    Image vihutuhokuva = LoadImage("vihutuho"); 
    2023    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    21  
     24    bool pelaajaTormaa = false; 
    2225    AssaultRifle pelaajan1Ase; 
    2326    Image energyshot = LoadImage("energyshot"); 
     27    Image[] vihuKavelee = LoadImages("Vihu1", "Vihu1move"); 
     28    bool voikoheittaakranua = true; 
     29 
     30    IntMeter pisteLaskuri; 
     31 
     32    void LuoPistelaskuri() 
     33    { 
     34        pisteLaskuri = new IntMeter(0); 
     35 
     36        Label pisteNaytto = new Label(); 
     37        pisteNaytto.X = Screen.Left + 375; 
     38        pisteNaytto.Y = Screen.Top - 45; 
     39        pisteNaytto.TextColor = Color.Black; 
     40        pisteNaytto.Color = Color.White; 
     41        pisteNaytto.Title = "Pisteet"; 
     42        pisteNaytto.BindTo(pisteLaskuri); 
     43        pisteLaskuri.MaxValue = 999999999; 
     44        Add(pisteNaytto); 
     45    } 
    2446 
    2547    public override void Begin() 
     
    2749        Gravity = new Vector(0, -1000); 
    2850 
    29          
     51        LuoPistelaskuri(); 
     52 
    3053 
    3154        LuoKentta(); 
    3255        LisaaNappaimet(); 
     56        LuoElamaLaskuri(); 
    3357 
    3458        Camera.Follow(pelaaja1); 
    3559        Camera.ZoomFactor = 1.2; 
    3660        Camera.StayInLevel = true; 
     61    } 
     62 
     63    void LuoElamaLaskuri() 
     64    { 
     65        elamaLaskuri = new DoubleMeter(10); 
     66        elamaLaskuri.MaxValue = 10; 
     67        elamaLaskuri.LowerLimit += ElamaLoppui; 
     68 
     69        ProgressBar elamaPalkki = new ProgressBar(150, 20); 
     70        elamaPalkki.X = Screen.Left + 250; 
     71        elamaPalkki.Y = Screen.Top - 20; 
     72        elamaPalkki.BindTo(elamaLaskuri); 
     73        Add(elamaPalkki); 
     74    } 
     75 
     76    void ElamaLoppui() 
     77    { 
     78        ClearAll(); 
     79        Begin(); 
    3780    } 
    3881 
     
    73116        vihu1.Image = vihukuva; 
    74117        vihu1.Tag = "vihollinen"; 
     118        Animation kavely = new Animation(vihuKavelee); 
     119        kavely.FPS = 5; 
     120        vihu1.AnimWalk = kavely; 
     121 
     122 
     123        PlatformWandererBrain tasoAivot = new PlatformWandererBrain(); 
     124        tasoAivot.Speed = 100; 
     125        tasoAivot.FallsOffPlatforms = true; 
     126        vihu1.Brain = tasoAivot; 
     127 
     128        Timer timer = new Timer(); 
     129        timer.Interval = 0.2; 
     130        timer.Timeout += delegate { 
     131            if (vihu1.IsDestroyed) 
     132            { 
     133                timer.Stop(); 
     134                return; 
     135            } 
     136            //if (Math.Abs(vihu1.Position.X - pelaaja1.Position.X) < 20 || Math.Abs(vihu1.Position.Y - pelaaja1.Position.Y) < RUUDUN_KOKO) 
     137            if (Vector.Distance(vihu1.Position, pelaaja1.Position) < RUUDUN_KOKO * 1.5) 
     138            { 
     139                elamaLaskuri.Value -= 1; 
     140            } 
     141        }; 
     142        timer.Start(); 
     143 
    75144        Add(vihu1); 
    76145    } 
    77146 
    78  
     147    void TormaaVihuun(PhysicsObject tormaaja, PhysicsObject kohde) 
     148    { 
     149        if (!pelaajaTormaa) 
     150        { 
     151            elamaLaskuri.Value -= 1; 
     152            pelaajaTormaa = true; 
     153            Timer.SingleShot(0.5, delegate { pelaajaTormaa = false; }); 
     154        } 
     155    } 
     156 
     157     
    79158 
    80159    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
     
    84163        pelaaja1.Mass = 4.0; 
    85164        pelaaja1.Image = pelaajanKuva; 
     165        pelaaja1.AnimIdle = new Animation(pelaajanKuva); 
     166        pelaaja1.AnimWalk = new Animation(pelaajaliikuKuvat); 
     167        pelaaja1.AnimWalk.FPS = 5; 
    86168        AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
     169        //AddCollisionHandler(pelaaja1, "vihollinen", TormaaVihuun); 
    87170        Add(pelaaja1); 
    88171 
     
    95178//pelaajan1Ase.Ammo.Value = 1000; 
    96179        pelaajan1Ase.InfiniteAmmo = true; 
    97  
     180        pelaajan1Ase.FireRate = 2.5; 
    98181//Mitä tapahtuu kun ammus osuu johonkin? 
    99182pelaajan1Ase.ProjectileCollision = AmmusOsui; 
     
    108191{ 
    109192    if (kohde.Tag != "tahti") { ammus.Destroy(); } 
    110      
    111 } 
    112  
    113    
    114  
    115     
    116  
     193    if (kohde.Tag == "vihollinen") { 
     194        TuhoaVihollinen(kohde); 
     195    } 
     196       
     197 
     198  } 
     199  void KranaattiOsui(IPhysicsObject rajahdyksenKohde, Vector v) 
     200  { 
     201      TuhoaVihollinen(rajahdyksenKohde); 
     202  } 
     203 
     204  void TuhoaVihollinen(IPhysicsObject vihu) 
     205  { 
     206      GameObject vihutuho = new GameObject(RUUDUN_KOKO, RUUDUN_KOKO + 10); 
     207      vihutuho.Position = vihu.Position; 
     208      vihutuho.Image = (vihutuhokuva); 
     209      Timer.SingleShot(0.6, delegate { vihutuho.Destroy(); }); 
     210      Add(vihutuho); 
     211      vihu.Destroy(); 
     212      pisteLaskuri.Value += 25; 
     213 
     214  } 
     215 
     216 
     217 
     218 
     219 
     220  void Heitakranu(PlatformCharacter pelaaja) 
     221  { 
     222      if (voikoheittaakranua) 
     223      { 
     224          Grenade kranu = new Grenade(4.0); 
     225          pelaaja.Throw(kranu, Angle.FromDegrees(30), 10000); 
     226          kranu.Explosion.AddShockwaveHandler("vihollinen", KranaattiOsui); 
     227          voikoheittaakranua = false; 
     228          Timer.SingleShot(3.5, delegate { voikoheittaakranua = true; }); 
     229      } 
     230       
     231  } 
    117232 
    118233 
     
    151266        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    152267        Keyboard.Listen(Key.Space, ButtonState.Down, AmmuAseella, "Ammu", pelaaja1); 
     268        Keyboard.Listen(Key.X, ButtonState.Pressed, Heitakranu, "Heitakranu", pelaaja1); 
    153269    } 
    154270    
     
    169285        MessageDisplay.Add("Keräsit tähden!"); 
    170286        tahti.Destroy(); 
     287        pisteLaskuri.Value += 10; 
    171288    } 
    172289} 
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip.csproj.Debug.cachefile

    r5815 r5827  
    22Content\norsu.xnb 
    33Content\tahti.xnb 
    4 Content\kentta1.xnb 
    54Content\Pelaaja_hahmo_tykki_kasi.xnb 
    65Content\Pelaaja_hahmo_tykki_kasi_move.xnb 
    76Content\energyshot.xnb 
    87Content\Vihu1.xnb 
     8Content\kentta1.xnb 
     9Content\Vihu1move.xnb 
     10Content\vihutuho.xnb 
     11Content\timantti.xnb 
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip/obj/x86/Debug/ContentPipeline-{D80F600A-7311-4ED4-989C-E68287FC5CE5}.xml

    r5815 r5827  
    99      <Options>None</Options> 
    1010      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\maali.xnb</Output> 
    11       <Time>2015-02-14T10:19:09.2626759+02:00</Time> 
     11      <Time>2015-04-18T10:06:37.7159791+03:00</Time> 
    1212    </Item> 
    1313    <Item> 
     
    1818      <Options>None</Options> 
    1919      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\norsu.xnb</Output> 
    20       <Time>2015-02-14T10:19:09.263676+02:00</Time> 
     20      <Time>2015-04-18T10:06:37.7939776+03:00</Time> 
    2121    </Item> 
    2222    <Item> 
     
    2727      <Options>None</Options> 
    2828      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\tahti.xnb</Output> 
    29       <Time>2015-02-14T10:19:09.2656762+02:00</Time> 
     29      <Time>2015-04-18T10:06:37.8563764+03:00</Time> 
     30    </Item> 
     31    <Item> 
     32      <Source>Pelaaja_hahmo_tykki_kasi.png</Source> 
     33      <Name>Pelaaja_hahmo_tykki_kasi</Name> 
     34      <Importer>TextureImporter</Importer> 
     35      <Processor>TextureProcessor</Processor> 
     36      <Options>None</Options> 
     37      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Pelaaja_hahmo_tykki_kasi.xnb</Output> 
     38      <Time>2015-04-18T10:06:37.8563764+03:00</Time> 
     39    </Item> 
     40    <Item> 
     41      <Source>Pelaaja_hahmo_tykki_kasi_move.png</Source> 
     42      <Name>Pelaaja_hahmo_tykki_kasi_move</Name> 
     43      <Importer>TextureImporter</Importer> 
     44      <Processor>TextureProcessor</Processor> 
     45      <Options>None</Options> 
     46      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Pelaaja_hahmo_tykki_kasi_move.xnb</Output> 
     47      <Time>2015-04-18T12:47:18.5919305+03:00</Time> 
     48    </Item> 
     49    <Item> 
     50      <Source>energyshot.png</Source> 
     51      <Name>energyshot</Name> 
     52      <Importer>TextureImporter</Importer> 
     53      <Processor>TextureProcessor</Processor> 
     54      <Options>None</Options> 
     55      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\energyshot.xnb</Output> 
     56      <Time>2015-04-18T10:06:37.7939776+03:00</Time> 
     57    </Item> 
     58    <Item> 
     59      <Source>Vihu1.png</Source> 
     60      <Name>Vihu1</Name> 
     61      <Importer>TextureImporter</Importer> 
     62      <Processor>TextureProcessor</Processor> 
     63      <Options>None</Options> 
     64      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Vihu1.xnb</Output> 
     65      <Time>2015-04-18T10:06:37.66918+03:00</Time> 
    3066    </Item> 
    3167    <Item> 
     
    3672      <Options>None</Options> 
    3773      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\kentta1.xnb</Output> 
    38       <Time>2015-03-14T13:38:14.7137287+02:00</Time> 
     74      <Time>2015-04-18T14:53:06.1457221+03:00</Time> 
    3975    </Item> 
    4076    <Item> 
    41       <Source>Pelaaja_hahmo_tykki_kasi.png</Source> 
    42       <Name>Pelaaja_hahmo_tykki_kasi</Name> 
     77      <Source>Vihu1move.png</Source> 
     78      <Name>Vihu1move</Name> 
    4379      <Importer>TextureImporter</Importer> 
    4480      <Processor>TextureProcessor</Processor> 
    4581      <Options>None</Options> 
    46       <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Pelaaja_hahmo_tykki_kasi.xnb</Output> 
    47       <Time>2015-02-14T11:56:17+02:00</Time> 
     82      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Vihu1move.xnb</Output> 
     83      <Time>2015-04-18T11:44:38.3317456+03:00</Time> 
    4884    </Item> 
    4985    <Item> 
    50       <Source>Pelaaja_hahmo_tykki_kasi_move.png</Source> 
    51       <Name>Pelaaja_hahmo_tykki_kasi_move</Name> 
     86      <Source>vihutuho.png</Source> 
     87      <Name>vihutuho</Name> 
    5288      <Importer>TextureImporter</Importer> 
    5389      <Processor>TextureProcessor</Processor> 
    5490      <Options>None</Options> 
    55       <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Pelaaja_hahmo_tykki_kasi_move.xnb</Output> 
    56       <Time>2015-02-14T11:20:40+02:00</Time> 
     91      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\vihutuho.xnb</Output> 
     92      <Time>2015-04-18T12:17:47.352451+03:00</Time> 
    5793    </Item> 
    5894    <Item> 
    59       <Source>energyshot.png</Source> 
    60       <Name>energyshot</Name> 
     95      <Source>timantti.png</Source> 
     96      <Name>timantti</Name> 
    6197      <Importer>TextureImporter</Importer> 
    6298      <Processor>TextureProcessor</Processor> 
    6399      <Options>None</Options> 
    64       <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\energyshot.xnb</Output> 
    65       <Time>2015-03-14T10:40:58.6206193+02:00</Time> 
    66     </Item> 
    67     <Item> 
    68       <Source>Vihu1.png</Source> 
    69       <Name>Vihu1</Name> 
    70       <Importer>TextureImporter</Importer> 
    71       <Processor>TextureProcessor</Processor> 
    72       <Options>None</Options> 
    73       <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Vihu1.xnb</Output> 
    74       <Time>2015-03-14T13:30:00.3765362+02:00</Time> 
     100      <Output>C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\timantti.xnb</Output> 
     101      <Time>2015-04-18T12:26:37.3329701+03:00</Time> 
    75102    </Item> 
    76103    <BuildSuccessful>true</BuildSuccessful> 
     
    121148      <Assembly> 
    122149        <Key>C:\Windows\Microsoft.Net\assembly\GAC_32\Microsoft.Xna.Framework.Content.Pipeline\v4.0_4.0.0.0__842cf8be1de50553\Microsoft.Xna.Framework.Content.Pipeline.dll</Key> 
    123         <Value>2014-04-23T00:45:54.1262189+03:00</Value> 
     150        <Value>2012-07-09T09:25:46.7449733+03:00</Value> 
    124151      </Assembly> 
    125152    </Assemblies> 
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip/obj/x86/Debug/Work_in_progress_wip.csproj.FileListAbsolute.txt

    r5815 r5827  
    1515C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\energyshot.xnb 
    1616C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Vihu1.xnb 
     17C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\Vihu1move.xnb 
     18C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\vihutuho.xnb 
     19C:\MyTemp\EetuR\Work_in_progress_wip\Work_in_progress_wip\Work_in_progress_wip\bin\x86\Debug\Content\timantti.xnb 
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wip/obj/x86/Debug/cachefile-{D80F600A-7311-4ED4-989C-E68287FC5CE5}-targetpath.txt

    r5815 r5827  
    22Content\norsu.xnb 
    33Content\tahti.xnb 
    4 Content\kentta1.xnb 
    54Content\Pelaaja_hahmo_tykki_kasi.xnb 
    65Content\Pelaaja_hahmo_tykki_kasi_move.xnb 
    76Content\energyshot.xnb 
    87Content\Vihu1.xnb 
     8Content\kentta1.xnb 
     9Content\Vihu1move.xnb 
     10Content\vihutuho.xnb 
     11Content\timantti.xnb 
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wipContent/Work_in_progress_wipContent.contentproj

    r5815 r5827  
    9595    </Compile> 
    9696  </ItemGroup> 
     97  <ItemGroup> 
     98    <Compile Include="Vihu1move.png"> 
     99      <Name>Vihu1move</Name> 
     100      <Importer>TextureImporter</Importer> 
     101      <Processor>TextureProcessor</Processor> 
     102    </Compile> 
     103  </ItemGroup> 
     104  <ItemGroup> 
     105    <Compile Include="vihutuho.png"> 
     106      <Name>vihutuho</Name> 
     107      <Importer>TextureImporter</Importer> 
     108      <Processor>TextureProcessor</Processor> 
     109    </Compile> 
     110  </ItemGroup> 
     111  <ItemGroup> 
     112    <Compile Include="timantti.png"> 
     113      <Name>timantti</Name> 
     114      <Importer>TextureImporter</Importer> 
     115      <Processor>TextureProcessor</Processor> 
     116    </Compile> 
     117  </ItemGroup> 
    97118  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    98119  <!--  To modify your build process, add your task inside one of the targets below and uncomment it.  
  • 2014/koodauskerho/38/EetuR/Work_in_progress_wip/Work_in_progress_wip/Work_in_progress_wipContent/kentta1.txt

    r5815 r5827  
    1 ......................................................................... 
    2 ......................................................................... 
    3 ......................................................................... 
    4 ......................................................................... 
    5 ......................................................................... 
    6 ......................................................................... 
    7 ......................................................................... 
    8 ......................................................................... 
    9 ......................................................................... 
    10 ......................................................................... 
    11 ...............*......................................................... 
    12 ......................................................................... 
    13 ......................................................................... 
    14 ......................................................................... 
    15 .....................##..1......*.......*......1...1..................... 
    16 ...............#.......###...#####..*..#####...#####...#.......1#........ 
    17 ..............###...............*.......*..............##......##........ 
    18 ..........#..#####..#...............P..................###....###........ 
    19 ######################################################################### 
     1......................................................................................... 
     2..........................***............................................................ 
     3..........................***............................................................ 
     4..........................###*........................................................... 
     5......................................................................................... 
     6.......................#......*..............................................*........... 
     7..............................**....................................***....##....*....... 
     8...............................*....................................###.......##......... 
     9...........#..#..#..#.............................................................##..... 
     10........#...............................................................................# 
     11.......##......*.......................................................................## 
     12......##...................................................*..........*...1..*........### 
     13...#......................................................###............##........###### 
     14#..........................*.....*.....*.....*........................#.....1#....#...... 
     15##1....1.......1.....##..1......##.....##......1...1.................###....###.......... 
     16###..###.......#......*###...###....P....###...#####...#...*...1#....*.##..##.*.......... 
     17#.*..*.#......###...................#..................##......##........................ 
     18#*....*#..#..#####..#..............###.................###....###*.#............#.*...... 
     19######################################################################################### 
Note: See TracChangeset for help on using the changeset viewer.