Changeset 9587


Ignore:
Timestamp:
2018-06-05 15:03:18 (22 months ago)
Author:
satovapi
Message:
 
Location:
2018/23/SAMPOP
Files:
80 added
10 edited

Legend:

Unmodified
Added
Removed
  • 2018/23/SAMPOP/pallo/pallo/obj/x86/Debug/pallo.csproj.CoreCompileInputs.cache

    r9536 r9587  
    1 791a85dc51f911666253ea990dd87439fe6f6e07 
     14a9a135d988865355ae8ff81c0b3e26ec9ddb919 
  • 2018/23/SAMPOP/pallo/pallo/obj/x86/Debug/pallo.csproj.FileListAbsolute.txt

    r9536 r9587  
    2727C:\MyTemp\pelikurssi\pallo\pallo\obj\x86\Debug\pallo.exe 
    2828C:\MyTemp\pelikurssi\pallo\pallo\obj\x86\Debug\pallo.pdb 
     29C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\pallo.exe 
     30C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\pallo.pdb 
     31C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\Jypeli.dll 
     32C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\Jypeli.Physics2d.dll 
     33C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\MonoGame.Framework.dll 
     34C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.MediaFoundation.dll 
     35C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.dll 
     36C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.XAudio2.dll 
     37C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.DXGI.dll 
     38C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.Direct3D11.dll 
     39C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.Direct2D1.dll 
     40C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.XInput.dll 
     41C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.Direct3D9.dll 
     42C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\Jypeli.xml 
     43C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\Jypeli.Physics2d.xml 
     44C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\MonoGame.Framework.xml 
     45C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.MediaFoundation.xml 
     46C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.xml 
     47C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.XAudio2.xml 
     48C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.DXGI.xml 
     49C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.Direct3D11.xml 
     50C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.Direct2D1.xml 
     51C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.XInput.xml 
     52C:\MyTemp\SAMPOP\pallo\pallo\bin\Windows\Debug\SharpDX.Direct3D9.xml 
     53C:\MyTemp\SAMPOP\pallo\pallo\obj\x86\Debug\pallo.csprojResolveAssemblyReference.cache 
     54C:\MyTemp\SAMPOP\pallo\pallo\obj\x86\Debug\pallo.csproj.CoreCompileInputs.cache 
     55C:\MyTemp\SAMPOP\pallo\pallo\obj\x86\Debug\pallo.exe 
     56C:\MyTemp\SAMPOP\pallo\pallo\obj\x86\Debug\pallo.pdb 
  • 2018/23/SAMPOP/pallo/pallo/pallo.cs

    r9536 r9587  
    88public class Pong : PhysicsGame 
    99{ 
     10    Vector nopeusYlos = new Vector(0, 200); 
     11    Vector nopeusAlas = new Vector(0, -200); 
     12 
     13 
    1014    PhysicsObject pallo; 
     15    PhysicsObject maila1; 
     16    PhysicsObject maila2; 
     17 
     18    IntMeter pelaajan1Pisteet; 
     19    IntMeter pelaajan2Pisteet; 
    1120    public override void Begin() 
    1221    { 
    1322        // Kirjoita ohjelmakoodisi tähän 
    1423        LuoKentta(); 
    15         AloitaPeli(); 
     24        AsetaOhjaimet(); 
     25        LisaaLaskurit(); 
     26         AloitaPeli(); 
     27 
    1628 
    1729 
     
    3143        pallo.Restitution = 1.0; 
    3244        Add(pallo); 
     45        AddCollisionHandler(pallo, KasittelePallonTormays); 
    3346 
    34         LuoMaila(Level.Left + 20.0, 0.0); 
    35         LuoMaila(Level.Right - 20.0, 0.0); 
     47        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     48        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
    3649        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
    3750        maila.Shape = Shape.Rectangle; 
     
    4255 
    4356 
    44         Level.CreateBorders(1.0, false); 
     57        PhysicsObject vasenReuna = Level.CreateLeftBorder(); 
     58        vasenReuna.Restitution = 1.0; 
     59        vasenReuna.IsVisible = false; 
    4560        Level.Background.Color = Color.LightBlue; 
    4661 
     
    5570 
    5671 
    57     void LuoMaila(double x, double y) 
     72    PhysicsObject LuoMaila(double x, double y) 
    5873    { 
    5974        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     
    6378        maila.Restitution = 1.0; 
    6479        Add(maila); 
     80        return maila; 
    6581    } 
     82 
     83 
    6684    void AsetaOhjaimet() 
    6785    { 
     86        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa Ylös", maila1, nopeusYlos); 
     87        Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     88        Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     89        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     90 
     91        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlos); 
     92        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     93        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
     94        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     95 
     96        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     97 
    6898        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     99    } 
     100    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
     101    { 
     102        if ((nopeus.Y < 0) && (maila.Bottom < Level.Bottom)) 
    69103        { 
     104            maila.Velocity = Vector.Zero; 
     105            return; 
    70106        } 
     107        if ((nopeus.Y > 0) && (maila.Top > Level.Top)) 
     108        { 
     109            maila.Velocity = Vector.Zero; 
     110            return; 
     111 
     112        } 
     113        maila.Velocity = nopeus; 
     114    } 
     115 
     116    void LisaaLaskurit() 
     117    { 
     118        pelaajan1Pisteet = LuoPisteLaskuri(Screen.Left + 100.0,  Screen.Top - 100.0); 
     119        pelaajan2Pisteet = LuoPisteLaskuri(Screen.Right - 100.0, Screen.Top - 100.0); 
     120    } 
     121    IntMeter LuoPisteLaskuri(double x, double y) 
     122    { 
     123        IntMeter Laskuri = new IntMeter(0); 
     124        Laskuri.MaxValue = 100; 
     125 
     126        Label naytto = new Label(); 
     127        naytto.BindTo(Laskuri); 
     128        naytto.X = x; 
     129        naytto.Y = y; 
     130        naytto.TextColor = Color.White; 
     131        naytto.BorderColor = Level.Background.Color; 
     132        naytto.Color = Level.Background.Color; 
     133        Add(naytto); 
     134 
     135        return Laskuri; 
     136    } 
     137    void KasittelePallonTormays(PhysicsObject pallo, PhysicsObject kohde) 
     138    { 
     139 
    71140    } 
    72141} 
Note: See TracChangeset for help on using the changeset viewer.