Changeset 3310 for 2012/26/TuomasL/PhysicsManipulator/PhysicsManipulator/PhysicsManipulator/PhysicsManipulator.cs
- Timestamp:
- 2012-06-28 13:21:31 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2012/26/TuomasL/PhysicsManipulator/PhysicsManipulator/PhysicsManipulator/PhysicsManipulator.cs
r3293 r3310 8 8 9 9 //Lisätyt aliohjelmat: GetAllObjects, GetShapedObjects, GetObjectsByType, 10 //MakeTransparent, DestroyAll, DestroyShaped, Destroy 10 //MakeTransparent, DestroyAll, DestroyShaped, Destroy, GetButton 11 11 12 12 public class PhysicsManipulator : PhysicsGame { 13 13 14 TileMap map = TileMap.FromLevelAsset("kenttä"); 15 List<Vector> reitti = new List<Vector>(); 16 PhysicsObject pelaaja; 17 14 18 public override void Begin() { 15 19 20 map.SetTileMethod('1', TeeReitti); 21 vihu.Tag = "1"; 22 23 Image img = LoadImage("MainWithButtons"); 24 Image img2 = LoadImage("MainWithOutButtons"); 16 25 26 ImageButtons button = new ImageButtons(); 27 button.GetButton(img, img2, Color.White); 17 28 18 29 PhoneBackButton.Listen(ConfirmExit, "Lopeta peli"); 19 30 Mouse.Listen(MouseButton.Left, ButtonState.Pressed, Hiiren1Painettu, "Painetaan hiiren vasenta nappia"); 20 31 Keyboard.Listen(Key.Escape, ButtonState.Pressed, ConfirmExit, "Lopeta peli"); 32 } 33 34 protected override void Update(Time time) { 35 base.Update(time); 36 37 Liiku(vihu); 21 38 } 22 39 … … 58 75 59 76 } 77 78 void TeeReitti(Vector paikka, double x, double y) { 79 80 for(int i = 0; i < map.ColumnCount; i++) { 81 82 for (int i2 = 0; i2 < map.RowCount; i2++) { 83 84 switch (map.GetTile(i, i2)) { 85 86 case '1': 87 88 reitti.Insert(0, new Vector(i * 100 - 750, (i2 * 100 - 750) * -1)); 89 break; 90 case '2': 91 92 reitti.Insert(1, new Vector(i * 100 - 750, (i2 * 100 - 750) * -1)); 93 break; 94 case '3': 95 96 reitti.Insert(2, new Vector(i * 100 - 750, (i2 * 100 - 750) * -1)); 97 break; 98 case '4': 99 100 reitti.Insert(3, new Vector(i * 100 - 750, (i2 * 100 - 750) * -1)); 101 break; 102 default: 103 break; 104 } 105 } 106 } 107 } 108 109 void Liiku(PhysicsObject obj) { 110 111 if (pelaaja.Position.X > -600 & pelaaja.Position.X < 600 & pelaaja.Position.Y > -600 & pelaaja.Position.Y < 600) { 112 113 114 } else { 115 116 if (obj.Position == reitti[(int)obj.Tag]) { 117 118 if (reitti.Count != (int)obj.Tag) obj.Tag = (int)obj.Tag + 1; 119 else obj.Tag = 0; 120 } 121 122 Vector hit = reitti[(int)obj.Tag]; 123 obj.Hit(hit); 124 } 125 } 60 126 }
Note: See TracChangeset
for help on using the changeset viewer.