Changeset 6511 for 2015/27/JimiS


Ignore:
Timestamp:
2015-06-29 14:16:14 (4 years ago)
Author:
jivesuor
Message:
 
Location:
2015/27/JimiS/Pong
Files:
6 added
9 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/JimiS/Pong/Pong/Pong/Pong.cs

    r6508 r6511  
    99public class Pong : PhysicsGame 
    1010{ 
     11    //vektorit 
    1112    Vector nopeusYlos = new Vector(0, 200); 
    1213    Vector nopeusAlas = new Vector(0, -200); 
     14    //reunat 
     15    PhysicsObject vasenReuna; 
     16    PhysicsObject oikeaReuna; 
     17    //pallo 
    1318    PhysicsObject pallo; 
     19    //mailat 
    1420    PhysicsObject maila1; 
    1521    PhysicsObject maila2; 
     22    //pisteet 
    1623    IntMeter pelaajan1Pisteet; 
    1724    IntMeter pelaajan2Pisteet; 
     25    Image pallokuva = LoadImage("jalkapallo"); 
     26    Image pallokenttä = LoadImage("jalkapallokenttä"); 
    1827 
    1928    public override void Begin() 
     
    2332        LisaaLaskurit(); 
    2433        AloitaPeli(); 
     34        ohjeteksti(); 
    2535    } 
    2636    void LuoKenttä() 
     
    3141        pallo.X = -200.0; 
    3242        pallo.Y = 0.0; 
    33         Level.CreateBorders(1.0, false); 
     43        pallo.Image = pallokuva; 
     44        //Kentän reunat, vasen 
     45        vasenReuna = Level.CreateLeftBorder(); 
     46        vasenReuna.Restitution = 1.0; 
     47        vasenReuna.IsVisible = false; 
     48        // oikea 
     49        oikeaReuna = Level.CreateRightBorder(); 
     50        oikeaReuna.Restitution = 1.0; 
     51        oikeaReuna.IsVisible = false; 
     52        //ala 
     53        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     54        alaReuna.Restitution = 1.0; 
     55        alaReuna.IsVisible = false; 
     56        //ylä 
     57        PhysicsObject yläReuna = Level.CreateTopBorder(); 
     58        yläReuna.Restitution = 1.0; 
     59        yläReuna.IsVisible = false; 
     60        //reunat loppuu  
    3461        pallo.Restitution = 1.0; 
    35         Level.Background.Color = Color.Black; 
     62        Level.Background.Color = Color.Green; 
    3663        pallo.Color = Color.Green; 
    3764        Camera.ZoomToLevel(); 
    3865        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
    3966        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    40  
     67        AddCollisionHandler(pallo, KasittelePallonTormays); 
     68    } 
     69    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     70    { 
     71        if (kohde == oikeaReuna) 
     72        { 
     73            pelaajan1Pisteet.Value += 1; 
     74        } 
     75        else if (kohde == vasenReuna) 
     76        { 
     77            pelaajan2Pisteet.Value += 1; 
     78        } 
    4179    } 
    4280    void LisaaLaskurit() 
    4381    { 
    4482        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
     83        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
    4584    } 
    4685    void AloitaPeli() 
     
    5796        maila.Restitution = 1.0; 
    5897        Add(maila); 
     98        maila.Color = Color.Blue; 
    5999        return maila; 
    60100    } 
    61101    void AsetaOhjaimet() 
    62102    { 
    63         Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta maila ylös", maila1, nopeusYlos); 
    64         Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    65         Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
    66         Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     103        Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta maila ylös", maila1, nopeusYlos); 
     104        Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     105        Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     106        Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    67107 
    68108        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     
    102142        return laskuri; 
    103143    } 
     144    void ohjeteksti() 
     145    { 
     146        Label ohje = new Label("ohje painamalla F1"); 
     147        ohje.X = Level.Left + 100.0; 
     148        ohje.Y = Level.Top - 100.0; 
     149        ohje.TextColor = Color.Red; 
     150        ohje.BorderColor = Level.Background.Color; 
     151        ohje.Color = Level.Background.Color; 
     152        ohje.TextScale *= 2; 
     153        Add(ohje); 
     154    } 
     155 
    104156    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
    105157    { 
  • 2015/27/JimiS/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{43441B02-A17B-4AA5-9B96-F0812FDBF432}.xml

    r6505 r6511  
    22<XnaContent xmlns:Pipeline="Microsoft.Xna.Framework.Content.Pipeline"> 
    33  <Asset Type="Pipeline:BuildItemCollection"> 
     4    <Item> 
     5      <Source>jalkapallo.png</Source> 
     6      <Name>jalkapallo</Name> 
     7      <Importer>TextureImporter</Importer> 
     8      <Processor>TextureProcessor</Processor> 
     9      <Options>None</Options> 
     10      <Output>C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallo.xnb</Output> 
     11      <Time>2015-06-29T13:39:58.6999532+03:00</Time> 
     12    </Item> 
     13    <Item> 
     14      <Source>jalkapallokenttä.png</Source> 
     15      <Name>jalkapallokenttä</Name> 
     16      <Importer>TextureImporter</Importer> 
     17      <Processor>TextureProcessor</Processor> 
     18      <Options>None</Options> 
     19      <Output>C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallokenttä.xnb</Output> 
     20      <Time>2015-06-29T13:42:56.6095532+03:00</Time> 
     21    </Item> 
    422    <BuildSuccessful>true</BuildSuccessful> 
    523    <Settings> 
     
    1634    <Assemblies> 
    1735      <Assembly> 
     36        <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\TextFileContentExtension.dll</Key> 
     37        <Value>2014-11-26T00:23:34+02:00</Value> 
     38      </Assembly> 
     39      <Assembly> 
     40        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.XImporter.dll</Key> 
     41        <Value>2011-09-01T16:22:30+03:00</Value> 
     42      </Assembly> 
     43      <Assembly> 
     44        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.VideoImporters.dll</Key> 
     45        <Value>2011-09-01T16:22:30+03:00</Value> 
     46      </Assembly> 
     47      <Assembly> 
     48        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.TextureImporter.dll</Key> 
     49        <Value>2011-09-01T16:22:30+03:00</Value> 
     50      </Assembly> 
     51      <Assembly> 
     52        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.FBXImporter.dll</Key> 
     53        <Value>2011-09-01T16:22:30+03:00</Value> 
     54      </Assembly> 
     55      <Assembly> 
     56        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.EffectImporter.dll</Key> 
     57        <Value>2011-09-01T16:22:30+03:00</Value> 
     58      </Assembly> 
     59      <Assembly> 
     60        <Key>C:\Program Files (x86)\Microsoft XNA\XNA Game Studio\v4.0\References\Windows\x86\Microsoft.Xna.Framework.Content.Pipeline.AudioImporters.dll</Key> 
     61        <Value>2011-09-01T16:22:30+03:00</Value> 
     62      </Assembly> 
     63      <Assembly> 
     64        <Key>C:\Program Files (x86)\Jypeli\lib\ContentExtensions\AnimationExtension.dll</Key> 
     65        <Value>2014-11-26T00:23:36+02:00</Value> 
     66      </Assembly> 
     67      <Assembly> 
    1868        <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> 
    1969        <Value>2014-04-23T00:22:29.3372049+03:00</Value> 
  • 2015/27/JimiS/Pong/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt

    r6505 r6511  
    77C:\MyTemp\JimiS\Pong\Pong\Pong\obj\x86\Debug\Pong.exe 
    88C:\MyTemp\JimiS\Pong\Pong\Pong\obj\x86\Debug\Pong.pdb 
     9C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallo.xnb 
     10C:\MyTemp\JimiS\Pong\Pong\Pong\bin\x86\Debug\Content\jalkapallokenttÀ.xnb 
  • 2015/27/JimiS/Pong/Pong/PongContent/PongContent.contentproj

    r6505 r6511  
    4545    <Reference Include="AnimationExtension" /> 
    4646  </ItemGroup> 
     47  <ItemGroup> 
     48    <Compile Include="jalkapallo.png"> 
     49      <Name>jalkapallo</Name> 
     50      <Importer>TextureImporter</Importer> 
     51      <Processor>TextureProcessor</Processor> 
     52    </Compile> 
     53  </ItemGroup> 
     54  <ItemGroup> 
     55    <Compile Include="jalkapallokenttä.png"> 
     56      <Name>jalkapallokenttä</Name> 
     57      <Importer>TextureImporter</Importer> 
     58      <Processor>TextureProcessor</Processor> 
     59    </Compile> 
     60  </ItemGroup> 
    4761  <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 
    4862  <!--  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.