Ignore:
Timestamp:
2010-07-28 14:55:40 (9 years ago)
Author:
lijiolva
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/30/lijiolva/Teh Bus Game/Peli.cs

    r1364 r1378  
    66public class Peli : TopDownPhysicsGame 
    77{ 
     8    PhysicsObject auto = new PhysicsObject(40, 20); 
     9        Vector Vektori = new Vector() ; 
    810    protected override void Begin() 
    911    { 
    1012        KineticFriction = 0.8; // Asetetaan kitka 
    11  
    12         Automobile auto = new Automobile(40, 20); 
    13         auto.Mass = 200.0; 
     13        LuoTalo(100, 60); 
     14        auto.Mass = 01.0; 
    1415        auto.Color = new Color(192, 192, 255); 
    1516        Add(auto); 
     
    1718        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
    1819        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 
    19         Keyboard.Listen(Key.Up, ButtonState.Down, kiihdyta, "Kiihdytä", auto); 
    20         Keyboard.Listen(Key.Down, ButtonState.Down, jarruta, "Jarruta", auto); 
    21         Keyboard.Listen(Key.Left, ButtonState.Down, kaanny, "Käänny vasemmalle", auto, Angle.Degrees(1)); 
    22         Keyboard.Listen(Key.Right, ButtonState.Down, kaanny, "Käänny oikealle", auto, Angle.Degrees(-1)); 
    23  
    24         ShowControlHelp(); 
     20        Mouse.Listen(MouseButton.Left, ButtonState.Down, Reitti, "Siirry", auto); 
    2521    } 
    2622    void LuoTalo(double x, double y) 
    2723{ 
    28         PhysicsObject talo = new PhysicsObject(100.0, 100.0) ; 
     24    PhysicsObject talo = new PhysicsObject(100.0, 100.0, Shapes.Rectangle); 
    2925        talo.X = x ; 
    30         talo.Y = y; 
     26        talo.Y = y ; 
    3127        talo.Color = Color.Yellow; 
    32      
     28        talo.IgnoresCollisionResponse = true; 
     29        Add(talo); 
    3330} 
    34  
    35     void kiihdyta(Automobile auto) 
     31    void Reitti (PhysicsObject auto) 
    3632    { 
    37         auto.Accelerate(Time.SinceLastUpdate.TotalSeconds); 
    38     } 
    39  
    40     void jarruta(Automobile auto) 
    41     { 
    42         auto.Brake(Time.SinceLastUpdate.TotalSeconds); 
    43     } 
    44  
    45     void kaanny(Automobile auto, Angle kaannos) 
    46     { 
    47         auto.Turn(kaannos, Time.SinceLastUpdate.TotalSeconds); 
     33        Vektori = Mouse.PositionOnWorld; 
     34        auto.Push(Vektori); 
     35        auto.Angle = Vektori.Angle; 
    4836    } 
    4937} 
Note: See TracChangeset for help on using the changeset viewer.