Changeset 8492 for 2017/24/MikoA/Pong


Ignore:
Timestamp:
2017-06-12 12:10:31 (2 years ago)
Author:
npo17_20
Message:
 
Location:
2017/24/MikoA/Pong/Pong/Pong
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2017/24/MikoA/Pong/Pong/Pong/Pong.cs

    r8491 r8492  
    99public class Pong : PhysicsGame 
    1010{ 
     11    Vector nopeusYlös = new Vector(0, 200); 
     12    Vector nopeusAlas = new Vector(0, -200); 
     13      
     14    PhysicsObject pallo; 
     15    PhysicsObject maila1; 
     16    PhysicsObject maila2; 
     17 
    1118    public override void Begin() 
    1219    { 
    13         PhysicsObject pallo = new PhysicsObject(40.0, 40.0); 
     20        LuoKentta(); 
     21        AsetaOhjaimet(); 
     22        AloitaPeli(); 
     23    } 
     24 
     25    void LuoKentta() 
     26    { 
     27        pallo = new PhysicsObject(40.0, 40.0); 
    1428        pallo.Shape = Shape.Circle; 
    1529        pallo.X = 0.0; 
    1630        pallo.Y = 0.0; 
    17         Vector impulssi= new Vector(500.0, 0.0); 
    18         pallo.Hit(impulssi); 
     31        pallo.Restitution = 1.0; 
    1932        Add(pallo); 
    2033 
    21         PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
     34        maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     35        maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     36 
     37 
     38        Level.CreateBorders(1.0, false); 
     39        Level.BackgroundColor = Color.Green; 
     40 
     41        Camera.ZoomToLevel(); 
     42 
     43    } 
     44    void AloitaPeli() 
     45    { 
     46        Vector impulssi = new Vector(500.0, 0.0); 
     47        pallo.Hit(impulssi); 
     48    } 
     49    void LuoMaila(double x, double y) 
     50    { 
     51     PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
     52        maila.Shape = Shape.Rectangle; 
     53        maila.X = x; 
     54        maila.Y = y; 
     55        maila.Restitution = 1.0; 
     56        Add(maila); 
     57        return maila; 
     58     } 
     59    void AsetaOhjaimet() 
     60    { 
     61        Keyboard.Listen(Key.A, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlös); 
     62        Keyboard.Listen(Key.A, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     63        Keyboard.Listen(Key.Z, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", maila1, nopeusAlas); 
     64        Keyboard.Listen(Key.Z, ButtonState.Released, AsetaNopeus, null, maila1, Vector.Zero); 
     65 
     66        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa ylös", maila2, nopeusYlös); 
     67        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     68        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Pelaaja 2: Liikuta mailaa alas", maila2, nopeusAlas); 
     69        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, maila2, Vector.Zero); 
     70 
     71        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    2272        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    2373    } 
     74    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
     75    { 
     76        maila.Velocity = nopeus; 
     77    } 
    2478} 
  • 2017/24/MikoA/Pong/Pong/Pong/obj/x86/Debug/ContentPipeline-{344B14C4-7331-4916-A874-A4798216B525}.xml

    r8491 r8492  
    1717      <Assembly> 
    1818        <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> 
    19         <Value>2017-06-09T17:02:21.2130348+03:00</Value> 
     19        <Value>2017-06-07T09:35:26.0439065+03:00</Value> 
    2020      </Assembly> 
    2121    </Assemblies> 
Note: See TracChangeset for help on using the changeset viewer.