- Timestamp:
- 2010-07-09 13:04:48 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/27/heikriin/CrabsAndShrimps/Peli.cs
r1223 r1229 12 12 PlatformCharacter rapu; 13 13 14 15 16 14 IntMeter pisteLaskuri; 17 15 IntMeter katkisElamat, rapuElamat; 18 16 19 20 21 17 protected override void Begin() 22 18 { 23 AloitaPeli();24 19 luoKentta(); 25 20 26 27 28 21 katkis = new PlatformCharacter(220.0, 220.0); 29 22 Add(katkis); … … 32 25 katkis.Y = -250.0; 33 26 katkis.Image = LoadImage("katkis"); 34 35 36 //pannu = new GameObject(500, 500);37 //pannu.Color = Color.Red;38 //pannu.Tag = "pannu";39 //Add(pannu);40 //katkis.Add(pannu);41 27 42 28 rapu = new PlatformCharacter(300.0, 300.0); … … 47 33 rapu.Image = LoadImage("rapu"); 48 34 49 //kukka = new GameObject(500, 500);50 //kukka.Color = Color.Red;51 //rapu.Add(kukka);52 53 54 AddCollisionHandler(katkis, katkisTormaa);55 AddCollisionHandler(rapu, rapuTormaa);56 35 57 36 Level.CreateBorders(false); … … 59 38 60 39 Camera.ZoomToLevel(); 61 40 62 41 Gravity = new Vector(0.0, -800.0); 63 42 lisaaNappaimet(); … … 78 57 Keyboard.Listen(Key.D, ButtonState.Down, liikuta, "Liikkuu oikealle", rapu, 100.0); 79 58 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", rapu, hyppyVoima); 80 Keyboard.Listen(Key.Q, ButtonState.Pressed, rapuiskee, "Kukka"); 59 Keyboard.Listen(Key.Q, ButtonState.Pressed, rapuiskee, "Kukka"); 81 60 82 61 } 83 84 85 86 87 62 88 63 void katkisiskee() 89 64 { 90 Image[] katkisKuvat = LoadImages("katkis", "katkisiskee", "katkisiskee", "katkisiskee"); 65 Image[] katkisKuvat; 66 if (katkis.X > rapu.X) 67 { 68 katkisKuvat = LoadImages("katkis", "katkisiskee", "katkisiskee", "katkisiskee"); 69 } 70 else 71 { 72 katkisKuvat = new Image[]{ 73 Image.Mirror(LoadImage("katkis")), 74 Image.Mirror(LoadImage("katkisiskee")), 75 Image.Mirror(LoadImage("katkisiskee")), 76 Image.Mirror(LoadImage("katkisiskee")) 77 }; 78 79 } 80 91 81 katkis.Animation = new Animation(katkisKuvat); 92 82 katkis.Animation.Start(1); 93 83 Vector etaisyys = new Vector(katkis.X - rapu.X, katkis.Y - rapu.Y); 94 if (etaisyys.Magnitude < 300)84 if (etaisyys.Magnitude < 300) 95 85 { 96 rapuElamat.Value -= 5;86 rapuElamat.Value -= 5; 97 87 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("bang"), 1); 98 88 Add(rajahdys); … … 109 99 void rapuiskee() 110 100 { 111 Image[] rapuKuvat = LoadImages("rapu", "rapuiskee", "rapuiskee", "rapuiskee"); 101 Image[] rapuKuvat; 102 if (rapu.X < katkis.X) 103 { 104 rapuKuvat = LoadImages("rapu", "rapuiskee", "rapuiskee", "rapuiskee"); 105 } 106 else 107 { 108 rapuKuvat = new Image[] 109 { 110 Image.Mirror(LoadImage("rapu")), 111 Image.Mirror(LoadImage("rapuiskee")), 112 Image.Mirror(LoadImage("rapuiskee")), 113 Image.Mirror(LoadImage("rapuiskee")) 114 }; 115 } 116 112 117 rapu.Animation = new Animation(rapuKuvat); 113 118 rapu.Animation.Start(1); 114 119 Vector etaisyys = new Vector(katkis.X - rapu.X, katkis.Y - rapu.Y); 115 120 if (etaisyys.Magnitude < 300) 116 117 121 { 118 katkisElamat.Value -= 5;122 katkisElamat.Value -= 5; 119 123 120 124 ExplosionSystem rajahdys = new ExplosionSystem(LoadImage("loyh"), 1); 121 125 Add(rajahdys); 122 126 rajahdys.AddEffect(0, 0, 1); 123 124 127 } 125 126 127 128 128 129 if (katkisElamat.Value <= 0) … … 132 133 } 133 134 134 135 136 135 } 137 136 … … 152 151 } 153 152 154 void katkisTormaa(PhysicsObject katkis, PhysicsObject kohde)155 {156 //if (kohde.Tag.ToString() == "pannu")157 //{158 // MessageDisplay.Add("katkikseen osui");159 //}160 }161 153 162 void rapuTormaa(PhysicsObject rapu, PhysicsObject kohde)163 {164 165 }166 154 void LuoLaskuri() 167 155 { … … 191 179 } 192 180 193 194 195 void AloitaPeli()196 { }197 198 181 void LopetusRuutu() 199 182 { 200 183 ClearAll(); 201 184 202 185 MessageDisplay.TextColor = Color.White; 203 186 MessageDisplay.Position = new Vector(00, 00); 204 187 205 Keyboard.Listen(Key.V, ButtonState.Pressed, Begin, null);188 Keyboard.Listen(Key.V, ButtonState.Pressed, Begin, null); 206 189 207 190 208 191 } 209 192 210 211 212 213 214 215 216 217 218 193 }
Note: See TracChangeset
for help on using the changeset viewer.