Changeset 749
- Timestamp:
- 2010-06-11 13:06:59 (13 years ago)
- Location:
- 2010/23/lasakauh/Testi
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
2010/23/lasakauh/Testi/Content/Content.contentproj
r736 r749 228 228 </Compile> 229 229 </ItemGroup> 230 <ItemGroup> 231 <Compile Include="bg_m.mp3"> 232 <Name>bg_m</Name> 233 <Importer>Mp3Importer</Importer> 234 <Processor>SongProcessor</Processor> 235 </Compile> 236 </ItemGroup> 230 237 <Import Project="$(MSBuildExtensionsPath)\Microsoft\XNA Game Studio\$(XnaFrameworkVersion)\Microsoft.Xna.GameStudio.ContentPipeline.targets" /> 231 238 <!-- To modify your build process, add your task inside one of the targets below and uncomment it. -
2010/23/lasakauh/Testi/Peli.cs
r736 r749 13 13 const double nopeusTaakse = 100; 14 14 const double hyppyVoima = 4000; 15 const double isku = 10;16 15 17 16 PlatformCharacter p1; 18 17 PlatformCharacter p2; 19 18 20 int hp1 = 502;21 int hp2 = 502;19 int hp1 = 102; 20 int hp2 = 102; 22 21 23 22 Stack<PhysicsObject> hiparit = new Stack<PhysicsObject>(); … … 32 31 Camera.StayInLevel = true; 33 32 Gravity = new Vector(0, -1000); 34 33 StartNewRound(); 34 35 36 } 37 38 void StartNewRound() 39 { 35 40 luoKentta(); 36 41 lisaaNappaimet(); 37 42 voitto(p1, p2); 38 43 voitto(p2, p1); 39 40 41 42 } 43 44 MediaPlayer.Play("bg_m"); 45 } 46 44 47 void voitto(PlatformCharacter hahmo, PlatformCharacter voittaja) 45 48 { … … 63 66 lisaaSeina(Level.Right +1, Tuhousl); 64 67 hpbar2(); 65 hpp1(145 ,100);66 hpp2(-145 , 100);68 hpp1(145); 69 hpp2(-145); 67 70 } 68 71 … … 114 117 p1.X = -140; 115 118 p1.Y = Level.Bottom + 100; 116 Add(p1); 117 if (hp1 < 0) { 118 p1.Destroy(); 119 MessageDisplay.Add("Pelaaja 2 voitti"); 120 }; 121 119 Add(p1); 122 120 } 123 121 … … 130 128 p2.Y = Level.Bottom + 100; 131 129 Add(p2); 132 if (hp2 < 0) {133 p2.Destroy();134 };135 136 130 } 137 131 … … 140 134 Keyboard.Listen(Key.F1, ButtonState.Pressed, ShowControlHelp, "Näytä ohjeet"); 141 135 Keyboard.Listen(Key.Escape, ButtonState.Pressed, Exit, "Poistu pelistä"); 136 Keyboard.Listen(Key.M, ButtonState.Pressed, MediaPlayer.Pause, "Keskeyttää musiikin"); 142 137 143 138 Keyboard.Listen(Key.A, ButtonState.Down, liikutaTaakse, "Liikkuu vasemmalle", p1,nopeusTaakse); 144 139 Keyboard.Listen(Key.D, ButtonState.Down, liikutaEteenp1, "Liikkuu oikealle", p1,nopeusEteen); 145 140 Keyboard.Listen(Key.W, ButtonState.Pressed, hyppaa, "Hyppää", p1, hyppyVoima); 146 Keyboard.Listen(Key.S, ButtonState. Down, iske,"iskee");141 Keyboard.Listen(Key.S, ButtonState.Pressed, iske,"iskee"); 147 142 Keyboard.Listen(Key.S, ButtonState.Released, lp_isku, "lopettaaiskun"); 148 143 … … 150 145 Keyboard.Listen(Key.Right, ButtonState.Down, liikutaEteenp2, "Liikkuu oikealle", p2, nopeusEteen); 151 146 Keyboard.Listen(Key.Up, ButtonState.Pressed, hyppaa, "Hyppää", p2, hyppyVoima); 152 Keyboard.Listen(Key.Down, ButtonState. Down, iske2, "iskee");147 Keyboard.Listen(Key.Down, ButtonState.Pressed, iske2, "iskee"); 153 148 Keyboard.Listen(Key.Down, ButtonState.Released, lp_isku2, "lopettaa iskun"); 154 155 } 156 149 150 lisaaOhjaimet(); 151 } 152 153 void lisaaOhjaimet() 154 { 155 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, liikutaTaakse, "Liikkuu vasemmalle", p1, nopeusTaakse); 156 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikutaEteenp1, "Liikkuu oikealle", p1, nopeusEteen); 157 ControllerOne.Listen(Key.A, ButtonState.Pressed, hyppaa, "Hyppää", p1, hyppyVoima); 158 ControllerOne.Listen(Key.B, ButtonState.Pressed, iske, "iskee"); 159 ControllerOne.Listen(Key.B, ButtonState.Released, lp_isku, "lopettaaiskun"); 160 161 162 ControllerOne.Listen(Button.DPadLeft, ButtonState.Down, liikutaTaakse, "Liikkuu vasemmalle", p2, nopeusTaakse); 163 ControllerOne.Listen(Button.DPadRight, ButtonState.Down, liikutaEteenp2, "Liikkuu oikealle", p2, nopeusEteen); 164 ControllerOne.Listen(Key.A, ButtonState.Pressed, hyppaa, "Hyppää", p2, hyppyVoima); 165 ControllerOne.Listen(Key.B, ButtonState.Pressed, iske2, "iskee"); 166 ControllerOne.Listen(Key.B, ButtonState.Released, lp_isku2, "lopettaaiskun"); 167 168 } 157 169 158 170 void liikutaEteenp1(PlatformCharacter hahmo, double nopeus) … … 205 217 Add(hpbar2); 206 218 } 207 void hpp1(double x , double hp1)219 void hpp1(double x) 208 220 { 209 221 for (int i = 1; i < hp1; i++) … … 217 229 Add(hpp1); 218 230 hiparit.Push(hpp1); 219 220 } 221 } 222 void hpp2(double x , double hp2)231 hp1 = 102; 232 } 233 } 234 void hpp2(double x) 223 235 { 224 236 for (int i = 1; i < hp2; i++) … … 251 263 p1.Animation.FPS = 20; 252 264 } 253 for (int i = 0; i < 5; i++) 254 { 255 if (hiparit1.Count != 0) 256 { 257 hiparit1.Pop().Destroy(); 265 if (Vector.Distance(p1.Position, p2.Position) < 20) 266 { 267 for (int i = 0; i < 5; i++) 268 { 269 if (hiparit1.Count != 0) 270 { 271 hiparit1.Pop().Destroy(); 272 } 273 if (hiparit1.Count == 0) 274 { 275 p2.Destroy(); 276 MessageDisplay.Add("Pelaaja 1 voitti"); 277 ClearAll(); 278 Begin(); 279 hp2 = 102; 280 } 258 281 } 259 if (hiparit1.Count == 0) 260 { 261 p2.Destroy(); 262 MessageDisplay.Add("Pelaaja 1 voitti"); 263 ClearAll(); 264 Begin(); 265 } 266 } 282 } 267 283 } 268 284 269 285 void iske2() 270 286 { 271 if (Vector.Distance(p1.Position, p2.Position) == 10) 272 { 273 274 if (p2.FacingDirection == Direction.Left) 287 if (p2.FacingDirection == Direction.Left) 275 288 { 276 289 Image[] p2Kuvat = LoadImages("b1", "b2", "b3", "b4"); … … 278 291 p2.Animation.Start(); 279 292 p2.Animation.FPS = 20; 280 hp1 = hp1 - 10;281 293 282 294 } 283 295 if (p2.FacingDirection == Direction.Right) 284 296 { 285 297 Image[] p22Kuvat = LoadImages("b1_l", "b2_l", "b3_l", "b4_l"); … … 287 299 p2.Animation.Start(); 288 300 p2.Animation.FPS = 20; 289 hp1 = hp1 - 10;290 291 292 301 } 302 if (Vector.Distance(p2.Position, p1.Position) < 20) 303 { 293 304 for (int i = 0; i < 5; i++) 294 305 {
Note: See TracChangeset
for help on using the changeset viewer.