- Timestamp:
- 2010-06-08 11:25:37 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/laemkaup/Pong/Peli.cs
r495 r531 8 8 public class Peli : PhysicsGame 9 9 { 10 PhysicsObject pallo; 11 PhysicsObject maila1; 12 PhysicsObject maila2; 13 10 14 protected override void Begin() 11 15 { 16 LuoKentta(); 17 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 18 19 AloitaPeli(); 12 20 13 21 … … 15 23 void LuoKentta() 16 24 { 17 PhysicsObject pallo = new PhysicsObject(50.8, 50.8); 25 26 pallo = new PhysicsObject(50.8, 50.8); 18 27 Add(pallo); 19 28 Level.CreateBorders(1.0, false); … … 24 33 pallo.Hit(impulssi); 25 34 pallo.Restitution = 1.0; 35 36 maila1 = LuoMaila(Level.Left + 20.0, 0.0); 37 maila2 = LuoMaila(Level.Right - 20.0, 0.0); 38 39 26 40 Level.BackgroundColor = Color.Green; 27 41 Camera.ZoomToLevel(); 28 42 } 29 43 44 void AloitaPeli() 45 { 46 Vector impulssi = new Vector(500.0, 0.0); 47 pallo.Hit(impulssi); 48 } 30 49 50 51 void LuoMaila(double x, double y) 52 { 53 PhysicsObject maila = PhysicsObject.CreateStaticObject (20.0, 100.0); 54 maila.Shape = Shapes.Rectangle; 55 maila.X = x; 56 maila.Y = y; 57 maila.Restitution = 1.0; 58 Add( maila ); 59 60 return maila; 61 62 } 63 void AsetaOhjaimet() 64 { 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 68 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu"); 69 70 71 } 72 void LiikutaMailaaYlos( PhysicsObject maila ) 73 { 74 Vector nopeus = new Vector ( 0, 200 ); 75 maila.Velocity = nopeus; 76 } 77 void PysaytaMaila ( PhysicsObject maila ) 78 { 79 } 80 81 31 82 } 83 32 84 }
Note: See TracChangeset
for help on using the changeset viewer.