Changeset 4551 for 2013/30


Ignore:
Timestamp:
2013-07-23 11:48:20 (10 years ago)
Author:
viosfilp
Message:

Talletus.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2013/30/VilleF/Lentokone/Lentokone/Lentokone/Lentokone.cs

    r4545 r4551  
    1111    Image maisema = LoadImage("havutausta"); 
    1212    Image havusaurus = LoadImage("havusaurus"); 
     13    PhysicsObject pelaaja; 
    1314    public override void Begin() 
    1415    { 
    15         luokentta(); 
    16         luohavusaurus(); 
    17  
     16        Level.Width = 800; 
     17        Level.Height = 600; 
     18        SetWindowSize(800, 600, false); 
     19        LuoKentta(); 
     20        LuoHavusaurus(); 
     21        LiikutaPelaajaa(); 
     22        Camera.ZoomToLevel(); 
    1823        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    1924        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    2025    } 
    21     void luokentta() 
     26 
     27    void LuoKentta() 
    2228    { 
    23         Level.Width = 1920; 
    24         Level.Height = 1080; 
    2529        Level.BackgroundColor = Color.Red; 
    2630        Level.Background.Image = maisema; 
    2731        Level.Background.FitToLevel(); 
     32        Surface alareuna = new Surface(Level.Width, 30, 50, 60, 10); 
     33        alareuna.Color = Color.Green; 
     34        alareuna.Bottom = Level.Bottom; 
     35        Add(alareuna); 
     36         
    2837    } 
    29     void luohavusaurus() 
     38    void LuoHavusaurus() 
    3039    { 
    3140        PhysicsObject pelaaja = new PhysicsObject(235.0, 283.0); 
     
    3544 
    3645    } 
     46    void LiikutaPelaajaa() 
     47    { 
     48        pelaaja.LinearDamping = 0.95; 
     49        Vector pelaajanSuunta = Vector.FromLengthAndAngle(500.0, pelaaja.Angle); 
     50        pelaaja.Push(pelaajanSuunta); 
     51 
     52        Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, "Pelaaja 1 Mailaa ylös", pelaaja, nopeusYlos); 
     53        Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, null, pelaaja, Vector.Zero); 
     54        Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, "Pelaaja 1: Liikuta mailaa alas", pelaaja, nopeusAlas); 
     55        Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, null, pelaaja, Vector.Zero); 
     56        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "PLS DOLAN STAAPH"); 
     57    } 
     58    void AsetaNopeus() 
     59    { 
     60          if ((nopeus.Y < 0) && (pelaaja.Bottom < Level.Bottom)) 
     61        { 
     62            pelaaja.Velocity = Vector.Zero; 
     63            return; 
     64        } 
     65        if ((nopeus.Y > 0) && (pelaaja.Top > Level.Top)) 
     66        { 
     67            pelaaja.Velocity = Vector.Zero; 
     68            return; 
     69    } 
    3770} 
Note: See TracChangeset for help on using the changeset viewer.