Changeset 8596


Ignore:
Timestamp:
2017-06-13 14:49:30 (6 years ago)
Author:
npo17_6
Message:
 
Location:
2017/24/SamuelN
Files:
53 added
1 deleted
12 edited

Legend:

Unmodified
Added
Removed
  • 2017/24/SamuelN/Bottleflip/Bottleflip/Bottleflip/Bottleflip.cs

    r8533 r8596  
    99public class Bottleflip : PhysicsGame 
    1010{ 
     11    PhysicsObject pullo; 
     12    PhysicsObject alareuna; 
     13    PhysicsObject ylareuna; 
     14    int y; 
     15 
    1116    public override void Begin() 
    1217    { 
    13         AloitaPeli(); 
     18         
     19        MediaPlayer.Play("IttyBitty"); 
     20        IsFullScreen = true; 
     21        IsMouseVisible = true; 
     22        MultiSelectWindow alkuValikko = new MultiSelectWindow("Bottle Flip Sim 2.0", "Start", "Buy Bottles", "Exit"); 
     23        alkuValikko.Image = LoadImage("pullo"); 
     24        alkuValikko.IsVisible = false; 
     25        alkuValikko.AddItemHandler(0, AloitaPeli); 
     26        alkuValikko.AddItemHandler(1, OpenShop); 
     27        alkuValikko.AddItemHandler(2, Exit); 
     28        Add(alkuValikko); 
     29         
     30    } 
     31    void OpenShop() 
     32    { 
     33        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Exit"); 
     34 
     35        Widget ruutu1 = new Widget(120.0, 360.0); 
     36        ruutu1.X = Screen.LeftSafe + 200; 
     37        ruutu1.Y = Screen.TopSafe - 200; 
     38        ruutu1.Image = LoadImage("pullo"); 
     39        Add(ruutu1); 
     40 
     41        Widget ruutu2 = new Widget(120.0, 360.0); 
     42        ruutu2.X = Screen.LeftSafe + 450; 
     43        ruutu2.Y = Screen.TopSafe - 200; 
     44        ruutu2.Image = LoadImage("pullo2"); 
     45        Add(ruutu2); 
     46 
     47        Widget ruutu3 = new Widget(200.0, 300.0); 
     48        ruutu3.X = Screen.LeftSafe + 700; 
     49        ruutu3.Y = Screen.TopSafe - 200; 
     50        //ruutu3.Image = LoadImage("pullo3"); 
     51        Add(ruutu3); 
    1452    } 
    1553    void AloitaPeli() 
    1654    { 
     55        ClearAll(); 
     56        LuoPistelaskuri(); 
     57        LuoLevel(); 
     58        MediaPlayer.Play("PinballSpring"); 
     59        MediaPlayer.IsRepeating = true; 
     60    } 
     61    void LuoLevel() 
     62    { 
    1763        Color vari = RandomGen.NextColor(); 
    1864        Color vari2 = RandomGen.NextColor(); 
    19         ClearAll(); 
    2065        Gravity = new Vector(0, -800); 
    21         //IsFullScreen = true; 
    22         IsMouseVisible = true; 
     66         
    2367        Level.Background.Color = vari2; 
    2468 
    25         PhysicsObject pullo = new PhysicsObject(40, 120); 
     69        pullo = new PhysicsObject(40, 120); 
    2670        Camera.ZoomFactor = 1; 
    2771        pullo.Image = LoadImage("pullo"); 
     72        pullo.Y = 0; 
    2873        pullo.Shape = Shape.FromImage(LoadImage("pullo")); 
     74        AddCollisionHandler(pullo, "alareuna", d); 
    2975        Add(pullo); 
    3076 
     77        /*PhysicsObject pullonpohja = new PhysicsObject(20, 10); 
     78        pullonpohja.X = pullo.X; 
     79        pullonpohja.Y = pullo.Bottom + 10; 
     80        Add(pullonpohja); 
    3181 
    32         PhysicsObject alareuna = PhysicsObject.CreateStaticObject(2000, 200); 
    33         alareuna.Y = -500; 
     82        AxleJoint aj = new AxleJoint(pullo, pullonpohja); 
     83         
     84        Add(aj);*/ 
     85 
     86        alareuna = PhysicsObject.CreateStaticObject(2000, 200); 
     87        alareuna.Y = -600; 
    3488        alareuna.Color = vari; 
    3589        alareuna.Tag = "alareuna"; 
    3690        Add(alareuna); 
    3791 
     92        ylareuna = PhysicsObject.CreateStaticObject(2000, 200); 
     93        ylareuna.Y = 600; 
     94        ylareuna.Color = vari; 
     95        ylareuna.Tag = "alareuna"; 
     96        Add(ylareuna); 
     97 
    3898        PhysicsObject vasenreuna = PhysicsObject.CreateStaticObject(200, 3000); 
    39         vasenreuna.X = -1050; 
     99        vasenreuna.X = -1100; 
    40100        vasenreuna.Y = 900; 
    41101        Add(vasenreuna); 
     102 
     103        PhysicsObject taso = PhysicsObject.CreateStaticObject(300, 30); 
     104        taso.X = 0; 
     105        taso.Y = -100; 
     106        taso.Color = vari; 
     107        Add(taso); 
    42108 
    43109        PhysicsObject oikeareuna = PhysicsObject.CreateStaticObject(200, 3000); 
     
    49115        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    50116        Keyboard.Listen(Key.R, ButtonState.Pressed, AloitaPeli, "Restart"); 
    51         Mouse.Listen(MouseButton.Left, ButtonState.Released, Pyori, "Heitä pullo", pullo); 
     117        Keyboard.Listen(Key.Space, ButtonState.Released, Pyori, "Heitä pullo", pullo); 
     118        Keyboard.Listen(Key.Space, ButtonState.Down, AloitaLaskuri, "Heitä pullo"); 
     119    } 
     120    void d (PhysicsObject pullo, PhysicsObject alareuna) 
     121    { 
     122        if (pullo.Bottom == alareuna.Top) 
     123        { 
     124            pisteLaskuri.Value += 1; 
     125        } 
     126    } 
     127    Timer aikaLaskuri; 
     128    void AloitaLaskuri() 
     129    { 
     130        y = 0; 
     131        aikaLaskuri = new Timer(); 
     132        aikaLaskuri.Interval = 0.1; 
     133        aikaLaskuri.Timeout += delegate {y = y + 10; }; 
     134        aikaLaskuri.Start(); 
     135        
    52136    } 
    53137    void Pyori(PhysicsObject pullo) 
    54138    { 
    55         pullo.Hit(new Vector(0, 100)); 
     139        pullo.Hit(new Vector(50, y)); 
    56140        pullo.AngularVelocity = 30; 
     141        MessageDisplay.Add(y.ToString()); 
     142        aikaLaskuri.Reset(); 
     143    } 
     144    IntMeter pisteLaskuri; 
     145 
     146    void LuoPistelaskuri() 
     147    { 
     148        pisteLaskuri = new IntMeter(0); 
     149 
     150        Label pisteNaytto = new Label(); 
     151        pisteNaytto.X = Screen.Left + 100; 
     152        pisteNaytto.Y = Screen.Top - 100; 
     153        pisteNaytto.TextColor = Color.White; 
     154        pisteNaytto.IntFormatString = "Flips: {0:D1}"; 
     155        pisteNaytto.BindTo(pisteLaskuri); 
     156        Add(pisteNaytto); 
    57157    } 
    58158} 
  • 2017/24/SamuelN/Bottleflip/Bottleflip/Bottleflip/Bottleflip.csproj.Debug.cachefile

    r8505 r8596  
    11Content\pullo.xnb 
     2Content\flip.xnb 
     3Content\IttyBitty.xnb 
     4Content\PinballSpring.xnb 
     5Content\pullo2.xnb 
     6Content\IttyBitty.wma 
     7Content\PinballSpring.wma 
  • 2017/24/SamuelN/Bottleflip/Bottleflip/Bottleflip/obj/x86/Debug/Bottleflip.csproj.FileListAbsolute.txt

    r8533 r8596  
    1616C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\obj\x86\Debug\Bottleflip.exe 
    1717C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\obj\x86\Debug\Bottleflip.pdb 
     18C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\flip.xnb 
     19C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\IttyBitty.xnb 
     20C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\PinballSpring.xnb 
     21C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\IttyBitty.wma 
     22C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\PinballSpring.wma 
     23C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\pullo2.xnb 
  • 2017/24/SamuelN/Bottleflip/Bottleflip/Bottleflip/obj/x86/Debug/ContentPipeline-{536D966A-8C7A-41D4-A0E3-DF5A9112B885}.xml

    r8533 r8596  
    99      <Options>None</Options> 
    1010      <Output>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\pullo.xnb</Output> 
    11       <Time>2017-06-12T12:06:16.7330895+03:00</Time> 
     11      <Time>2017-06-13T10:25:01.1873806+03:00</Time> 
     12    </Item> 
     13    <Item> 
     14      <Source>flip.wav</Source> 
     15      <Name>flip</Name> 
     16      <Importer>WavImporter</Importer> 
     17      <Processor>SoundEffectProcessor</Processor> 
     18      <Options>None</Options> 
     19      <Output>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\flip.xnb</Output> 
     20      <Time>2017-06-13T14:07:55.9813721+03:00</Time> 
     21    </Item> 
     22    <Item> 
     23      <Source>IttyBitty.mp3</Source> 
     24      <Name>IttyBitty</Name> 
     25      <Importer>Mp3Importer</Importer> 
     26      <Processor>SongProcessor</Processor> 
     27      <Options>None</Options> 
     28      <Output>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\IttyBitty.xnb</Output> 
     29      <Extra>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\IttyBitty.wma</Extra> 
     30      <Time>2017-06-13T14:18:52.8341593+03:00</Time> 
     31    </Item> 
     32    <Item> 
     33      <Source>PinballSpring.mp3</Source> 
     34      <Name>PinballSpring</Name> 
     35      <Importer>Mp3Importer</Importer> 
     36      <Processor>SongProcessor</Processor> 
     37      <Options>None</Options> 
     38      <Output>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\PinballSpring.xnb</Output> 
     39      <Extra>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\PinballSpring.wma</Extra> 
     40      <Time>2017-06-13T14:19:24.6279234+03:00</Time> 
     41    </Item> 
     42    <Item> 
     43      <Source>pullo2.png</Source> 
     44      <Name>pullo2</Name> 
     45      <Importer>TextureImporter</Importer> 
     46      <Processor>TextureProcessor</Processor> 
     47      <Options>None</Options> 
     48      <Output>C:\MyTemp\SamuelN\Bottleflip\Bottleflip\Bottleflip\bin\x86\Debug\Content\pullo2.xnb</Output> 
     49      <Time>2017-06-13T14:36:52.3688506+03:00</Time> 
    1250    </Item> 
    1351    <BuildSuccessful>true</BuildSuccessful> 
     
    5896      <Assembly> 
    5997        <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> 
    60         <Value>2017-06-07T09:21:00.3687337+03:00</Value> 
     98        <Value>2017-06-10T13:20:55.82404+03:00</Value> 
    6199      </Assembly> 
    62100    </Assemblies> 
  • 2017/24/SamuelN/Bottleflip/Bottleflip/Bottleflip/obj/x86/Debug/cachefile-{536D966A-8C7A-41D4-A0E3-DF5A9112B885}-targetpath.txt

    r8505 r8596  
    11Content\pullo.xnb 
     2Content\flip.xnb 
     3Content\IttyBitty.xnb 
     4Content\IttyBitty.wma 
     5Content\PinballSpring.xnb 
     6Content\PinballSpring.wma 
     7Content\pullo2.xnb 
  • 2017/24/SamuelN/Bottleflip/Bottleflip/BottleflipContent/BottleflipContent.contentproj

    r8505 r8596  
    5252    </Compile> 
    5353  </ItemGroup> 
     54  <ItemGroup> 
     55    <Compile Include="flip.wav"> 
     56      <Name>flip</Name> 
     57      <Importer>WavImporter</Importer> 
     58      <Processor>SoundEffectProcessor</Processor> 
     59    </Compile> 
     60  </ItemGroup> 
     61  <ItemGroup> 
     62    <Compile Include="IttyBitty.mp3"> 
     63      <Name>IttyBitty</Name> 
     64      <Importer>Mp3Importer</Importer> 
     65      <Processor>SongProcessor</Processor> 
     66    </Compile> 
     67  </ItemGroup> 
     68  <ItemGroup> 
     69    <Compile Include="PinballSpring.mp3"> 
     70      <Name>PinballSpring</Name> 
     71      <Importer>Mp3Importer</Importer> 
     72      <Processor>SongProcessor</Processor> 
     73    </Compile> 
     74  </ItemGroup> 
     75  <ItemGroup> 
     76    <Compile Include="pullo2.png"> 
     77      <Name>pullo2</Name> 
     78      <Importer>TextureImporter</Importer> 
     79      <Processor>TextureProcessor</Processor> 
     80    </Compile> 
     81  </ItemGroup> 
    5482  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    5583  <!--  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.