- Timestamp:
- 2016-06-19 15:48:08 (7 years ago)
- Location:
- 2016/25/MiskaL/Pongis Khan
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2016/25/MiskaL/Pongis Khan/Pongis Khan/Pongis_Khan/Pongis_Khan.cs
r7456 r7465 9 9 public class Pongis_Khan : PhysicsGame 10 10 { 11 Vector nopeusYlös = new Vector(0, 200); 12 Vector nopeusAlas = new Vector(0, -200); 11 13 PhysicsObject pallo; 14 PhysicsObject maila2; 15 PhysicsObject maila; 12 16 public override void Begin() 13 17 { 14 18 15 19 LuoKentta(); 16 17 18 Vector impulssi = new Vector(1000.0, 0.0); 19 pallo.Hit(impulssi); 20 20 AloitaPeli(); 21 AsetaOhjaimet(); 22 23 24 25 21 26 Level.Background.CreateGradient(Color.Black, Color.Black); 22 27 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 23 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli");28 24 29 } 25 30 void LuoKentta() 26 31 { 27 32 pallo = new PhysicsObject(50, 50); 28 33 Add(pallo); 29 34 pallo.Shape = Shape.Circle; … … 31 36 pallo.X = -200.0; 32 37 pallo.Y = 0.0; 38 39 maila2= LuoMaila(Level.Left + 20.0, 0.0); 40 maila = LuoMaila(Level.Right - 20.0, 0.0); 41 42 33 43 Level.CreateBorders(1.0, false); 34 44 pallo.Restitution = 1.0; 35 45 Camera.ZoomToLevel(); 36 46 47 48 } 49 protected override void Update(Time time) 50 { 51 if (pallo != null && Math.Abs(pallo.Velocity.X) < 1000) 52 { 53 pallo.Velocity = new Vector(pallo.Velocity.X * 1.1, pallo.Velocity.Y); 54 } 55 base.Update(time); 56 57 } 58 void AloitaPeli() 59 { 60 61 Vector impulssi = new Vector(1000.0, 0.0); 62 pallo.Hit(impulssi); 63 } 64 PhysicsObject LuoMaila(double x, double y) { 37 65 PhysicsObject maila = PhysicsObject.CreateStaticObject(20.0, 100.0); 38 66 maila.Shape = Shape.Rectangle; 39 maila.X = Level.Left + 20.0;40 maila.Y = 0.0;67 maila.X = x; 68 maila.Y = y; 41 69 maila.Restitution = 1.0; 42 70 Add(maila); 71 return maila; 43 72 } 44 } 73 void AsetaOhjaimet() 74 { 75 Keyboard.Listen(Key.W, ButtonState.Down, AsetaNopeus, maila, nopeusYlös, ""); 76 Keyboard.Listen(Key.W, ButtonState.Released, AsetaNopeus, "", maila, Vector. Zero); 77 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 78 Keyboard.Listen(Key.Up, ButtonState.Down, AsetaNopeus ,maila2 ""); 79 Keyboard.Listen(Key.Up, ButtonState.Released, AsetaNopeus,maila2, Vector. Zero); 80 Keyboard.Listen(Key.S, ButtonState.Down, AsetaNopeus, maila, ); 81 Keyboard.Listen(Key.S, ButtonState.Released, AsetaNopeus, , maila, Vector.Zero); 82 } 83 void AsetaNopeus(PhysicsObject maila, Vector nopeus) 84 { 85 maila.Velocity = nopeus; 86 87 88 89 90 91 92 93 94 95 96 }
Note: See TracChangeset
for help on using the changeset viewer.