Ignore:
Timestamp:
2010-07-07 14:56:04 (13 years ago)
Author:
vekakart
Message:

loin pelin osia

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/27/Vekakart/Catch The Rainbow/Catch The Rainbow/Peli.cs

    r1129 r1156  
    77 
    88{ 
     9    const int ruudunleveys = 50; 
     10    const int ruudunkorkeus = 50; 
     11 
     12    Vector NopeusEteen = new Vector(200, 0); 
     13 
     14    PlatformCharacter Chandler; 
     15 
    916    protected override void Begin() 
    1017    { 
    1118        LuoChandler(); 
     19        AsetaOhjaimet(); 
    1220        LuoKentta(); 
    13         AsetaOhjaimet(); 
     21         
    1422    } 
    1523    void LuoKentta() 
    1624    { 
    17         Level.CreateBorders (); 
     25        Camera.FollowedObject = Chandler; 
     26 
     27        TileMap ruudut = TileMap.FromFile("Kentta1.txt"); 
     28        ruudut ['='] = LuoPalikka; 
     29        ruudut['C'] = LuoRainbow; 
     30        ruudut.Insert(ruudunleveys, ruudunkorkeus); 
     31 
    1832        Gravity = new Vector(0.0, -800.0); 
    1933         
     34    } 
     35    PhysicsObject LuoPalikka() 
     36    { 
     37        PhysicsObject Palikka = PhysicsObject.CreateStaticObject(50, 50); 
     38        Palikka.Color = Color.Brown; 
     39        return Palikka; 
     40    } 
     41   PhysicsObject LuoRainbow() 
     42    { 
     43        PhysicsObject Rainbow = PhysicsObject.CreateStaticObject(25, 25); 
     44       Rainbow.Image = Image.FromFile (" 
     45        return Rainbow; 
    2046    } 
    2147 
    2248    void LuoChandler() 
    2349    { 
    24         PhysicsObject Chandler = new PhysicsObject(20,60); 
     50        Chandler = new PlatformCharacter(20,45); 
    2551        Chandler.Restitution = 0.0; 
     52        Chandler.CanRotate = false; 
    2653        Chandler.X = -450; 
    27         Chandler.Y = -375; 
     54        Chandler.Y = -365; 
     55        Chandler.KineticFriction = 0.0; 
    2856        Add (Chandler); 
    2957        return; 
    3058    } 
    3159 
    32     void AsetaOhjaimet(PhysicsObject Chandler) 
     60    void AsetaOhjaimet() 
    3361    { 
    34         Keyboard.Listen(Key.D, ButtonState.Down, PelaajaLiikuEteenpain); 
     62        Keyboard.Listen(Key.A, ButtonState.Down, PelaajaLiikuTaakse, "Liiku Taaksepäin"); 
     63        Keyboard.Listen(Key.A, ButtonState.Released, PelaajaPysahdy, null); 
     64        Keyboard.Listen(Key.D, ButtonState.Down, PelaajaLiikuEteenpain, "Liiku Eteenpäin"); 
     65        Keyboard.Listen(Key.D, ButtonState.Released, PelaajaPysahdy, null); 
     66        Keyboard.Listen(Key.W, ButtonState.Down, PelaajaHypaa, "Hyppää"); 
     67 
     68 
     69        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     70        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
    3571    } 
    3672    void PelaajaLiikuEteenpain() 
    3773    { 
     74        Chandler.Walk(200); 
     75    } 
     76 
     77    void PelaajaLiikuTaakse() 
     78    { 
     79        Chandler.Walk (-200); 
     80    } 
     81 
     82    void PelaajaPysahdy() 
     83    { 
     84        Vector nopeus = new Vector(0.0, 0); 
     85    } 
     86 
     87    void PelaajaHypaa() 
     88    { 
     89        Chandler.Jump(1000); 
    3890    } 
    3991} 
Note: See TracChangeset for help on using the changeset viewer.