Changeset 7465 for 2016/25


Ignore:
Timestamp:
2016-06-19 15:48:08 (7 years ago)
Author:
koannak
Message:
 
Location:
2016/25/MiskaL/Pongis Khan
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • 2016/25/MiskaL/Pongis Khan/Pongis Khan/Pongis_Khan/Pongis_Khan.cs

    r7456 r7465  
    99public class Pongis_Khan : PhysicsGame 
    1010{ 
     11    Vector nopeusYlös = new Vector(0, 200); 
     12    Vector nopeusAlas = new Vector(0, -200); 
    1113    PhysicsObject pallo; 
     14    PhysicsObject maila2; 
     15    PhysicsObject maila; 
    1216    public override void Begin() 
    1317    { 
    14      
     18         
    1519        LuoKentta(); 
    16          
    17        
    18         Vector impulssi = new Vector(1000.0, 0.0); 
    19         pallo.Hit(impulssi); 
    20         
     20        AloitaPeli(); 
     21        AsetaOhjaimet(); 
     22 
     23 
     24 
     25 
    2126        Level.Background.CreateGradient(Color.Black, Color.Black); 
    2227        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    23         Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     28        
    2429    } 
    2530    void LuoKentta() 
    2631    { 
    27          pallo = new PhysicsObject(50, 50); 
     32        pallo = new PhysicsObject(50, 50); 
    2833        Add(pallo); 
    2934        pallo.Shape = Shape.Circle; 
     
    3136        pallo.X = -200.0; 
    3237        pallo.Y = 0.0; 
     38 
     39       maila2= LuoMaila(Level.Left + 20.0, 0.0); 
     40       maila = LuoMaila(Level.Right - 20.0, 0.0); 
     41 
     42 
    3343        Level.CreateBorders(1.0, false); 
    3444        pallo.Restitution = 1.0; 
    3545        Camera.ZoomToLevel(); 
    3646 
     47 
     48    } 
     49    protected override void Update(Time time) 
     50    { 
     51        if (pallo != null && Math.Abs(pallo.Velocity.X) < 1000) 
     52        { 
     53            pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); 
     54        } 
     55        base.Update(time); 
     56     
     57    } 
     58    void AloitaPeli() 
     59    { 
     60 
     61        Vector impulssi = new Vector(1000.0, 0.0); 
     62        pallo.Hit(impulssi); 
     63    } 
     64    PhysicsObject LuoMaila(double x, double y) { 
    3765        PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 
    3866        maila.Shape = Shape.Rectangle; 
    39         maila.X = Level.Left + 20.0; 
    40         maila.Y = 0.0; 
     67        maila.X = x; 
     68        maila.Y = y; 
    4169        maila.Restitution = 1.0; 
    4270        Add(maila); 
     71        return maila; 
    4372    } 
    44 } 
     73    void AsetaOhjaimet() 
     74    { 
     75        Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, maila, nopeusYlös, ""); 
     76        Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, "", maila, Vector. Zero); 
     77        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
     78        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus ,maila2 ""); 
     79        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus,maila2, Vector. Zero); 
     80        Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, maila,  ); 
     81        Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, , maila, Vector.Zero); 
     82    } 
     83    void AsetaNopeus(PhysicsObject maila, Vector nopeus) 
     84    { 
     85        maila.Velocity = nopeus; 
     86  
     87 
     88 
     89 
     90 
     91 
     92 
     93 
     94 
     95 
     96    }  
Note: See TracChangeset for help on using the changeset viewer.