Changeset 2788 for 2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/YAG2DSS.cs
- Timestamp:
- 2012-06-05 10:36:54 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/23/RamiP/YAG2DSSBase/YAG2DSS/YAG2DSS/YAG2DSS.cs
r2785 r2788 13 13 { 14 14 ALTKHandler altkHandler; 15 PhysicsObject po;16 15 GameObject Kursori; 17 18 ExplosionSystem expSystem;19 16 20 17 public override void Begin() 21 18 { 19 #region Cursor handling 22 20 Kursori = new GameObject(32, 32); 23 21 Kursori.Image = Image.FromStream(File.OpenRead(ALTKConstants.TexturePath + "cursor.png")); … … 26 24 Mouse.ListenMovement(0.1, handler, ""); 27 25 Add(Kursori); 26 #endregion 28 27 29 expSystem = new ExplosionSystem(Image.FromStream(File.OpenRead(ALTKConstants.TexturePath + "communist_trollface.png")), 500); 30 Add(expSystem); 28 //PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 29 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ShowExit, "Lopeta peli"); 30 } 31 31 32 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 33 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ShowExit, "Lopeta peli"); 34 Keyboard.Listen(Key.LeftControl, ButtonState.Down, ShootProjectile, ""); 35 36 //IsMouseVisible = true; 37 38 Level.CreateBorders(0.5, false); 39 40 po = new PhysicsObject(50.0, 50.0); 41 po.Shape = Shape.Octagon; 42 po.X = -200; 43 po.Y = -150.0; 44 po.Restitution = 1.0; 45 po.AngularDamping = 0.02; 46 po.MomentOfInertia = 50.0; 47 AddCollisionHandler(po, HandleCollision); 48 po.Image = Image.FromStream(File.OpenRead(ALTKConstants.TexturePath + "communist_trollface.png")); 49 Add(po); 50 //AddCollisionHandler(po, 51 po.Hit(new Vector(500.0, 0.0)); 52 53 Light light = new Light(); 54 light.Distance = 75.0; 55 light.Intensity = 0.75; 56 Add(light); 57 } 32 #region XNA / ALTK-Based Code 58 33 59 34 private void HandleCursor(AnalogState analogState) 60 35 { 61 36 Kursori.AbsolutePosition = new Vector(Kursori.Position.X + analogState.MouseMovement.X, Kursori.Position.Y + analogState.MouseMovement.Y); 62 }63 64 private void HandleCollision(PhysicsObject x, PhysicsObject y)65 {66 if (x.Velocity.X < 0)67 {68 if (x.Velocity.Y < 0)69 {70 ALTKHandler.StaticAnimHandler.AddStaticAnim(0, new Microsoft.Xna.Framework.Vector2(Convert.ToSingle(x.Right), Convert.ToSingle(x.Bottom)));71 }72 else73 {74 ALTKHandler.StaticAnimHandler.AddStaticAnim(0, new Microsoft.Xna.Framework.Vector2(Convert.ToSingle(x.Right), Convert.ToSingle(x.Top)));75 }76 }77 else78 {79 if (x.Velocity.Y < 0)80 {81 ALTKHandler.StaticAnimHandler.AddStaticAnim(0, new Microsoft.Xna.Framework.Vector2(Convert.ToSingle(x.Left), Convert.ToSingle(x.Bottom)));82 }83 else84 {85 ALTKHandler.StaticAnimHandler.AddStaticAnim(0, new Microsoft.Xna.Framework.Vector2(Convert.ToSingle(x.Left), Convert.ToSingle(x.Top)));86 }87 }88 89 expSystem.AddEffect(new Vector(x.X, x.Y), 1000);90 37 } 91 38 … … 95 42 96 43 InitALTK(); 97 }98 99 private void ShootProjectile()100 {101 Projectile proj = new Projectile(40.0, 10.0, Color.Red);102 proj.Position = Vector.ComponentProduct(po.Position, Vector.FromLengthAndAngle(po.Width, po.Angle));103 proj.Image = Image.FromStream(File.OpenRead(ALTKConstants.TexturePath + "communist_trollface.png"));104 Add(proj);105 proj.Hit(Vector.FromLengthAndAngle(100.0, po.Angle));106 44 } 107 45 … … 133 71 //MessageDisplay.Add(Convert.ToString(ALTK.Cursor.SecPosX + "; " + ALTK.Cursor.SecPosY)); 134 72 135 if (Keyboard.GetKeyState(Key.Up) == ButtonState.Down)136 {137 Vector impulssi = Vector.FromLengthAndAngle(2.0, po.Angle);138 po.Hit(impulssi);139 }73 //if (Keyboard.GetKeyState(Key.Up) == ButtonState.Down) 74 //{ 75 // Vector impulssi = Vector.FromLengthAndAngle(2.0, po.Angle); 76 // po.Hit(impulssi); 77 //} 140 78 141 if (Keyboard.GetKeyState(Key.Left) == ButtonState.Down)142 {143 po.Angle = Angle.FromDegrees(po.Angle.Degrees - 5.0);144 }79 //if (Keyboard.GetKeyState(Key.Left) == ButtonState.Down) 80 //{ 81 // po.Angle = Angle.FromDegrees(po.Angle.Degrees - 5.0); 82 //} 145 83 146 if (Keyboard.GetKeyState(Key.Right) == ButtonState.Down)147 {148 po.Angle = Angle.FromDegrees(po.Angle.Degrees + 5.0);149 }84 //if (Keyboard.GetKeyState(Key.Right) == ButtonState.Down) 85 //{ 86 // po.Angle = Angle.FromDegrees(po.Angle.Degrees + 5.0); 87 //} 150 88 151 if (Keyboard.GetKeyState(Key.Down) == ButtonState.Down)152 {153 if (po.Velocity.Angle == po.Angle)154 {155 Vector impulssi = Vector.FromLengthAndAngle(-2.0, po.Angle);156 po.Hit(impulssi);157 }158 }89 //if (Keyboard.GetKeyState(Key.Down) == ButtonState.Down) 90 //{ 91 // if (po.Velocity.Angle == po.Angle) 92 // { 93 // Vector impulssi = Vector.FromLengthAndAngle(-2.0, po.Angle); 94 // po.Hit(impulssi); 95 // } 96 //} 159 97 160 98 if (ALTK.GameHandler.DoUpdate) … … 191 129 } 192 130 } 131 132 #endregion 193 133 }
Note: See TracChangeset
for help on using the changeset viewer.