Changeset 4276


Ignore:
Timestamp:
2013-06-27 14:56:47 (10 years ago)
Author:
rotaraih
Message:

Talletus.

Location:
2013/26/RoopeR
Files:
18 added
4 edited

Legend:

Unmodified
Added
Removed
  • 2013/26/RoopeR/The Random game/The Random game/The Random game/The_Random_game.cs

    r4233 r4276  
    99public class The_Random_game : PhysicsGame 
    1010{ 
    11  
    12     const double nopeus = 200; 
    13     const double hyppyNopeus = 3000; 
     11    ScoreList topLista = new ScoreList(10, false, 0); 
     12 
     13    const double nopeus = 100; 
     14    const double hyppyNopeus = 2000; 
    1415    const int RUUDUN_KOKO = 60; 
    1516    int kenttaNro = 1; 
     17    int maara = 0; 
    1618    PlatformCharacter pelaaja1; 
    1719 
    18  
    19     Image tahtiKuva = LoadImage("tahti"); 
     20    IntMeter pisteLaskuri; 
     21 
     22    Image kerattavaKuva = LoadImage("kerattava"); 
    2023    Image esteKuva = LoadImage("Este"); 
    2124    Image pelaajakuva = LoadImage("pelaaja"); 
    2225    Image maalikuva = LoadImage("Untitled"); 
    23      
     26 
    2427    SoundEffect maaliAani = LoadSoundEffect("maali"); 
    2528 
    2629    public override void Begin() 
    2730    { 
     31        alkuvalikko(); 
     32 
     33 
     34        
     35    } 
     36    
     37 
     38    void alkuvalikko() 
     39    { 
     40        MultiSelectWindow alkuValikko = new MultiSelectWindow("The Random Game", "Start game", "exit"); 
     41        Add(alkuValikko); 
     42        alkuValikko.AddItemHandler(0, SeuraavaKentta); 
     43        //alkuValikko.AddItemHandler(1, ParhaatPisteet); 
     44        alkuValikko.AddItemHandler(1, Exit); 
     45    } 
     46 
     47    void TormaaMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 
     48    { 
     49        if (maara == 0) 
     50        { 
     51            kenttaNro++; 
     52            SeuraavaKentta(); 
     53        } 
     54    } 
     55    void SeuraavaKentta() 
     56    { 
     57        ClearAll(); 
     58        maara = 0; 
     59        if (kenttaNro > 17) Exit(); 
     60        else LuoKentta("kentta" + kenttaNro); 
     61        //if (kenttaNro == 1) LuoKentta("kentta1"); 
     62        //else if (kenttaNro == 2) LuoKentta("kentta2"); 
     63        //else if (kenttaNro == 3) LuoKentta("kentta3"); 
     64        //else if (kenttaNro == 4) LuoKentta("kentta4"); 
     65        //else if (kenttaNro == 5) LuoKentta("kentta5"); 
     66        //else if (kenttaNro == 6) LuoKentta("kentta6"); 
     67        //else if (kenttaNro == 7) LuoKentta("kentta7"); 
     68        //else if (kenttaNro == 8) LuoKentta("kentta8"); 
     69        //else if (kenttaNro == 9) LuoKentta("kentta9"); 
     70        //else if (kenttaNro == 10) LuoKentta("kentta10"); 
     71        //else if (kenttaNro == 11) LuoKentta("kentta11"); 
     72        //else if (kenttaNro == 12) LuoKentta("kentta12"); 
     73        //else if (kenttaNro == 13) LuoKentta("kentta13"); 
     74        //else if (kenttaNro == 14) LuoKentta("kentta14"); 
     75        //else if (kenttaNro == 15) LuoKentta("kentta15"); 
     76        //else if (kenttaNro == 16) LuoKentta("kentta16"); 
     77        //else if (kenttaNro == 17) LuoKentta("kentta17"); 
     78        //else if (kenttaNro > 17) Exit(); 
     79 
    2880        Gravity = new Vector(0, -3000); 
    2981 
    30         SeuraavaKentta(); 
    3182        LisaaNappaimet(); 
     83        LuoPistelaskuri(); 
     84        LuoAikaLaskuri(); 
    3285 
    3386        Camera.Follow(pelaaja1); 
    3487        Camera.ZoomFactor = 1.2; 
    3588        Camera.StayInLevel = true; 
    36     } 
    37  
    38     void TormaaMaaliin(PhysicsObject pelaaja, PhysicsObject maali) 
    39     { 
    40  
    41     } 
    42     void SeuraavaKentta() 
    43     { 
    44         if (kenttaNro == 1) LuoKentta("kentta1"); 
    45         else if (kenttaNro == 2) LuoKentta("kentta2"); 
    46         else if (kenttaNro == 3) LuoKentta("kentta3"); 
    47         else if (kenttaNro > 3) Exit(); 
    4889    } 
    4990 
     
    89130    void LisaaEste(Vector paikka, double leveys, double korkeus) 
    90131    { 
    91         PhysicsObject este = PhysicsObject.CreateStaticObject(leveys * 1.5, korkeus); 
     132        PhysicsObject este = PhysicsObject.CreateStaticObject(leveys / 2, korkeus / 2); 
    92133        este.Image = esteKuva; 
    93134        este.Shape = Shape.FromImage(esteKuva); 
     
    95136        este.Color = Color.Magenta; 
    96137        Add(este); 
    97         este.Restitution = (5.0); 
     138        este.Restitution = (1.0); 
    98139 
    99140    } 
     
    104145        tahti.IgnoresCollisionResponse = true; 
    105146        tahti.Position = paikka; 
    106         tahti.Image = tahtiKuva; 
     147        tahti.Image = kerattavaKuva; 
    107148        tahti.Tag = "random"; 
    108149        Add(tahti); 
    109         tahti.Restitution = (2.0); 
     150        tahti.Restitution = (0.0); 
     151        maara++; 
    110152    } 
    111153 
    112154    void LisaaPelaaja(Vector paikka, double leveys, double korkeus) 
    113155    { 
    114         pelaaja1 = new PlatformCharacter(leveys, korkeus); 
     156        pelaaja1 = new PlatformCharacter(leveys / 2, korkeus / 2); 
    115157        pelaaja1.Position = paikka; 
    116158        pelaaja1.Mass = 5.0; 
    117         pelaaja1.Restitution = 5.0; 
     159        pelaaja1.Restitution = 1.0; 
    118160        pelaaja1.Image = pelaajakuva; 
    119         AddCollisionHandler(pelaaja1, "tahti", TormaaTahteen); 
     161        AddCollisionHandler(pelaaja1, "random", TormaaTahteen); 
    120162        AddCollisionHandler(pelaaja1, "maali", TormaaMaaliin); 
    121163        Add(pelaaja1); 
    122         pelaaja1.LifetimeLeft = TimeSpan.FromSeconds(60.0); 
    123         pelaaja1.Push(new Vector(1000, 0)); 
    124     } 
    125      
     164        pelaaja1.LifetimeLeft = TimeSpan.FromSeconds(60); 
     165        pelaaja1.Push(new Vector(1, 0)); 
     166    } 
     167 
    126168 
    127169 
     
    130172        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    131173        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    132  
     174        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
     175        Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
     176        Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "pelaaja hyppää", pelaaja1, hyppyNopeus); 
    133177        Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, -nopeus); 
    134178        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, "Liikkuu vasemmalle", pelaaja1, nopeus); 
    135179        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    136180        Keyboard.Listen(Key.P, ButtonState.Pressed, Pause, "Pysäyttää pelin"); 
    137         ControllerOne.Listen(Button.Back, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    138  
    139         ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, "Pelaaja liikkuu vasemmalle", pelaaja1, -nopeus); 
    140         ControllerOne.Listen(Button.DPadRight, ButtonState.Down, Liikuta, "Pelaaja liikkuu oikealle", pelaaja1, nopeus); 
    141         ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Pelaaja hyppää", pelaaja1, hyppyNopeus); 
    142  
    143         PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    144     } 
     181        Keyboard.Listen(Key.Enter, ButtonState.Pressed, SeuraavaKentta, "Aloittaa kentän uudestaan"); 
     182 
     183        ControllerOne.ListenAnalog(AnalogControl.LeftStick, 0.1, 
     184   LiikutaTatilla, "Liikuta pelaajaa tattia pyörittämällä.", pelaaja1, 1000.0); 
     185        ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, Liikuta, null, pelaaja1, -100.0); 
     186        ControllerOne.Listen(Button.DPadRight, ButtonState.Down, 
     187          Liikuta, null, pelaaja1, 100.0); 
     188        ControllerOne.Listen(Button.DPadUp, ButtonState.Down, 
     189          Hyppaa, null, pelaaja1, 1000.0); 
     190        ControllerOne.Listen(Button.A, ButtonState.Pressed, Hyppaa, "Hyppää", pelaaja1, 1000.0); 
     191 
     192    } 
     193 
     194    void LiikutaTatilla(AnalogState a, PlatformCharacter pelaaja, double voima) 
     195    { 
     196        Vector tatinAsento = a.StateVector; 
     197        //if (tatinAsento.Y > 0) pelaaja.Jump(voima*2); 
     198        pelaaja.Walk(tatinAsento.X * voima); 
     199 
     200    } 
     201 
    145202 
    146203    void Liikuta(PlatformCharacter hahmo, double nopeus) 
     
    157214    { 
    158215        // maaliAani.Play(); 
    159         MessageDisplay.Add("Onnea keräsit tähden!!! :)"); 
     216        MessageDisplay.Add("Onnea keräsit merkin!!! :)"); 
    160217        tahti.Destroy(); 
    161     } 
    162 } 
     218        pisteLaskuri.Value++; 
     219        maara--; 
     220    } 
     221 
     222    void LuoPistelaskuri() 
     223    { 
     224        pisteLaskuri = new IntMeter(0); 
     225 
     226        Label pisteNaytto = new Label(); 
     227        pisteNaytto.X = Screen.Right - 100; 
     228        pisteNaytto.Y = Screen.Top - 100; 
     229        pisteNaytto.TextColor = Color.Black; 
     230        pisteNaytto.Color = Color.HotPink; 
     231        pisteNaytto.Title = "Pisteet"; 
     232        pisteNaytto.BindTo(pisteLaskuri); 
     233        Add(pisteNaytto); 
     234 
     235    } 
     236 
     237 
     238    void LuoAikaLaskuri() 
     239    { 
     240        Timer aikaLaskuri = new Timer(); 
     241        //aikaLaskuri.Interval = 30.0; 
     242        aikaLaskuri.GetType().GetField("trigInterval", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.GetField | System.Reflection.BindingFlags.Instance).SetValue(aikaLaskuri, TimeSpan.FromSeconds(300)); 
     243        aikaLaskuri.Timeout += AikaLoppui; 
     244        aikaLaskuri.Start(1); 
     245              
     246 
     247        Label aikaNaytto = new Label(); 
     248        aikaNaytto.TextColor = Color.Black; 
     249        aikaNaytto.DecimalPlaces = 1; 
     250        aikaNaytto.X = Screen.Right - 100; 
     251        aikaNaytto.Y = Screen.Top - 200; 
     252        aikaNaytto.BindTo(aikaLaskuri.SecondCounter); 
     253        Add(aikaNaytto); 
     254    } 
     255 
     256    void AikaLoppui() 
     257    { 
     258        MessageDisplay.Add("Aika loppui..."); 
     259        SeuraavaKentta(); 
     260 
     261    } 
     262 
     263    } 
     264 
     265 
     266 
    163267     
    164  
    165      
  • 2013/26/RoopeR/The Random game/The Random game/The Random gameContent/The Random gameContent.contentproj

    r4233 r4276  
    5656      <Processor>TextureProcessor</Processor> 
    5757    </Compile> 
     58    <Compile Include="pelaaja.png"> 
     59      <Name>pelaaja</Name> 
     60      <Importer>TextureImporter</Importer> 
     61      <Processor>TextureProcessor</Processor> 
     62    </Compile> 
    5863    <Compile Include="tahti.png"> 
    5964      <Name>tahti</Name> 
     
    7681  </ItemGroup> 
    7782  <ItemGroup> 
    78     <Compile Include="pelaaja.png"> 
    79       <Name>pelaaja</Name> 
    80       <Importer>TextureImporter</Importer> 
    81       <Processor>TextureProcessor</Processor> 
    82     </Compile> 
    83   </ItemGroup> 
    84   <ItemGroup> 
    8583    <Compile Include="Untitled.png"> 
    8684      <Name>Untitled</Name> 
    8785      <Importer>TextureImporter</Importer> 
    8886      <Processor>TextureProcessor</Processor> 
     87    </Compile> 
     88  </ItemGroup> 
     89  <ItemGroup> 
     90    <Compile Include="kerattava.png"> 
     91      <Name>kerattava</Name> 
     92      <Importer>TextureImporter</Importer> 
     93      <Processor>TextureProcessor</Processor> 
     94    </Compile> 
     95  </ItemGroup> 
     96  <ItemGroup> 
     97    <Compile Include="kentta2.txt"> 
     98      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     99      <Name>kentta2</Name> 
     100      <Importer>TextFileImporter</Importer> 
     101      <Processor>TextFileContentProcessor</Processor> 
     102    </Compile> 
     103  </ItemGroup> 
     104  <ItemGroup> 
     105    <Compile Include="kentta3.txt"> 
     106      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     107      <Name>kentta3</Name> 
     108      <Importer>TextFileImporter</Importer> 
     109      <Processor>TextFileContentProcessor</Processor> 
     110    </Compile> 
     111  </ItemGroup> 
     112  <ItemGroup> 
     113    <Compile Include="kentta4.txt"> 
     114      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     115      <Name>kentta4</Name> 
     116      <Importer>TextFileImporter</Importer> 
     117      <Processor>TextFileContentProcessor</Processor> 
     118    </Compile> 
     119  </ItemGroup> 
     120  <ItemGroup> 
     121    <Compile Include="kentta5.txt"> 
     122      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     123      <Name>kentta5</Name> 
     124      <Importer>TextFileImporter</Importer> 
     125      <Processor>TextFileContentProcessor</Processor> 
     126    </Compile> 
     127  </ItemGroup> 
     128  <ItemGroup> 
     129    <Compile Include="kentta6.txt"> 
     130      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     131      <Name>kentta6</Name> 
     132      <Importer>TextFileImporter</Importer> 
     133      <Processor>TextFileContentProcessor</Processor> 
     134    </Compile> 
     135  </ItemGroup> 
     136  <ItemGroup> 
     137    <Compile Include="kentta7.txt"> 
     138      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     139      <Name>kentta7</Name> 
     140      <Importer>TextFileImporter</Importer> 
     141      <Processor>TextFileContentProcessor</Processor> 
     142    </Compile> 
     143  </ItemGroup> 
     144  <ItemGroup> 
     145    <Compile Include="kentta8.txt"> 
     146      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     147      <Name>kentta8</Name> 
     148      <Importer>TextFileImporter</Importer> 
     149      <Processor>TextFileContentProcessor</Processor> 
     150    </Compile> 
     151  </ItemGroup> 
     152  <ItemGroup> 
     153    <Compile Include="kentta9.txt"> 
     154      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     155      <Name>kentta9</Name> 
     156      <Importer>TextFileImporter</Importer> 
     157      <Processor>TextFileContentProcessor</Processor> 
     158    </Compile> 
     159  </ItemGroup> 
     160  <ItemGroup> 
     161    <Compile Include="kentta10.txt"> 
     162      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     163      <Name>kentta10</Name> 
     164      <Importer>TextFileImporter</Importer> 
     165      <Processor>TextFileContentProcessor</Processor> 
     166    </Compile> 
     167  </ItemGroup> 
     168  <ItemGroup> 
     169    <Compile Include="kentta11.txt"> 
     170      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     171      <Name>kentta11</Name> 
     172      <Importer>TextFileImporter</Importer> 
     173      <Processor>TextFileContentProcessor</Processor> 
     174    </Compile> 
     175  </ItemGroup> 
     176  <ItemGroup> 
     177    <Compile Include="kentta12.txt"> 
     178      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     179      <Name>kentta12</Name> 
     180      <Importer>TextFileImporter</Importer> 
     181      <Processor>TextFileContentProcessor</Processor> 
     182    </Compile> 
     183  </ItemGroup> 
     184  <ItemGroup> 
     185    <Compile Include="kentta13.txt"> 
     186      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     187      <Name>kentta13</Name> 
     188      <Importer>TextFileImporter</Importer> 
     189      <Processor>TextFileContentProcessor</Processor> 
     190    </Compile> 
     191  </ItemGroup> 
     192  <ItemGroup> 
     193    <Compile Include="kentta14.txt"> 
     194      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     195      <Name>kentta14</Name> 
     196      <Importer>TextFileImporter</Importer> 
     197      <Processor>TextFileContentProcessor</Processor> 
     198    </Compile> 
     199  </ItemGroup> 
     200  <ItemGroup> 
     201    <Compile Include="kentta15.txt"> 
     202      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     203      <Name>kentta15</Name> 
     204      <Importer>TextFileImporter</Importer> 
     205      <Processor>TextFileContentProcessor</Processor> 
     206    </Compile> 
     207  </ItemGroup> 
     208  <ItemGroup> 
     209    <Compile Include="kentta16.txt"> 
     210      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     211      <Name>kentta16</Name> 
     212      <Importer>TextFileImporter</Importer> 
     213      <Processor>TextFileContentProcessor</Processor> 
     214    </Compile> 
     215  </ItemGroup> 
     216  <ItemGroup> 
     217    <Compile Include="kentta17.txt"> 
     218      <CopyToOutputDirectory>Always</CopyToOutputDirectory> 
     219      <Name>kentta17</Name> 
     220      <Importer>TextFileImporter</Importer> 
     221      <Processor>TextFileContentProcessor</Processor> 
    89222    </Compile> 
    90223  </ItemGroup> 
  • 2013/26/RoopeR/The Random game/The Random game/The Random gameContent/kentta1.txt

    r4233 r4276  
    33 
    44       *    * 
    5        ##  ## 
     5       ##  ##        M 
    66 
    7      *        * 
     7     *    *    * 
    88     ##  ##  ## 
    99 
    1010   *    *  *    *      
    11    ##  ##  ##  ## 
     11   ############### 
    1212 
    13  *    *       *   * 
     13 *    *   *    *   * 
    1414 ##  ##  ##  ##  ## 
    1515 
    16    !    N   M 
     16       N    
    1717###################### 
Note: See TracChangeset for help on using the changeset viewer.