Ignore:
Timestamp:
2010-06-09 14:53:41 (13 years ago)
Author:
ekeimaja
Message:

Pelaajat liikkuvat nyt

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 2010/23/ekeimaja/Labyrinth/Labyrinth/Peli.cs

    r609 r618  
    88namespace Labyrinth // © Eki Majankallio 2010 
    99{ 
    10     public class Peli : Game 
     10    public class Peli : PhysicsGame 
    1111    { 
    12         GameObject Pelaaja1; 
     12        PhysicsObject Pelaaja1; 
     13        PhysicsObject Pelaaja2; 
    1314 
    1415        const int RuudunLeveys = 50; 
     
    3738        } 
    3839 
    39         GameObject LuoPelaaja1() 
     40        PhysicsObject LuoPelaaja1() 
    4041        { 
    41             Pelaaja1 = new GameObject(50.0,50.0); 
     42            Pelaaja1 = new PhysicsObject(40.0,40.0); 
     43            Pelaaja1.IgnoresPhysicsLogics = true; 
     44            Pelaaja1.CanRotate = false;  
    4245            Pelaaja1.Image = LoadImage("player1"); 
    4346            Add(Pelaaja1); 
     
    4649        } 
    4750 
    48         GameObject LuoPelaaja2() 
     51        PhysicsObject LuoPelaaja2() 
    4952        { 
    50             GameObject Pelaaja2 = new GameObject(50.0, 50.0); 
     53            Pelaaja2 = new PhysicsObject(40.0, 40.0); 
     54            Pelaaja2.IgnoresPhysicsLogics = true; 
     55            Pelaaja2.CanRotate = false; 
    5156            Pelaaja2.Image = LoadImage("player2"); 
    5257            Add(Pelaaja2); 
     
    8287            PhysicsObject seina = PhysicsObject.CreateStaticObject(50.0, 50.0); 
    8388            seina.Shape = Shapes.Rectangle; 
     89            seina.Restitution = 0.0; 
    8490            seina.Color = Color.Black; 
    8591            return seina; 
     
    8894        void LuoOhjain() 
    8995        { 
    90  
     96            //näppäin alhaalla 
    9197            Keyboard.Listen(Key.Left, ButtonState.Down, LiikutaPelaajaaVasemmalle, null); 
    9298            Keyboard.Listen(Key.Right, ButtonState.Down, LiikutaPelaajaaOikealle, null); 
    9399            Keyboard.Listen(Key.Up, ButtonState.Down, LiikutaPelaajaaYlos, null); 
    94100            Keyboard.Listen(Key.Down, ButtonState.Down, LiikutaPelaajaaAlas, null); 
     101            Keyboard.Listen(Key.A, ButtonState.Down, LiikutaPelaaja2Vasemmalle, null); 
     102            Keyboard.Listen(Key.D, ButtonState.Down, LiikutaPelaaja2Oikealle, null); 
     103            Keyboard.Listen(Key.W, ButtonState.Down, LiikutaPelaaja2Ylos, null); 
     104            Keyboard.Listen(Key.S, ButtonState.Down, LiikutaPelaaja2Alas, null); 
     105            //näppäin ylhäällä 
     106            Keyboard.Listen(Key.Left, ButtonState.Released, Pelaaja1.StopHorizontal, null); 
     107            Keyboard.Listen(Key.Right, ButtonState.Released, Pelaaja1.StopHorizontal, null); 
     108            Keyboard.Listen(Key.Up, ButtonState.Released, Pelaaja1.StopVertical, null); 
     109            Keyboard.Listen(Key.Down, ButtonState.Released, Pelaaja1.StopVertical, null); 
     110            Keyboard.Listen(Key.A, ButtonState.Released, Pelaaja2.StopHorizontal, null); 
     111            Keyboard.Listen(Key.D, ButtonState.Released, Pelaaja2.StopHorizontal, null); 
     112            Keyboard.Listen(Key.W, ButtonState.Released, Pelaaja2.StopVertical, null); 
     113            Keyboard.Listen(Key.S, ButtonState.Released, Pelaaja2.StopVertical, null); 
    95114             
    96115        } 
    97116 
    98  
     117        //pelaaja1 
    99118        void LiikutaPelaajaaVasemmalle() 
    100119        { 
    101             Pelaaja1.Move(new Vector(-20, 0)); 
     120            Pelaaja1.Hit(new Vector(-10, 0)); 
    102121        } 
    103122 
    104123        void LiikutaPelaajaaOikealle() 
    105124        { 
    106             Pelaaja1.Move(new Vector(20, 0)); 
     125            Pelaaja1.Hit(new Vector(20, 0)); 
    107126        } 
    108127 
    109128        void LiikutaPelaajaaYlos() 
    110129        { 
    111             Pelaaja1.Move(new Vector(0, -0)); 
     130            Pelaaja1.Hit(new Vector(0, 10)); 
    112131        } 
    113132 
    114133        void LiikutaPelaajaaAlas() 
    115134        { 
    116             Pelaaja1.Move(new Vector(-0, 0)); 
     135            Pelaaja1.Hit(new Vector(0, -10)); 
     136       } 
     137        //Pelaaja2 
     138        void LiikutaPelaaja2Vasemmalle() 
     139        { 
     140            Pelaaja2.Hit(new Vector(-10, 0)); 
     141        } 
     142 
     143        void LiikutaPelaaja2Oikealle() 
     144        { 
     145            Pelaaja2.Hit(new Vector(20, 0)); 
     146        } 
     147 
     148        void LiikutaPelaaja2Ylos() 
     149        { 
     150            Pelaaja2.Hit(new Vector(0, 10)); 
     151        } 
     152 
     153        void LiikutaPelaaja2Alas() 
     154        { 
     155            Pelaaja2.Hit(new Vector(0, -10)); 
    117156        } 
    118157 
Note: See TracChangeset for help on using the changeset viewer.