Ignore:
Timestamp:
2015-07-23 15:03:02 (8 years ago)
Author:
misakana
Message:
 
Location:
2015/30/SamuelL/jotain/jotain
Files:
10 added
4 deleted
7 edited

Legend:

Unmodified
Added
Removed
  • 2015/30/SamuelL/jotain/jotain/jotain/jotain.cs

    r6938 r6995  
    1414 
    1515    PlatformCharacter pelaaja1; 
     16    AssaultRifle ase1; 
     17    bool ase1Flipattu = false; 
    1618 
    1719    Image pelaajanKuva = LoadImage("pelaajakuva"); 
     
    2527    Image Pimeyskuva = LoadImage("pimeys"); 
    2628    Image valokuva = LoadImage("valokuva"); 
    27     Image Luola = LoadImage("luola"); 
     29    Image luolapaikka = LoadImage("luolapaikka"); 
     30    Image Isokivi = LoadImage("kivi2"); 
     31    Image pienikivi = LoadImage("kivi"); 
     32    Image puu = LoadImage("puuu"); 
     33    Image Asekuva = LoadImage("GUN"); 
     34    Image Tähtäin = LoadImage("tähtäin"); 
     35 
    2836    int kenttänumero = 1; 
    2937 
     
    3240    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    3341    SoundEffect TuliPalo = LoadSoundEffect("tuli"); 
     42    SoundEffect pistolshot = LoadSoundEffect("PistolShot"); 
    3443 
    3544    public override void Begin() 
     
    4150    void LuoKentta() 
    4251    { 
    43         TileMap kentta = TileMap.FromLevelAsset("kentta"+kenttänumero); 
     52        TileMap kentta = TileMap.FromLevelAsset("kentta" + kenttänumero); 
    4453        kentta.SetTileMethod('#', LisaaTaso); 
    4554        kentta.SetTileMethod('*', LisaaTahti); 
     
    5059        kentta.SetTileMethod('T', Lisaatuli); 
    5160        kentta.SetTileMethod('V', LisaaVaihto); 
     61        kentta.SetTileMethod('O', Lisaakivi, Isokivi, 1); 
     62        kentta.SetTileMethod('o', Lisaakivi, pienikivi, -1); 
     63        kentta.SetTileMethod('p', Lisaapuu, puu, 1); 
    5264        kentta.Execute(RUUDUN_KOKO, RUUDUN_KOKO); 
    5365        kentta.Optimize('#'); 
    54         Level.CreateBorders(); 
    5566        if (kenttänumero == 1) 
    5667        { 
     
    5970        else if (kenttänumero == 2) 
    6071        { 
    61             Level.Background.Image = Luola; 
     72            Level.Background.Image = luolapaikka; 
    6273        } 
    6374        Level.Background.FitToLevel(); 
     
    7182        taso.Position = paikka; 
    7283        taso.IsVisible = true; 
     84        taso.Tag = "taso"; 
    7385        Add(taso); 
    7486        taso.Color = Color.Black; 
    7587    } 
    76     void LisaaKasvi(Vector paikka, double leveys, double korkeus,Image kuva,int taso) 
    77     { 
    78         GameObject kasvi = new GameObject(leveys*1.5,korkeus*3); 
    79         kasvi.Position = paikka + new Vector (0, 0); 
    80         Add(kasvi,taso); 
     88    void LisaaKasvi(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 
     89    { 
     90        GameObject kasvi = new GameObject(leveys * 1.5, korkeus * 3); 
     91        kasvi.Position = paikka + new Vector(0, 0); 
     92        Add(kasvi, taso); 
    8193        kasvi.Image = kuva; 
    8294 
     
    88100    } 
    89101 
    90     void Lisaaruoho(Vector paikka, double leveys, double korkeus,Image kuva,int taso) 
    91     { 
    92         GameObject ruoho = new GameObject(leveys,korkeus); 
    93         ruoho.Position = paikka + new Vector (); 
    94         Add(ruoho,taso); 
     102    void Lisaaruoho(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 
     103    { 
     104        GameObject ruoho = new GameObject(leveys, korkeus); 
     105        ruoho.Position = paikka + new Vector(); 
     106        Add(ruoho, taso); 
    95107        ruoho.Image = kuva; 
    96108 
     
    109121    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    110122    { 
    111         pelaaja1 = new PlatformCharacter(leveys*1.5, korkeus*1.5); 
     123        pelaaja1 = new PlatformCharacter(leveys * 1.5, korkeus * 1.5); 
    112124        pelaaja1.Position = paikka; 
    113125        pelaaja1.Mass = 4.0; 
    114126        pelaaja1.Image = pelaajanKuva; 
     127        pelaaja1.Tag = "pelaaja1"; 
    115128        pelaaja1.AnimWalk = kävely; 
    116129        pelaaja1.AnimIdle = new Animation(pelaajanKuva); 
     
    121134 
    122135        GameObject pimeys = new GameObject(2700, 2700); 
     136        pimeys.IsVisible = true; 
    123137        pimeys.Image = Pimeyskuva; 
    124         Add(pimeys,2); 
     138        Add(pimeys, 2); 
    125139        Timer ajastin = new Timer(); 
    126140        ajastin.Interval = 0.05; 
     
    130144        }; 
    131145        ajastin.Start(); 
     146 
     147        ase1 = new AssaultRifle(Asekuva.Width, Asekuva.Height); 
     148        ase1.Image = Asekuva; 
     149        ase1.Size *= 0.1; 
     150        ase1.Power.Value = 2000; 
     151        ase1.FireRate = 2.0; 
     152        ase1.Tag = "ase"; 
     153        ase1.AttackSound = pistolshot; 
     154 
     155 
     156 
     157 
     158        Add(ase1); 
    132159    } 
    133160 
     
    137164        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    138165 
    139         Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
    140         Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    141         Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     166        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     167        Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
     168        Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     169        Mouse.Listen(MouseButton.Left, ButtonState.Down, ammuaseella, "Liikkuu vasemmalle"); 
     170 
    142171 
    143172        ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    144173 
    145         ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 
    146         ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 
    147         ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     174        ControllerOne.Listen(Button.A, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 
     175        ControllerOne.Listen(Button.B, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 
     176        ControllerOne.Listen(Button.BigButton, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
     177        Mouse.IsCursorVisible = false; 
     178 
     179 
     180 
     181        GameObject hiiri = new GameObject(Tähtäin); 
     182        hiiri.Size *= 0.1; 
     183        Add(hiiri, 3); 
     184         
     185        Timer hiiriAjastin = new Timer(); 
     186        hiiriAjastin.Interval = 0.01; 
     187        hiiriAjastin.Timeout += delegate 
     188        { 
     189            hiiri.Position = Mouse.PositionOnWorld; 
     190        }; 
     191        hiiriAjastin.Start(); 
     192 
     193        Mouse.ListenMovement(0.0, KaannetaanAsetta, ""); 
    148194 
    149195        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     196    } 
     197    void KaannetaanAsetta(AnalogState hiirenTila) 
     198    { 
     199        Vector suunta = Mouse.PositionOnWorld - pelaaja1.Position; 
     200        ase1.Position = pelaaja1.Position + suunta.Normalize() * 30; 
     201        ase1.Angle = suunta.Angle; 
     202 
     203        double kulma = suunta.Angle.Degrees; 
     204         
     205        if (kulma < 90 && kulma > -90) 
     206        { 
     207            if (ase1Flipattu) 
     208            { 
     209                ase1.FlipImage(); 
     210                ase1Flipattu = false; 
     211            } 
     212        } 
     213        else 
     214        { 
     215            if (!ase1Flipattu) 
     216            { 
     217                ase1.FlipImage(); 
     218                ase1Flipattu = true; 
     219            } 
     220        } 
     221 
    150222    } 
    151223 
     
    213285        Camera.ZoomFactor = 1.2; 
    214286        Camera.StayInLevel = true; 
    215     } 
    216     void tormaavaihtoon(PhysicsObject pelaaja,PhysicsObject vaihto) 
     287 
     288        if (kenttänumero == 1) 
     289        { 
     290            MediaPlayer.Play("tuli"); 
     291            MediaPlayer.IsRepeating = true; 
     292        } 
     293        else if (kenttänumero == 2) 
     294        { 
     295            MediaPlayer.Stop(); 
     296        } 
     297    } 
     298    void tormaavaihtoon(PhysicsObject pelaaja, PhysicsObject vaihto) 
    217299    { 
    218300        VaihdaKenttaa(); 
     
    221303 
    222304    } 
     305    void Lisaakivi(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 
     306    { 
     307        GameObject Isokivi = new GameObject(leveys * 1, korkeus * 1); 
     308        Isokivi.Position = paikka + new Vector(0, 0); 
     309        Add(Isokivi, taso); 
     310        Isokivi.Image = kuva; 
     311 
     312    } 
     313    void Lisaapuu(Vector paikka, double leveys, double korkeus, Image kuva, int taso) 
     314    { 
     315        GameObject puu = new GameObject(leveys * 3, korkeus * 3); 
     316        puu.Position = paikka + new Vector(0, 0); 
     317        Add(puu, taso); 
     318        puu.Image = kuva; 
     319 
     320 
     321 
     322    } 
     323    void ammuaseella() 
     324    { 
     325        PhysicsObject ammus = ase1.Shoot(); 
     326 
     327        if (ammus != null) 
     328        { 
     329            ammus.MaximumLifetime = TimeSpan.FromSeconds(5); 
     330             
     331            AddCollisionHandler(ammus, "taso", delegate(PhysicsObject a, PhysicsObject b)  
     332            { 
     333                ammus.Destroy();  
     334            }); 
     335        } 
     336    } 
     337 
    223338} 
  • 2015/30/SamuelL/jotain/jotain/jotain/jotain.csproj.Debug.cachefile

    r6938 r6995  
    88Content\tausta 1.xnb 
    99Content\kÀvely loulassa.xnb 
    10 Content\tuli.xnb 
    1110Content\kÀvely ruohossa.xnb 
    12 Content\kivi 2.xnb 
    13 Content\kivi.xnb 
    14 Content\luola.xnb 
    1511Content\spooky.xnb 
    1612Content\tulikuva.xnb 
     
    3228Content\pelaaja\pelaaja9_0.xnb 
    3329Content\pelaajaputoaa.xnb 
     30Content\tuli.xnb 
     31Content\luolapaikka.xnb 
     32Content\kivi2.xnb 
     33Content\puu.xnb 
     34Content\puuu.xnb 
     35Content\GUN.xnb 
     36Content\tÀhtÀin.xnb 
     37Content\PistolShot.xnb 
     38Content\tuli.wma 
  • 2015/30/SamuelL/jotain/jotain/jotainContent/jotainContent.contentproj

    r6938 r6995  
    6868  </ItemGroup> 
    6969  <ItemGroup> 
    70     <Compile Include="tausta - kasvit 2.png"> 
    71       <Name>tausta - kasvit 2</Name> 
    72       <Importer>TextureImporter</Importer> 
    73       <Processor>TextureProcessor</Processor> 
    74     </Compile> 
    75   </ItemGroup> 
    76   <ItemGroup> 
    7770    <Compile Include="tausta - kasvi 1.png"> 
    7871      <Name>tausta - kasvi 1</Name> 
     
    9689  </ItemGroup> 
    9790  <ItemGroup> 
    98     <Compile Include="kivi 2.png"> 
    99       <Name>kivi 2</Name> 
    100       <Importer>TextureImporter</Importer> 
    101       <Processor>TextureProcessor</Processor> 
    102     </Compile> 
    103     <Compile Include="kivi.png"> 
    104       <Name>kivi</Name> 
    105       <Importer>TextureImporter</Importer> 
    106       <Processor>TextureProcessor</Processor> 
    107     </Compile> 
    108     <Compile Include="luola.png"> 
    109       <Name>luola</Name> 
     91    <Compile Include="kivi2.png"> 
     92      <Name>kivi2</Name> 
    11093      <Importer>TextureImporter</Importer> 
    11194      <Processor>TextureProcessor</Processor> 
     
    11598    <Compile Include="kävely loulassa.wav"> 
    11699      <Name>kävely loulassa</Name> 
    117       <Importer>WavImporter</Importer> 
    118       <Processor>SoundEffectProcessor</Processor> 
    119     </Compile> 
    120     <Compile Include="tuli.wav"> 
    121       <Name>tuli</Name> 
    122100      <Importer>WavImporter</Importer> 
    123101      <Processor>SoundEffectProcessor</Processor> 
     
    185163      <Importer>TextureImporter</Importer> 
    186164      <Processor>TextureProcessor</Processor> 
     165    </Compile> 
     166  </ItemGroup> 
     167  <ItemGroup> 
     168    <Compile Include="tuli.mp3"> 
     169      <Name>tuli</Name> 
     170      <Importer>Mp3Importer</Importer> 
     171      <Processor>SongProcessor</Processor> 
     172    </Compile> 
     173  </ItemGroup> 
     174  <ItemGroup> 
     175    <Compile Include="luolapaikka.png"> 
     176      <Name>luolapaikka</Name> 
     177      <Importer>TextureImporter</Importer> 
     178      <Processor>TextureProcessor</Processor> 
     179    </Compile> 
     180  </ItemGroup> 
     181  <ItemGroup> 
     182    <Compile Include="tausta - kasvit 2.png"> 
     183      <Name>tausta - kasvit 2</Name> 
     184      <Importer>TextureImporter</Importer> 
     185      <Processor>TextureProcessor</Processor> 
     186    </Compile> 
     187  </ItemGroup> 
     188  <ItemGroup> 
     189    <Compile Include="puu.png"> 
     190      <Name>puu</Name> 
     191      <Importer>TextureImporter</Importer> 
     192      <Processor>TextureProcessor</Processor> 
     193    </Compile> 
     194  </ItemGroup> 
     195  <ItemGroup> 
     196    <Compile Include="puuu.png"> 
     197      <Name>puuu</Name> 
     198      <Importer>TextureImporter</Importer> 
     199      <Processor>TextureProcessor</Processor> 
     200    </Compile> 
     201  </ItemGroup> 
     202  <ItemGroup> 
     203    <Compile Include="GUN.png"> 
     204      <Name>GUN</Name> 
     205      <Importer>TextureImporter</Importer> 
     206      <Processor>TextureProcessor</Processor> 
     207    </Compile> 
     208  </ItemGroup> 
     209  <ItemGroup> 
     210    <Compile Include="tähtäin.png"> 
     211      <Name>tähtäin</Name> 
     212      <Importer>TextureImporter</Importer> 
     213      <Processor>TextureProcessor</Processor> 
     214    </Compile> 
     215  </ItemGroup> 
     216  <ItemGroup> 
     217    <Compile Include="PistolShot.wav"> 
     218      <Name>PistolShot</Name> 
     219      <Importer>WavImporter</Importer> 
     220      <Processor>SoundEffectProcessor</Processor> 
    187221    </Compile> 
    188222  </ItemGroup> 
  • 2015/30/SamuelL/jotain/jotain/jotainContent/kentta1.txt

    r6938 r6995  
    55 
    66 
    7             
     7#           
    88# 
    99#T       N      k   K 
    1010# TT rrrrrrrrrrrrrrr 
    1111####################         
    12 ####################  
    13 ####################  
    14 ####################  
    15 ####################  
    16 ####################  
    17 ####################          
     12####################                  
     13####################                 
     14####################                 
     15####################                 
     16####################                 
     17####################                 
    1818####################VVVVVVVVVVVVVVVV 
  • 2015/30/SamuelL/jotain/jotain/jotainContent/kentta2.txt

    r6938 r6995  
    1         
    2     
    3         
    4          
     1                    #      N      # 
     2                    #             #          
     3                  ##              ####                        
     4                ###                  ###### 
     5#     ##### #####                        #### ###### 
     6 ###########                                 ## #   ######### 
     7                                                         #### 
    58 
    69 
    7             
    8     
    9     
    10     
    11     
    12     
    13     
    14     
    15     
    16     
    17     
    18     
    19     
    20     
    21                                          
     10 
     11 
     12 
     13        K         p        k                  K                
     14                                  O 
     15############################################################## 
Note: See TracChangeset for help on using the changeset viewer.