Changeset 1347 for 2010/30


Ignore:
Timestamp:
2010-07-27 22:12:48 (9 years ago)
Author:
vematata
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/30/vematata/SeikailuRoolipeli/Peli.cs

    r1341 r1347  
    66public class Peli : PhysicsGame 
    77{ 
    8     Vector nopeusYlos = new Vector(0, -200); 
    9     Vector nopeusAlas = new Vector(0, 200); 
    10     Vector nopeusVasen = new Vector(200, 0); 
    11     Vector nopeusOikea = new Vector(-200, 0); 
     8    Vector nopeusYlos = new Vector(0, 200); 
     9    Vector nopeusAlas = new Vector(0, -200); 
     10    Vector nopeusVasen = new Vector(-200, 0); 
     11    Vector nopeusOikea = new Vector(200, 0); 
    1212 
    1313    PhysicsObject hahmo; 
     
    1919    } 
    2020 
     21    void Testi() 
     22    { 
     23        Hahmo(0, 0); 
     24        Kivi(30, -200, -300); 
     25        Kivi(60, 100, 300); 
     26        Puu(20, 100, -400); 
     27        Seina(500, 10, 30, 30); 
     28        Seina(500, 10, 30, -30); 
     29 
     30    } 
     31 
    2132    void Hahmo(double x, double y) 
    2233    { 
     
    2637        hahmo.X = x; 
    2738        hahmo.Y = y; 
    28         hahmo.Restitution = 1.0; 
    29         //hahmo. 
    3039        Add(hahmo); 
    3140        Camera.Follow(hahmo); 
    3241    } 
     42     
     43    PhysicsObject Kivi(double koko, double x, double y)  
     44    { 
     45        PhysicsObject kivi = PhysicsObject.CreateStaticObject(koko, koko, Shapes.Circle); 
     46        kivi.Color = Color.DarkGray; 
     47        kivi.X = x; 
     48        kivi.Y = y; 
     49        Add(kivi); 
     50        return(kivi); 
     51    } 
    3352 
    34     void Testi()  
     53    PhysicsObject Puu(double koko, double x, double y) 
    3554    { 
    36         Hahmo(0,0); 
    37         PhysicsObject kivi = new PhysicsObject(30,30,Shapes.Circle); 
    38         kivi.Color = Color.Gray; 
    39         kivi.X = 200; 
    40         kivi.Y = -200; 
    41         Add(kivi); 
     55        PhysicsObject runko = PhysicsObject.CreateStaticObject(koko, koko, Shapes.Circle); 
     56        PhysicsObject lehdet = new PhysicsObject(7*koko, 7*koko, Shapes.Circle); 
     57        lehdet.X = runko.X = x; 
     58        lehdet.Y = runko.Y = y; 
     59        lehdet.IgnoresCollisionResponse = true; 
     60        runko.Color = Color.Brown; 
     61        lehdet.Color = Color.ForestGreen; 
    4262 
     63        Add(runko); 
     64        Add(lehdet); 
     65        return(runko); 
     66        return(lehdet); 
    4367    } 
     68 
     69    PhysicsObject Seina(double leveys, double pituus, double x, double y) 
     70    { 
     71        PhysicsObject seina = PhysicsObject.CreateStaticObject(leveys, pituus, Shapes.Rectangle); 
     72        seina.Color = Color.LightYellow; 
     73        seina.X = x; 
     74        seina.Y = y; 
     75        Add(seina); 
     76        return (seina); 
     77    } 
     78     
    4479    void AsetaOhjaimet() 
    4580    { 
    46         Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "", hahmo, nopeusYlos); 
     81        Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus, "Liiku ylös", hahmo, nopeusYlos); 
    4782        Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus, null, hahmo, Vector.Zero); 
    48         Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "", hahmo, nopeusAlas); 
     83        Keyboard.Listen(Key.Down, ButtonState.Down, AsetaNopeus, "Liiku alas", hahmo, nopeusAlas); 
    4984        Keyboard.Listen(Key.Down, ButtonState.Released, AsetaNopeus, null, hahmo, Vector.Zero); 
    50         Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "", hahmo, nopeusVasen); 
     85        Keyboard.Listen(Key.Left, ButtonState.Down, AsetaNopeus, "liiku vasemmalle", hahmo, nopeusVasen); 
    5186        Keyboard.Listen(Key.Left, ButtonState.Released, AsetaNopeus, null, hahmo, Vector.Zero); 
    52         Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "", hahmo, nopeusOikea); 
     87        Keyboard.Listen(Key.Right, ButtonState.Down, AsetaNopeus, "Liiku oikealle", hahmo, nopeusOikea); 
    5388        Keyboard.Listen(Key.Right, ButtonState.Released, AsetaNopeus, null, hahmo, Vector.Zero); 
     89 
     90        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     91 
     92        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
    5493 
    5594    } 
     
    5897    { 
    5998        hahmo.Velocity = nopeus; 
    60  
    6199    } 
    62100 
Note: See TracChangeset for help on using the changeset viewer.