Changeset 531 for 2010/23


Ignore:
Timestamp:
2010-06-08 11:25:37 (13 years ago)
Author:
paaaanro
Message:

Saanut molemmat mailat ruudulle.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/23/laemkaup/Pong/Peli.cs

    r495 r531  
    88    public class Peli : PhysicsGame 
    99    { 
     10        PhysicsObject pallo; 
     11        PhysicsObject maila1; 
     12        PhysicsObject maila2; 
     13 
    1014        protected override void Begin() 
    1115        { 
     16            LuoKentta(); 
     17            Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
     18             
     19            AloitaPeli(); 
    1220 
    1321 
     
    1523        void LuoKentta() 
    1624        { 
    17             PhysicsObject pallo = new PhysicsObject(50.8, 50.8); 
     25 
     26            pallo = new PhysicsObject(50.8, 50.8); 
    1827            Add(pallo); 
    1928            Level.CreateBorders(1.0, false); 
     
    2433            pallo.Hit(impulssi); 
    2534            pallo.Restitution = 1.0; 
     35 
     36            maila1 = LuoMaila(Level.Left + 20.0, 0.0); 
     37            maila2 = LuoMaila(Level.Right - 20.0, 0.0); 
     38 
     39 
    2640            Level.BackgroundColor = Color.Green; 
    2741            Camera.ZoomToLevel(); 
    2842        } 
    2943 
     44        void AloitaPeli() 
     45        { 
     46            Vector impulssi = new Vector(500.0, 0.0); 
     47            pallo.Hit(impulssi); 
     48        } 
    3049 
     50 
     51        void LuoMaila(double x, double y) 
     52        { 
     53            PhysicsObject maila = PhysicsObject.CreateStaticObject (20.0, 100.0); 
     54            maila.Shape = Shapes.Rectangle; 
     55            maila.X = x; 
     56            maila.Y = y; 
     57            maila.Restitution = 1.0; 
     58            Add( maila ); 
     59 
     60            return maila; 
     61 
     62         } 
     63        void AsetaOhjaimet() 
     64        { 
     65            Keyboard.Listen(Key.A, ButtonState.Pressed, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös", maila1 ); 
     66            Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null, maila1 ); 
     67 
     68            Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
     69         
     70         
     71        } 
     72        void LiikutaMailaaYlos( PhysicsObject maila ) 
     73        { 
     74          Vector nopeus = new Vector  ( 0, 200 ); 
     75          maila.Velocity = nopeus; 
     76        } 
     77        void PysaytaMaila ( PhysicsObject maila ) 
     78        { 
     79        } 
     80 
     81     
    3182    } 
     83 
    3284} 
Note: See TracChangeset for help on using the changeset viewer.