Changeset 9137


Ignore:
Timestamp:
2017-07-26 14:50:39 (6 years ago)
Author:
npo17_55
Message:

Pelaajaa voi nyt liikuttaa

Location:
2017/30/MainiI
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • 2017/30/MainiI/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1/FysiikkaPeli1.cs

    r9124 r9137  
    1111    Image kenttaKuva = LoadImage("Kentta"); 
    1212    Image Pahankuva = LoadImage("Pahis"); 
     13    PlatformCharacter OlioH; 
    1314    public override void Begin() 
    1415    { 
    15          LuoOlio(); 
    1616         Luokenttä(); 
     17         LuoOhjaimet(); 
    1718 
    1819        Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 
    19         Camera.ZoomToLevel(); 
     20        Camera.ZoomToLevel(-1000); 
    2021 
    2122    } 
    22     void LuoOlio() 
    23     { 
    24         
    25  
    26     } 
    27  
    2823    void Luokenttä() 
    2924    { 
     
    3833    void LuoOlioH(Vector paikka, double leveys, double korkeus) 
    3934    { 
    40         PlatformCharacter OlioH = new PlatformCharacter(leveys, korkeus); 
     35        OlioH = new PlatformCharacter(leveys, korkeus); 
    4136        OlioH.Position = paikka; 
    4237        //AddCollisionHandler(OlioH, "Pahis", TormaaVihuun);  
     
    6560        OlioP.Shape = Shape.Circle; 
    6661 
    67         RandomMoverBrain satunnaisAivot = new RandomMoverBrain(200); 
    68  
    69         List<Vector> polku = new List<Vector>(); 
    70  
    71         polkuAivot = OlioP; 
     62        PathFollowerBrain polkuAivot = new PathFollowerBrain(200); 
     63        OlioP.Brain = polkuAivot; 
    7264 
    7365        polkuAivot.Active = true; 
     66        polkuAivot.TurnWhileMoving = true; 
    7467        polkuAivot.Speed = 100; 
    7568 
     
    7972        polku.Add(new Vector(-100, 50)); 
    8073        polku.Add(new Vector(-250, -200)); 
     74 
    8175        polkuAivot.Path = polku; 
    8276        polkuAivot.Loop = true; 
     77 
     78    } 
     79    void LuoOhjaimet() 
     80    { 
     81        Keyboard.Listen(Key.Left, ButtonState.Down,  
     82        LiikutaPelaajaa, null, new Vector(-29000, 0)); 
     83        Keyboard.Listen(Key.Right, ButtonState.Down, 
     84        LiikutaPelaajaa, null, new Vector(29000, 0)); 
     85        Keyboard.Listen(Key.Up, ButtonState.Down, 
     86        LiikutaPelaajaa, null, new Vector(0, 2000)); 
     87        Keyboard.Listen(Key.Down, ButtonState.Down, 
     88        LiikutaPelaajaa, null, new Vector(0, -2000)); 
     89 
     90    } 
     91    void LiikutaPelaajaa(Vector vektori) 
     92    { 
     93       OlioH.Push(vektori); 
    8394    } 
    8495} 
Note: See TracChangeset for help on using the changeset viewer.