- Timestamp:
- 2010-06-08 14:14:19 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/laemkaup/Pong/Peli.cs
r531 r551 11 11 PhysicsObject maila1; 12 12 PhysicsObject maila2; 13 Vector nopeusYlos = new Vector ( 0, 200); 14 Vector nopeusAlas = new Vector ( 0, -200); 13 15 14 16 protected override void Begin() … … 49 51 50 52 51 voidLuoMaila(double x, double y)53 PhysicsObject LuoMaila(double x, double y) 52 54 { 53 55 PhysicsObject maila = PhysicsObject.CreateStaticObject (20.0, 100.0); … … 63 65 void AsetaOhjaimet() 64 66 { 65 Keyboard.Listen(Key.A, ButtonState.Pressed, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös", maila1 ); 66 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null, maila1 ); 67 Keyboard.Listen(Key.A, ButtonState.Pressed, LiikutaMailaaYlos, "Pelaaja 1: Liikuta mailaa ylös", maila1, nopeusYlos ); 68 Keyboard.Listen(Key.A, ButtonState.Released, PysaytaMaila, null, maila1, Vector.Zero ); 69 Keyboard.Listen(Key.Z, ButtonState.Pressed, LiikutaMailaaAlas, "Pelaaja1: Liikuta mailaa alas", maila1,nopeusAlas ); 70 Keyboard.Listen(Key.Z, ButtonState.Released, PysaytaMaila, null, maila1, Vector.Zero ); 67 71 72 Keyboard.Listen(Key.Up, ButtonState.Pressed, LiikutaMailaaYlos, "Pelaaja2: Liikuta mailaa ylös", maila2, nopeusYlos ); 73 Keyboard.Listen(Key.Up, ButtonState.Released, PysaytaMaila, null, maila2, Vector.Zero); 74 Keyboard.Listen(Key.Down, ButtonState.Pressed, LiikutaMailaaAlas, "Pelaaja2: Liikuta mailaa alas", maila2, nopeusAlas ); 75 Keyboard.Listen(Key.Down, ButtonState.Released, PysaytaMaila, null, maila2, nopeusAlas ); 76 77 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 68 78 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 69 79 70 80 71 81 } 72 void LiikutaMailaaYlos( PhysicsObject maila)82 void LiikutaMailaaYlos(PhysicsObject maila) 73 83 { 74 Vector nopeus = new Vector ( 0, 200 ); 75 maila.Velocity = nopeus; 84 if (maila.Y <= Level.Top) 85 { 86 maila.Velocity = Vector.Zero; 87 return; 88 } Vector nopeus = new Vector(0, 200); 89 maila.Velocity = nopeus; 76 90 } 77 91 void PysaytaMaila ( PhysicsObject maila ) 78 92 { 93 maila.Velocity = Vector.Zero; 79 94 } 95 void LiikutaMailaaAlas(PhysicsObject maila) 96 { 97 Vector nopeus = new Vector(0, -200); 98 maila.Velocity = nopeus; 99 } 100 { void AsetaNopeus(PhysicsObject maila, Vector nopeus); 101 { 102 } if ( (nopeus.Y > 0 ) && ( maila.Y < Level.Bottom) ) 103 maila.Velocity = 80 104 81 105
Note: See TracChangeset
for help on using the changeset viewer.