Changeset 9606


Ignore:
Timestamp:
2018-06-06 11:39:14 (20 months ago)
Author:
veeranta
Message:
 
Location:
2018/23/VEETIR
Files:
219 added
10 edited

Legend:

Unmodified
Added
Removed
  • 2018/23/VEETIR/Pong/Pong/Pong.cs

    r9538 r9606  
    1515    PhysicsObject maila1; 
    1616    PhysicsObject maila2; 
     17 
     18    PhysicsObject vasenReuna; 
     19    PhysicsObject oikeaReuna; 
     20 
     21    IntMeter pelaajan1Pisteet; 
     22    IntMeter pelaajan2Pisteet; 
    1723    public override void Begin() 
    1824    { 
     
    2430 
    2531 
    26      
    2732 
     33    void LisaaLaskurit() 
     34    { 
     35        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0, Screen.Top - 100.0); 
     36        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
     37    } 
    2838 
     39    IntMeter LuoPisteLaskuri(double x, double y) 
     40    { 
     41        IntMeter laskuri = new IntMeter(0); 
     42        laskuri.MaxValue = 10; 
    2943 
     44        Label naytto = new Label(); 
     45        naytto.BindTo(laskuri); 
     46        naytto.X = x; 
     47        naytto.Y = y; 
     48        naytto.TextColor = Color.White; 
     49        naytto.BorderColor = Level.Background.Color; 
     50        naytto.Color = Level.Background.Color; 
     51        Add(naytto); 
    3052 
     53        return laskuri; 
     54    } 
    3155 
    3256 
     
    3458    void LuoKentta() 
    3559    { 
    36         pallo = new PhysicsObject(30.0, 30.0); 
     60        pallo = new PhysicsObject(100.0, 102.0); 
    3761        pallo.Shape = Shape.Circle; 
    3862        pallo.Color = Color.Crimson; 
     
    4569        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    4670 
     71        AddCollisionHandler(pallo, KasittelePallonTörmäys); 
     72 
     73        vasenReuna = Level.CreateLeftBorder(); 
     74        Level.Background.Color = Color.DarkBlue; 
     75        vasenReuna.Restitution = 1.0; 
     76        vasenReuna.IsVisible = false; 
     77        vasenReuna.KineticFriction = 0.0; 
    4778 
    4879 
    49         Level.CreateBorders(1.0, false); 
    50         Level.Background.Color = Color.DarkBlue; 
     80        oikeaReuna = Level.CreateRightBorder(); 
     81        oikeaReuna.Restitution = 1.0; 
     82        oikeaReuna.IsVisible = false; 
     83        oikeaReuna.KineticFriction = 0.0; 
     84 
     85        PhysicsObject alaReuna = Level.CreateBottomBorder(); 
     86        alaReuna.Restitution = 1.0; 
     87        alaReuna.IsVisible = false; 
     88        alaReuna.KineticFriction = 0.0; 
     89 
     90 
     91 
     92        PhysicsObject yläReuna = Level.CreateTopBorder(); 
     93        yläReuna.Restitution = 1.0; 
     94        yläReuna.IsVisible = false; 
     95        yläReuna.KineticFriction = 0.0; 
     96 
    5197 
    5298        Camera.ZoomToLevel(); 
     99 
    53100    } 
     101 
    54102    void AloitaPeli() 
    55103    { 
     
    85133        ControllerOne.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila1, nopeusYlos); 
    86134        ControllerOne.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    87         ControllerOne.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila1, nopeusAlas); 
     135        ControllerOne.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila1, nopusAlas); 
    88136        ControllerOne.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
    89137 
    90138        ControllerTwo.Listen(Button.DPadUp, ButtonState.Down, AsetaNopeus, "Liikuta mailaa ylös", maila2, nopeusYlos); 
    91139        ControllerTwo.Listen(Button.DPadUp, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
    92         ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila2, nopeusAlas); 
     140        ControllerTwo.Listen(Button.DPadDown, ButtonState.Down, AsetaNopeus, "Liikuta mailaa alas", maila2, nopusAlas); 
    93141        ControllerTwo.Listen(Button.DPadDown, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
    94142 
     
    100148    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
    101149    { 
     150        if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 
     151 
     152        { 
     153            maila.Velocity = Vector.Zero; 
     154            return; 
     155        } 
    102156        if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 
    103157        { 
     
    108162 
    109163    } 
     164    void KasittelePallonTörmäys(PhysicsObject pallo, PhysicsObject kohde) 
     165    { 
     166        if (kohde == oikeaReuna) 
     167        { 
     168            pelaajan1Pisteet.Value += 1; 
     169        } 
     170        else if (kohde == vasenReuna) 
     171        { 
     172            pelaajan2Pisteet.Value += 1; 
     173        } 
     174    } 
    110175 
    111176} 
     177   
     178 
  • 2018/23/VEETIR/Pong/Pong/obj/x86/Debug/Pong.csproj.CoreCompileInputs.cache

    r9538 r9606  
    1 65f2c0ca5cc76bc2de608a63d4c445b737f43290 
     1d6d42f99c75ad9f468200b5516bdb98f859eb1f8 
  • 2018/23/VEETIR/Pong/Pong/obj/x86/Debug/Pong.csproj.FileListAbsolute.txt

    r9538 r9606  
    2727C:\MyTemp\Veeti Ranta\Pong\Pong\obj\x86\Debug\Pong.exe 
    2828C:\MyTemp\Veeti Ranta\Pong\Pong\obj\x86\Debug\Pong.pdb 
     29C:\MyTemp\Veeti Ranta\RL\Pong\Pong\obj\x86\Debug\Pong.csprojResolveAssemblyReference.cache 
     30C:\MyTemp\Veeti Ranta\RL\Pong\Pong\obj\x86\Debug\Pong.csproj.CoreCompileInputs.cache 
     31C:\MyTemp\Veeti Ranta\RL\Pong\Pong\obj\x86\Debug\Pong.exe 
     32C:\MyTemp\Veeti Ranta\RL\Pong\Pong\obj\x86\Debug\Pong.pdb 
     33C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\Pong.exe 
     34C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\Pong.pdb 
     35C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\Jypeli.dll 
     36C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\Jypeli.Physics2d.dll 
     37C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\MonoGame.Framework.dll 
     38C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.MediaFoundation.dll 
     39C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.dll 
     40C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.XAudio2.dll 
     41C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.DXGI.dll 
     42C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.Direct3D11.dll 
     43C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.Direct2D1.dll 
     44C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.XInput.dll 
     45C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.Direct3D9.dll 
     46C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\Jypeli.xml 
     47C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\Jypeli.Physics2d.xml 
     48C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\MonoGame.Framework.xml 
     49C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.MediaFoundation.xml 
     50C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.xml 
     51C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.XAudio2.xml 
     52C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.DXGI.xml 
     53C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.Direct3D11.xml 
     54C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.Direct2D1.xml 
     55C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.XInput.xml 
     56C:\MyTemp\Veeti Ranta\RL\Pong\Pong\bin\Windows\Debug\SharpDX.Direct3D9.xml 
Note: See TracChangeset for help on using the changeset viewer.