- Timestamp:
- 2014-07-01 10:43:04 (9 years ago)
- Location:
- 2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236
- Files:
-
- 1 added
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.cs
r5198 r5199 8 8 9 9 // apuva lista: 10 11 public class MikonPhysicsObject : PhysicsObject12 {13 private bool broken = false;14 private Protokolla236 game;15 public void Break(int method, int pieceCountX = 2, int pieceCountY = 2)16 {17 if (this.broken) { return; }18 this.Destroy();19 this.broken = true;20 switch (method)21 {22 case 0://uniform break23 var pieceWidth = this.Width / pieceCountX;24 var pieceHeight = this.Height / pieceCountY;25 if (pieceWidth < 1 || pieceHeight < 1) { return; }26 //loop x and y through27 //calc left corner28 var startCorner = Vector.FromLengthAndAngle(this.Width / 2 - pieceWidth / 2, this.AbsoluteAngle + Angle.StraightAngle) + Vector.FromLengthAndAngle(this.Height / 2 - pieceHeight / 2, this.AbsoluteAngle - Angle.RightAngle); //vasen alakulma29 30 for (int y = 0; y < pieceCountY; y++)31 {32 for (int x = 0; x < pieceCountX; x++)33 {34 MikonPhysicsObject childBox = new MikonPhysicsObject(this.game, pieceWidth, pieceHeight);35 childBox.Color = this.Color;36 childBox.AbsoluteAngle = this.AbsoluteAngle;37 childBox.AngularVelocity = this.AngularVelocity;38 39 childBox.Position = this.Position + startCorner40 + Vector.FromLengthAndAngle(x * pieceWidth, this.AbsoluteAngle) //plus x41 + Vector.FromLengthAndAngle(y * pieceHeight, this.AbsoluteAngle + Angle.RightAngle); //plus y42 43 childBox.Velocity = this.Velocity;44 45 //childBox.Position += offset;46 47 Game.Add(childBox);48 }49 }50 break;51 }52 }53 public MikonPhysicsObject(Protokolla236 game, double w, double h)54 : base(w, h)55 {56 // TODO: Complete member initialization57 //game.AddCollisionHandler(game.level, this, delegate { this.Break(0, 2, 2); });58 this.game = game;59 }60 }61 10 62 11 public class Portti : PhysicsObject -
2014/27/AleksanteriV/Protokolla236/Protokolla236/Protokolla236/Protokolla236.csproj
r5197 r5199 111 111 </ItemGroup> 112 112 <ItemGroup> 113 <Compile Include="MikonPhysicsObject.cs" /> 113 114 <Compile Include="Ohjelma.cs" /> 114 115 <Compile Include="Protokolla236.cs" />
Note: See TracChangeset
for help on using the changeset viewer.