Changeset 736
- Timestamp:
- 2010-06-11 11:29:27 (13 years ago)
- Location:
- 2010/23/lasakauh/Testi
- Files:
-
- 1 deleted
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/lasakauh/Testi/Content/Content.contentproj
r717 r736 19 19 </PropertyGroup> 20 20 <ItemGroup> 21 <Compile Include="maali.wav">22 <Name>maali</Name>23 <Importer>WavImporter</Importer>24 <Processor>SoundEffectProcessor</Processor>25 </Compile>26 </ItemGroup>27 <ItemGroup>28 21 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.AudioImporters, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> 29 22 <Reference Include="Microsoft.Xna.Framework.Content.Pipeline.EffectImporter, Version=3.1.0.0, Culture=neutral, PublicKeyToken=6d5c3888ef60e27d" /> -
2010/23/lasakauh/Testi/Peli.cs
r717 r736 1 1 using System; 2 using System.Collections.Generic; 2 3 using Jypeli; 3 4 using Jypeli.ScreenObjects; … … 17 18 PlatformCharacter p2; 18 19 19 int hp1 = 102; 20 int hp2 = 102; 20 int hp1 = 502; 21 int hp2 = 502; 22 23 Stack<PhysicsObject> hiparit = new Stack<PhysicsObject>(); 24 Stack<PhysicsObject> hiparit1 = new Stack<PhysicsObject>(); 21 25 22 26 … … 56 60 hpbar1(); 57 61 lisaaTaso(0, -154); 62 lisaaSeina(Level.Left -1, Tuhousr); 63 lisaaSeina(Level.Right +1, Tuhousl); 58 64 hpbar2(); 59 65 hpp1(145,100); … … 70 76 } 71 77 72 void lisaaSeina(double x,double y) 73 { 74 PhysicsObject taso = PhysicsObject.CreateStaticObject(10, 30); 75 taso.Image = LoadImage("taso_pystyseina"); 78 void lisaaSeina(double x, CollisionHandler handi) 79 { 80 PhysicsObject taso = PhysicsObject.CreateStaticObject(2, 300); 76 81 taso.X = x; 77 taso.Y = y; 82 taso.Y = 0; 83 AddCollisionHandler(taso ,handi); 78 84 Add(taso); 79 85 } … … 85 91 taso.X = x; 86 92 taso.Y = y; 87 AddCollisionHandler(taso,Tuhous );93 AddCollisionHandler(taso,Tuhousu); 88 94 Add(taso); 89 95 } 90 96 91 void Tuhous(PhysicsObject taso, PhysicsObject kohde) 92 { 93 kohde.Destroy(); 94 MessageDisplay.Add("Pelaaja tuhoutui"); 97 void Tuhousr(PhysicsObject taso, PhysicsObject kohde) 98 { 99 kohde.X = 140; 100 } 101 void Tuhousl(PhysicsObject taso, PhysicsObject kohde) 102 { 103 kohde.X = -140; 104 } 105 void Tuhousu(PhysicsObject taso, PhysicsObject kohde) 106 { 107 kohde.Y = 140; 95 108 } 96 109 void lisaaPelaajat() … … 131 144 Keyboard.Listen(Key.D, ButtonState.Down, liikutaEteenp1, "Liikkuu oikealle", p1,nopeusEteen); 132 145 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", p1, hyppyVoima); 133 Keyboard.Listen(Key.S, ButtonState. Pressed, iske,"iskee");146 Keyboard.Listen(Key.S, ButtonState.Down, iske,"iskee"); 134 147 Keyboard.Listen(Key.S, ButtonState.Released, lp_isku, "lopettaaiskun"); 135 148 … … 137 150 Keyboard.Listen(Key.Right, ButtonState.Down, liikutaEteenp2, "Liikkuu oikealle", p2, nopeusEteen); 138 151 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", p2, hyppyVoima); 139 Keyboard.Listen(Key.Down, ButtonState. Pressed, iske2, "iskee");152 Keyboard.Listen(Key.Down, ButtonState.Down, iske2, "iskee"); 140 153 Keyboard.Listen(Key.Down, ButtonState.Released, lp_isku2, "lopettaa iskun"); 141 154 … … 194 207 void hpp1(double x, double hp1) 195 208 { 196 for (int i = 1; i < hp1; i++) 197 { 209 for (int i = 1; i < hp1; i++) 210 { 211 198 212 PhysicsObject hpp1 = PhysicsObject.CreateStaticObject(1, 8.5); 199 213 hpp1.Shape = Shapes.Rectangle; 200 214 hpp1.Color = Color.Green; 201 hpp1.X = -146 +i;215 hpp1.X = -146 + i; 202 216 hpp1.Y = 144.8; 203 217 Add(hpp1); 204 218 hiparit.Push(hpp1); 219 205 220 } 206 221 } … … 215 230 hpp2.Y = 144.8; 216 231 Add(hpp2); 217 } 232 hiparit1.Push(hpp2); 233 } 234 218 235 } 219 236 … … 234 251 p1.Animation.FPS = 20; 235 252 } 236 hp2 = hp2 - 10; 237 } 238 239 void iske2() 240 { 253 for (int i = 0; i < 5; i++) 254 { 255 if (hiparit1.Count != 0) 256 { 257 hiparit1.Pop().Destroy(); 258 } 259 if (hiparit1.Count == 0) 260 { 261 p2.Destroy(); 262 MessageDisplay.Add("Pelaaja 1 voitti"); 263 ClearAll(); 264 Begin(); 265 } 266 } 267 } 268 269 void iske2() 270 { 271 if (Vector.Distance(p1.Position, p2.Position) == 10) 272 { 273 274 if (p2.FacingDirection == Direction.Left) 275 { 276 Image[] p2Kuvat = LoadImages("b1", "b2", "b3", "b4"); 277 p2.Animation = new Animation(p2Kuvat); 278 p2.Animation.Start(); 279 p2.Animation.FPS = 20; 280 hp1 = hp1 - 10; 281 282 } 283 if (p2.FacingDirection == Direction.Right) 284 { 285 Image[] p22Kuvat = LoadImages("b1_l", "b2_l", "b3_l", "b4_l"); 286 p2.Animation = new Animation(p22Kuvat); 287 p2.Animation.Start(); 288 p2.Animation.FPS = 20; 289 hp1 = hp1 - 10; 290 291 292 } 293 for (int i = 0; i < 5; i++) 294 { 295 if (hiparit.Count != 0) 296 { 297 hiparit.Pop().Destroy(); 298 } 299 if (hiparit.Count == 0) 300 { 301 p1.Destroy(); 302 MessageDisplay.Add("Pelaaja 2 voitti"); 303 ClearAll(); 304 Begin(); 305 } 306 } 307 } 308 } 309 310 311 void lp_isku() 312 { 313 if (p1.FacingDirection == Direction.Right) 314 { 315 p1.Image = LoadImage("ninja"); 316 } 317 if (p1.FacingDirection == Direction.Left) 318 { 319 p1.Image = LoadImage("ninja_l"); 320 } 321 } 322 323 void lp_isku2() 324 { 325 241 326 if (p2.FacingDirection == Direction.Left) 242 327 { 243 Image[] p2Kuvat = LoadImages("b1", "b2", "b3", "b4"); 244 p2.Animation = new Animation(p2Kuvat); 245 p2.Animation.Start(); 246 p2.Animation.FPS = 20; 247 hp1 = hp1 - 10; 328 p2.Image = LoadImage("ninja2"); 248 329 } 249 330 if (p2.FacingDirection == Direction.Right) 250 331 { 251 Image[] p22Kuvat = LoadImages("b1_l", "b2_l", "b3_l", "b4_l");252 p2.Animation = new Animation(p22Kuvat);253 p2.Animation.Start();254 p2.Animation.FPS = 20;255 hp1 = hp1 - 10;256 }257 }258 259 void lp_isku()260 {261 if (p1.FacingDirection == Direction.Right)262 {263 p1.Image = LoadImage("ninja");264 }265 if (p1.FacingDirection == Direction.Left)266 {267 p1.Image = LoadImage("ninja_l");268 }269 }270 271 void lp_isku2()272 {273 if (p2.FacingDirection == Direction.Left)274 {275 p2.Image = LoadImage("ninja2");276 }277 if (p2.FacingDirection == Direction.Right)278 {279 332 p2.Image = LoadImage("ninja2_l"); 280 333 } 334 281 335 } 282 336 }
Note: See TracChangeset
for help on using the changeset viewer.