Changeset 1187 for 2010/27


Ignore:
Timestamp:
2010-07-08 14:45:57 (13 years ago)
Author:
jupepaiv
Message:

Tein hahmot valmiiksi ja loitin kentän suunnittelua

Location:
2010/27/Jupepaiv/Nemesis Duels
Files:
5 edited
1 copied

Legend:

Unmodified
Added
Removed
  • 2010/27/Jupepaiv/Nemesis Duels/Peli.cs

    r1163 r1187  
    66public class Peli : PhysicsGame 
    77{ 
     8 
     9    const double nopeus = 400; 
     10    const double hyppyVoima = 1500; 
     11 
     12 
     13    const int ruudunLeveys = 50; 
     14    const int ruudunKorkeus = 50; 
     15 
     16    PlatformCharacter nemesis; 
     17    PlatformCharacter nemesis2; 
     18 
    819    protected override void Begin() 
    920    { 
    10         PhysicsObject Nemesis1 = new PhysicsObject( 40.0, 40.0 ); 
    11         Nemesis1.Shape = Shape.Rectangle; 
    12         Add.Nemesis1; 
     21        LuoKentta(); 
    1322    } 
     23 
     24    void LuoKentta() 
     25    { 
     26 
     27        Gravity = new Vector(0, -1500); 
     28        TileMap ruudut = TileMap.FromFile("kentta.txt"); 
     29        ruudut['='] = LuoPalikka; 
     30        ruudut.Insert(ruudunLeveys, ruudunKorkeus); 
     31 
     32        LisaaPelaajat(); 
     33        AsetaOhjaimet(); 
     34        Camera.ZoomToLevel(); 
     35 
     36    } 
     37 
     38    void LisaaPelaajat() 
     39    { 
     40        nemesis = new PlatformCharacter(100, 100); 
     41        nemesis.Shape = Shapes.Circle; 
     42 
     43        nemesis.Image = LoadImage("Nemesis1"); 
     44        nemesis.X = -100.0; 
     45        nemesis.Y = -200.0; 
     46        Add(nemesis); 
     47 
     48        nemesis2 = new PlatformCharacter(100, 100); 
     49        nemesis2.Shape = Shapes.Circle; 
     50        nemesis2.Image = LoadImage("Nemesis2"); 
     51        nemesis2.X = 100.0; 
     52        nemesis2.Y = -200.0; 
     53        Add(nemesis2); 
     54 
     55    } 
     56 
     57    PhysicsObject LuoPalikka() 
     58    { 
     59        PhysicsObject palikka = PhysicsObject.CreateStaticObject(50.0, 50.0); 
     60        palikka.Shape = Shapes.Rectangle; 
     61        palikka.Color = Color.Black; 
     62        return palikka; 
     63    } 
     64 
     65    void AsetaOhjaimet() 
     66    { 
     67        Keyboard.Listen(Key.A, ButtonState.Down, Liikuta, null, nemesis, -nopeus); 
     68        Keyboard.Listen(Key.D, ButtonState.Down, Liikuta, null, nemesis, nopeus); 
     69        Keyboard.Listen(Key.A, ButtonState.Released, nemesis.StopHorizontal, null); 
     70        Keyboard.Listen(Key.D, ButtonState.Released, nemesis.StopHorizontal, null); 
     71        Keyboard.Listen(Key.W, ButtonState.Pressed, Hyppaa, "Hyppää", nemesis, hyppyVoima); 
     72 
     73  
     74        Keyboard.Listen(Key.Left, ButtonState.Down, Liikuta, null, nemesis2, -nopeus); 
     75        Keyboard.Listen(Key.Right, ButtonState.Down, Liikuta, null, nemesis2, nopeus); 
     76        Keyboard.Listen(Key.Left, ButtonState.Released, nemesis2.StopHorizontal, null); 
     77        Keyboard.Listen(Key.Right, ButtonState.Released, nemesis2.StopHorizontal, null); 
     78        Keyboard.Listen(Key.Up, ButtonState.Pressed, Hyppaa, "Hyppää", nemesis2, hyppyVoima); 
     79 
     80        Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 
     81        Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 
     82    } 
     83 
     84    void Liikuta(PlatformCharacter hahmo, double nopeus) 
     85    { 
     86        hahmo.Walk(nopeus); 
     87    } 
     88 
     89    void Hyppaa(PlatformCharacter hahmo, double voima) 
     90    { 
     91        hahmo.Jump(voima); 
     92    } 
     93 
     94 
     95 
    1496} 
  • 2010/27/Jupepaiv/Nemesis Duels/kentta.txt

    r1164 r1187  
    1 ==================== 
    2 =                  = 
    3 =     =   =   =    = 
    4 =   =           =  = 
    5 = =              = = 
    6 =   =           =  = 
    7 =     =   =   =    = 
    8 ==================== 
    9  
     1==================================== 
     2=                                  = 
     3=                                  = 
     4=              ======              = 
     5=                                  = 
     6=                   =====          = 
     7=                                  = 
     8=                                  = 
     9=                       ======     = 
     10=                                  = 
     11=                                  = 
     12=               =======            = 
     13=                                  = 
     14=                                  = 
     15=      ========                    = 
     16=                                  = 
     17=               =======            = 
     18=                                  = 
     19=                                  = 
     20=    ======        ========        = 
     21=                                  = 
     22=                                  = 
     23=                                  = 
     24=                                  = 
     25=                                  = 
     26==================================== 
Note: See TracChangeset for help on using the changeset viewer.