Changeset 6562 for 2015


Ignore:
Timestamp:
2015-06-30 10:54:15 (8 years ago)
Author:
misakana
Message:
 
Location:
2015/27/TapaniS/ProjectStar/ProjectStar/ProjectStar
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 2015/27/TapaniS/ProjectStar/ProjectStar/ProjectStar/ProjectStar.cs

    r6559 r6562  
    99public class ProjectStar : PhysicsGame 
    1010{ 
     11    Image tasoKuva = LoadImage("monttu"); 
     12    Image taustaKuva = LoadImage("Kentta"); 
     13    Vector nopeusYlos = new Vector(0, 200); 
     14    //Vector nopeusOikealle = new Vector(150, 0); 
     15    //Vector nopeusVasemmalle = new Vector(-150, 0); 
     16    double nopeus = 300; 
     17 
     18    PlatformCharacter ukko; 
     19 
    1120    public override void Begin() 
    1221    { 
     22        //Level.Background.Image = taustaKuva; 
     23         
     24        Level.Size = new Vector(1500, 1000);  
     25        //Level.CreateBorders(); 
     26        //Camera.ZoomToLevel(); 
     27 
     28        ukko = new PlatformCharacter( 40.0, 40.0); 
     29 
     30        for (int i = 0; i < 20; i++) 
     31        { 
     32            Vector kentanPiste = Level.GetRandomPosition(); 
     33            Vector pisteenPiste = Level.GetRandomPosition(); 
     34 
     35 
     36            Add(ukko); 
     37            ukko.Color = Color.Purple; 
     38 
     39            PhysicsObject aloitus = new PhysicsObject(100.0, 20.0); 
     40            Add(aloitus); 
     41            aloitus.IgnoresGravity = true; 
     42             
     43            PhysicsObject piste = new PhysicsObject(20, 20); 
     44            piste.IgnoresGravity = true; 
     45            Add(piste); 
     46            piste.Position = pisteenPiste; 
     47            piste.Color = Color.Blue; 
     48            piste.Tag = "piste"; 
     49 
     50            PhysicsObject taso = PhysicsObject.CreateStaticObject(60.0, 20.0); 
     51            taso.IgnoresGravity = true; 
     52            Add(taso); 
     53            taso.Position = kentanPiste; 
     54        } 
     55 
     56        Gravity = new Vector(0.0, -800.0); 
     57 
     58        Level.Background.Image = taustaKuva; 
     59        Camera.ZoomToLevel(); 
     60        Level.CreateBorders(1, 1, 2, 1.0, Color.Transparent);    
     61        Level.Size = new Vector(1650, 1050);             
     62        Level.Background.FitToLevel(); 
     63 
     64        LiikutaUkkoa(); 
     65             
    1366        // TODO: Kirjoita ohjelmakoodisi tähän 
    14  
    1567 
    1668        PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 
    1769        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    1870    } 
     71 
     72    void LiikutaUkkoa() 
     73    { 
     74        Keyboard.Listen(Key.W, ButtonState.Down, Hyppy, "Ukko: Liikuta ukkoa ylös", ukko); 
     75        Keyboard.Listen(Key.D, ButtonState.Down, Liiku, "Ukko: Liikuta ukkoa oikealle", ukko, nopeus); 
     76        Keyboard.Listen(Key.A, ButtonState.Down, Liiku, "Ukko: Liikuta ukkoa vasemmalle", ukko, -nopeus); 
     77    } 
     78 
     79    void Liiku(PlatformCharacter Ukko, double nopeus) 
     80    { 
     81        //ukko.Velocity = nopeus; 
     82        ukko.Walk(nopeus); 
     83    } 
     84 
     85    void Hyppy(PlatformCharacter Ukko) 
     86    { 
     87        ukko.Jump(1000); 
     88    } 
     89 
     90    void Pelaajaosuu() 
     91    { 
     92 
     93    } 
     94 
     95    IntMeter pisteLaskuri; 
     96 
     97    void LuoPistelaskuri() 
     98    { 
     99        Label pisteNaytto = new Label(); 
     100        pisteNaytto.X = Screen.Left + 100; 
     101        pisteNaytto.Y = Screen.Top - 100; 
     102        pisteNaytto.TextColor = Color.Black; 
     103        pisteNaytto.Color = Color.White; 
     104 
     105        pisteNaytto.BindTo(pisteLaskuri); 
     106        Add(pisteNaytto); 
     107        LuoPistelaskuri(); 
     108        pisteNaytto.Title = "Pisteet"; 
     109 
     110 
     111    } 
     112 
    19113} 
Note: See TracChangeset for help on using the changeset viewer.